const PingPeriod = 10 * time.Second
PortForwardProtocolV1Name is the subprotocol used for port forwarding. TODO move to API machinery and re-unify with kubelet/server/portfoward
const PortForwardProtocolV1Name = "portforward.k8s.io"
var ErrLostConnectionToPod = errors.New("lost connection to pod")
func NewFallbackDialer(primary, secondary httpstream.Dialer, shouldFallback func(error) bool) httpstream.Dialer
NewFallbackDialer creates the fallbackDialer with the primary and secondary dialers, as well as the boolean function to determine if the primary dialer failed.
func NewSPDYOverWebsocketDialer(url *url.URL, config *restclient.Config) (httpstream.Dialer, error)
NewTunnelingDialer creates and returns the tunnelingDialer structure which implemements the "httpstream.Dialer" interface. The dialer can upgrade a websocket request, creating a websocket connection. This function returns an error if one occurs.
ForwardedPort contains a Local:Remote port pairing.
type ForwardedPort struct { Local uint16 Remote uint16 }
PortForwarder knows how to listen for local connections and forward them to a remote pod via an upgraded HTTP request.
type PortForwarder struct {
Ready chan struct{}
// contains filtered or unexported fields
}
func New(dialer httpstream.Dialer, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)
New creates a new PortForwarder with localhost listen addresses.
func NewOnAddresses(dialer httpstream.Dialer, addresses []string, ports []string, stopChan <-chan struct{}, readyChan chan struct{}, out, errOut io.Writer) (*PortForwarder, error)
NewOnAddresses creates a new PortForwarder with custom listen addresses.
func (pf *PortForwarder) Close()
Close stops all listeners of PortForwarder.
func (pf *PortForwarder) ForwardPorts() error
ForwardPorts formats and executes a port forwarding request. The connection will remain open until stopChan is closed.
func (pf *PortForwarder) GetPorts() ([]ForwardedPort, error)
GetPorts will return the ports that were forwarded; this can be used to retrieve the locally-bound port in cases where the input was port 0. This function will signal an error if the Ready channel is nil or if the listeners are not ready yet; this function will succeed after the Ready channel has been closed.
TunnelingConnection implements the "httpstream.Connection" interface, wrapping a websocket connection that tunnels SPDY.
type TunnelingConnection struct {
// contains filtered or unexported fields
}
func NewTunnelingConnection(name string, conn *gwebsocket.Conn) *TunnelingConnection
NewTunnelingConnection wraps the passed gorilla/websockets connection with the TunnelingConnection struct (implementing net.Conn).
func (c *TunnelingConnection) Close() error
Close implements "io.Closer" interface, signaling the other tunneled connection endpoint, and closing the tunneled connection only once.
func (c *TunnelingConnection) LocalAddr() net.Addr
LocalAddr implements part of the "net.Conn" interface, returning the local endpoint network address of the tunneled connection.
func (c *TunnelingConnection) Read(p []byte) (int, error)
Read implements "io.Reader" interface, reading from the stored connection into the passed buffer "p". Returns the number of bytes read and an error. Can keep track of the "inProgress" messsage from the tunneled connection.
func (c *TunnelingConnection) RemoteAddr() net.Addr
LocalAddr implements part of the "net.Conn" interface, returning the remote endpoint network address of the tunneled connection.
func (c *TunnelingConnection) SetDeadline(t time.Time) error
SetDeadline sets the *absolute* time in the future for both read and write deadlines. Returns an error if one occurs.
func (c *TunnelingConnection) SetReadDeadline(t time.Time) error
SetDeadline sets the *absolute* time in the future for the read deadlines. Returns an error if one occurs.
func (c *TunnelingConnection) SetWriteDeadline(t time.Time) error
SetDeadline sets the *absolute* time in the future for the write deadlines. Returns an error if one occurs.
func (c *TunnelingConnection) Write(p []byte) (n int, err error)
Write implements "io.Writer" interface, copying the data in the passed byte array "p" into the stored tunneled connection. Returns the number of bytes written and an error.