vendor: revendor

This commit is contained in:
Sergiusz Urbaniak 2020-12-14 12:43:28 +01:00
parent 269295a414
commit 9f0440be0f
No known key found for this signature in database
GPG key ID: 44E6612519E13C39
669 changed files with 58447 additions and 20021 deletions

View file

@ -51,6 +51,12 @@ type grpcTunnel struct {
connsLock sync.RWMutex
}
type clientConn interface {
Close() error
}
var _ clientConn = &grpc.ClientConn{}
// CreateSingleUseGrpcTunnel creates a Tunnel to dial to a remote server through a
// gRPC based proxy service.
// Currently, a single tunnel supports a single connection, and the tunnel is closed when the connection is terminated
@ -79,7 +85,7 @@ func CreateSingleUseGrpcTunnel(address string, opts ...grpc.DialOption) (Tunnel,
return tunnel, nil
}
func (t *grpcTunnel) serve(c *grpc.ClientConn) {
func (t *grpcTunnel) serve(c clientConn) {
defer c.Close()
for {
@ -88,11 +94,11 @@ func (t *grpcTunnel) serve(c *grpc.ClientConn) {
return
}
if err != nil || pkt == nil {
klog.Warningf("stream read error: %v", err)
klog.ErrorS(err, "stream read failure")
return
}
klog.V(6).Infof("[tracing] recv packet, type: %s", pkt.Type)
klog.V(5).InfoS("[tracing] recv packet", "type", pkt.Type)
switch pkt.Type {
case client.PacketType_DIAL_RSP:
@ -102,7 +108,7 @@ func (t *grpcTunnel) serve(c *grpc.ClientConn) {
t.pendingDialLock.RUnlock()
if !ok {
klog.Warning("DialResp not recognized; dropped")
klog.V(1).Infoln("DialResp not recognized; dropped")
} else {
ch <- dialResult{
err: resp.Error,
@ -119,7 +125,7 @@ func (t *grpcTunnel) serve(c *grpc.ClientConn) {
if ok {
conn.readCh <- resp.Data
} else {
klog.Warningf("connection id %d not recognized", resp.ConnectID)
klog.V(1).InfoS("connection not recognized", "connectionID", resp.ConnectID)
}
case client.PacketType_CLOSE_RSP:
resp := pkt.GetCloseResponse()
@ -136,7 +142,7 @@ func (t *grpcTunnel) serve(c *grpc.ClientConn) {
t.connsLock.Unlock()
return
}
klog.Warningf("connection id %d not recognized", resp.ConnectID)
klog.V(1).InfoS("connection not recognized", "connectionID", resp.ConnectID)
}
}
}
@ -169,14 +175,14 @@ func (t *grpcTunnel) Dial(protocol, address string) (net.Conn, error) {
},
},
}
klog.V(6).Infof("[tracing] send packet, type: %s", req.Type)
klog.V(5).InfoS("[tracing] send packet", "type", req.Type)
err := t.stream.Send(req)
if err != nil {
return nil, err
}
klog.Info("DIAL_REQ sent to proxy server")
klog.V(5).Infoln("DIAL_REQ sent to proxy server")
c := &conn{stream: t.stream}

View file

@ -54,7 +54,7 @@ func (c *conn) Write(data []byte) (n int, err error) {
},
}
klog.V(6).Infof("[tracing] send req, type: %s", req.Type)
klog.V(5).InfoS("[tracing] send req", "type", req.Type)
err = c.stream.Send(req)
if err != nil {
@ -112,7 +112,7 @@ func (c *conn) SetWriteDeadline(t time.Time) error {
// Close closes the connection. It also sends CLOSE_REQ packet over
// proxy service to notify remote to drop the connection.
func (c *conn) Close() error {
klog.Info("conn.Close()")
klog.V(4).Infoln("closing connection")
req := &client.Packet{
Type: client.PacketType_CLOSE_REQ,
Payload: &client.Packet_CloseRequest{
@ -122,7 +122,7 @@ func (c *conn) Close() error {
},
}
klog.V(6).Infof("[tracing] send req, type: %s", req.Type)
klog.V(5).InfoS("[tracing] send req", "type", req.Type)
if err := c.stream.Send(req); err != nil {
return err