package vpnkit
import "github.com/moby/vpnkit/go/pkg/vpnkit"
Package vpnkit allows a running VPNKit service to be reconfigured.
Features
- expose/unexpose TCP and UDP ports
Index ¶
- Constants
- type Client
- type Connection
- func NewConnection(ctx context.Context, path string) (*Connection, error)
- func NewConnectionForClient(client *datakit.Client) *Connection
- func (c *Connection) Expose(ctx context.Context, p *Port) error
- func (c *Connection) ListExposed(ctx context.Context) ([]Port, error)
- func (c *Connection) Unexpose(ctx context.Context, p *Port) error
- type DHCPConfiguration
- type Dialer
- type Forward
- type GatewayForwards
- type HTTPConfiguration
- type Port
- func NewPath(connection *Connection, outPath, inPath string) *Port
- func NewPort(connection *Connection, proto Protocol, outIP net.IP, outPort uint16, inIP net.IP, inPort uint16) *Port
- func (p *Port) String() string
- type Protocol
Constants ¶
const ( // TCP port is exposed TCP = Protocol("tcp") // UDP port is exposed UDP = Protocol("udp") // Unix domain socket is exposed Unix = Protocol("unix") )
const DefaultVsockPort = 62373
DefaultVsockPort is the default AF_VSOCK port where vpnkit-forwarder listens.
Types ¶
type Client ¶
type Client interface { Expose(context.Context, *Port) error Unexpose(context.Context, *Port) error ListExposed(context.Context) ([]Port, error) }
Client exposes and unexposes ports on vpnkit.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents an open control connection to vpnkit
func NewConnection ¶
func NewConnection(ctx context.Context, path string) (*Connection, error)
NewConnection connects to a vpnkit Unix domain socket on the given path and returns the connection. If the path is the empty string then the default system path will be used.
func NewConnectionForClient ¶
func NewConnectionForClient(client *datakit.Client) *Connection
NewConnectionForClient returns a connection using given client
func (*Connection) Expose ¶
func (c *Connection) Expose(ctx context.Context, p *Port) error
Expose asks vpnkit to expose the port
func (*Connection) ListExposed ¶
func (c *Connection) ListExposed(ctx context.Context) ([]Port, error)
ListExposed returns a list of currently exposed ports.
func (*Connection) Unexpose ¶
func (c *Connection) Unexpose(ctx context.Context, p *Port) error
Unexpose asks vpnkit to hide the port again
type DHCPConfiguration ¶
type DHCPConfiguration struct { SearchDomains []string `json:"searchDomains"` DomainName string `json:"domainName"` }
DHCPConfiguration configures the built-in DHCP server.
func (DHCPConfiguration) Write ¶
func (d DHCPConfiguration) Write(w io.Writer) error
type Dialer ¶
type Dialer struct { HyperkitConnectPath string // HyperkitConnectPath is the path of the `connect` Unix domain socket HyperVVMID string // HyperkitVMVMID is the GUID of the VM running vpnkit-forwarder Port int // Port is the AF_VSOCK port where vpnkit-forwarder is listening // contains filtered or unexported fields }
Dialer connects to remote addresses via the vpnkit-forwarder.
func (*Dialer) Dial ¶
Dial connects to the address on the named network.
type Forward ¶
type Forward struct { Protocol Protocol `json:"protocol"` ExternalPort int `json:"external_port"` InternalIP string `json:"internal_ip"` InternalPort int `json:"internal_port"` }
Forward is a single forward from the gateway IP ExternalPort to (InternalIP, InternalPort)
type GatewayForwards ¶
type GatewayForwards []Forward
GatewayForwards is a list of individual forwards.
func (GatewayForwards) Write ¶
func (g GatewayForwards) Write(w io.Writer) error
type HTTPConfiguration ¶
type HTTPConfiguration struct { HTTP string `json:"http,omitempty"` HTTPS string `json:"https,omitempty"` Exclude string `json:"exclude,omitempty"` TransparentHTTPPorts []int `json:"transparent_http_ports"` TransparentHTTPSPorts []int `json:"transparent_https_ports"` }
HTTPConfiguration configures the built-in HTTP proxy.
func (HTTPConfiguration) Write ¶
func (h HTTPConfiguration) Write(w io.Writer) error
type Port ¶
type Port struct { // Proto is the protocol used by the exposed port. Proto Protocol // OutIP is the external IP address. OutIP net.IP // OutPort is the external port number. OutPort uint16 // OutPath is the external Unix domain socket. OutPath string // InIP is the internal IP address. InIP net.IP // InPort is the internal port number. InPort uint16 // InPath is the internal Unix domain socket. InPath string // contains filtered or unexported fields }
Port describes a UDP, TCP port forward or a Unix domain socket forward.
func NewPath ¶
func NewPath(connection *Connection, outPath, inPath string) *Port
NewPath constructs an instance of a forwarded Unix path
func NewPort ¶
func NewPort(connection *Connection, proto Protocol, outIP net.IP, outPort uint16, inIP net.IP, inPort uint16) *Port
NewPort constructs an instance of a TCP or UDP Port
func (*Port) String ¶
String returns a human-readable string
type Protocol ¶
type Protocol string
Protocol used by the exposed port.
Source Files ¶
config.go connection.go connection_unix.go dialer.go dialer_darwin.go doc.go port.go
- Version
- v0.3.0
- Published
- Feb 7, 2019
- Platform
- darwin/amd64
- Imports
- 18 packages
- Last checked
- 6 hours ago –
Tools for package owners.