mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
In preparation for the daemon passing a listen fd, add command line option -use-listen-fd to indicate that the fd is present (as fd 4). If the new flag isn't given, open the listener as normal. Refactor the TCP and UDP proxies to be constructed with an existing TCPListener or UDPConn, respectively. Lift the responsibilty of opening the listener to the entrypoint. Per the Single Responsibility Principle, this structure affords changing how the listener is created without having to touch the proxy implementations. Co-authored-by: Cory Snider <csnider@mirantis.com> Signed-off-by: Rob Murray <rob.murray@docker.com>
33 lines
982 B
Go
33 lines
982 B
Go
// docker-proxy provides a network Proxy interface and implementations for TCP
|
|
// and UDP.
|
|
package main
|
|
|
|
import "net"
|
|
|
|
// ipVersion refers to IP version - v4 or v6
|
|
type ipVersion string
|
|
|
|
const (
|
|
// IPv4 is version 4
|
|
ipv4 ipVersion = "4"
|
|
// IPv4 is version 6
|
|
ipv6 ipVersion = "6"
|
|
)
|
|
|
|
// Proxy defines the behavior of a proxy. It forwards traffic back and forth
|
|
// between two endpoints : the frontend and the backend.
|
|
// It can be used to do software port-mapping between two addresses.
|
|
// e.g. forward all traffic between the frontend (host) 127.0.0.1:3000
|
|
// to the backend (container) at 172.17.42.108:4000.
|
|
type Proxy interface {
|
|
// Run starts forwarding traffic back and forth between the front
|
|
// and back-end addresses.
|
|
Run()
|
|
// Close stops forwarding traffic and close both ends of the Proxy.
|
|
Close()
|
|
// FrontendAddr returns the address on which the proxy is listening.
|
|
FrontendAddr() net.Addr
|
|
// BackendAddr returns the proxied address.
|
|
BackendAddr() net.Addr
|
|
}
|