Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ var sandboxID string

var proxyLog = logrus.New()

// yamuxWriter is a type responsible for logging yamux messages to the proxy
// log.
type yamuxWriter struct {
}

// Write implements the Writer interface for the yamuxWriter.
func (yw yamuxWriter) Write(bytes []byte) (int, error) {
message := string(bytes)

l := len(message)

// yamux messages are all warnings and errors
logger().WithField("component", "yamux").Warn(message)

return l, nil
}

// This function is meant to run in a go routine since it will send ping
// commands every second. It behaves as a heartbeat to maintain a proper
// communication state with the Yamux server in the agent.
Expand All @@ -71,6 +88,9 @@ func serve(servConn io.ReadWriteCloser, proto, addr string, results chan error)
sessionConfig := yamux.DefaultConfig()
// Disable keepAlive since we don't know how much time a container can be paused
sessionConfig.EnableKeepAlive = false

sessionConfig.LogOutput = yamuxWriter{}

sessionConfig.ConnectionWriteTimeout = time.Second
session, err := yamux.Client(servConn, sessionConfig)
if err != nil {
Expand Down