package libproxy
import "github.com/moby/vpnkit/go/pkg/libproxy"
Package libproxy provides a network Proxy interface and implementations for TCP and UDP.
Index ¶
- Constants
- func HandleTCPConnection(client Conn, backendAddr *net.TCPAddr, quit chan bool)
- type Conn
- type Proxy
- func NewIPProxy(frontendAddr, backendAddr net.Addr) (Proxy, error)
- func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error)
- func NewVsockProxy(frontendAddr *vsock.VsockAddr, backendAddr net.Addr) (Proxy, error)
- type StubProxy
- func (p *StubProxy) BackendAddr() net.Addr
- func (p *StubProxy) Close()
- func (p *StubProxy) FrontendAddr() net.Addr
- func (p *StubProxy) Run()
- type TCPProxy
- func NewTCPProxy(listener net.Listener, backendAddr *net.TCPAddr) (*TCPProxy, error)
- func (proxy *TCPProxy) BackendAddr() net.Addr
- func (proxy *TCPProxy) Close()
- func (proxy *TCPProxy) FrontendAddr() net.Addr
- func (proxy *TCPProxy) Run()
- type UDPListener
- type UDPProxy
Constants ¶
const ( // UDPConnTrackTimeout is the timeout used for UDP connection tracking UDPConnTrackTimeout = 90 * time.Second // UDPBufSize is the buffer size for the UDP proxy UDPBufSize = 65507 )
Functions ¶
func HandleTCPConnection ¶
HandleTCPConnection forwards the TCP traffic to a specified backend address
Types ¶
type Conn ¶
Conn defines a network connection
type Proxy ¶
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 }
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.
func NewIPProxy ¶
NewIPProxy creates a Proxy according to the specified frontendAddr and backendAddr.
func NewStubProxy ¶
NewStubProxy creates a new StubProxy
func NewVsockProxy ¶
NewVsockProxy creates a Proxy listening on Vsock
type StubProxy ¶
type StubProxy struct {
// contains filtered or unexported fields
}
StubProxy is a proxy that is a stub (does nothing).
func (*StubProxy) BackendAddr ¶
BackendAddr returns the backend address.
func (*StubProxy) Close ¶
func (p *StubProxy) Close()
Close does nothing.
func (*StubProxy) FrontendAddr ¶
FrontendAddr returns the frontend address.
func (*StubProxy) Run ¶
func (p *StubProxy) Run()
Run does nothing.
type TCPProxy ¶
type TCPProxy struct {
// contains filtered or unexported fields
}
TCPProxy is a proxy for TCP connections. It implements the Proxy interface to handle TCP traffic forwarding between the frontend and backend addresses.
func NewTCPProxy ¶
NewTCPProxy creates a new TCPProxy.
func (*TCPProxy) BackendAddr ¶
BackendAddr returns the TCP proxied address.
func (*TCPProxy) Close ¶
func (proxy *TCPProxy) Close()
Close stops forwarding the traffic.
func (*TCPProxy) FrontendAddr ¶
FrontendAddr returns the TCP address on which the proxy is listening.
func (*TCPProxy) Run ¶
func (proxy *TCPProxy) Run()
Run starts forwarding the traffic using TCP.
type UDPListener ¶
type UDPListener interface { ReadFromUDP(b []byte) (int, *net.UDPAddr, error) WriteToUDP(b []byte, addr *net.UDPAddr) (int, error) Close() error }
UDPListener defines a listener interface to read, write and close a UDP connection
func NewUDPConn ¶
func NewUDPConn(conn net.Conn) UDPListener
NewUDPConn initializes a new UDP connection
func NewUDPListener ¶
func NewUDPListener(listener net.Listener) UDPListener
NewUDPListener initializes a new UDP listener
type UDPProxy ¶
type UDPProxy struct {
// contains filtered or unexported fields
}
UDPProxy is proxy for which handles UDP datagrams. It implements the Proxy interface to handle UDP traffic forwarding between the frontend and backend addresses.
func NewUDPProxy ¶
func NewUDPProxy(frontendAddr net.Addr, listener UDPListener, backendAddr *net.UDPAddr) (*UDPProxy, error)
NewUDPProxy creates a new UDPProxy.
func (*UDPProxy) BackendAddr ¶
BackendAddr returns the proxied UDP address.
func (*UDPProxy) Close ¶
func (proxy *UDPProxy) Close()
Close stops forwarding the traffic.
func (*UDPProxy) FrontendAddr ¶
FrontendAddr returns the UDP address on which the proxy is listening.
func (*UDPProxy) Run ¶
func (proxy *UDPProxy) Run()
Run starts forwarding the traffic using UDP.
Source Files ¶
proxy.go stub_proxy.go tcp_proxy.go udp_encapsulation.go udp_proxy.go
- Version
- v0.1.0
- Published
- Aug 17, 2017
- Platform
- js/wasm
- Imports
- 11 packages
- Last checked
- 1 day ago –
Tools for package owners.