2018-04-19 13:07:27 -04:00
|
|
|
package grpchijack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
controlapi "github.com/moby/buildkit/api/services/control"
|
|
|
|
"google.golang.org/grpc/metadata"
|
|
|
|
)
|
|
|
|
|
2018-09-26 08:26:12 -04:00
|
|
|
// Hijack hijacks session to a connection.
|
2018-04-19 13:07:27 -04:00
|
|
|
func Hijack(stream controlapi.Control_SessionServer) (net.Conn, <-chan struct{}, map[string][]string) {
|
|
|
|
md, _ := metadata.FromIncomingContext(stream.Context())
|
|
|
|
c, closeCh := streamToConn(stream)
|
|
|
|
return c, closeCh, md
|
|
|
|
}
|