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 ¶
- type Connection
- type DhcpRequest
- type Ethernet
- type EthernetFrame
- func NewEthernetFrame(Dst, Src net.HardwareAddr, Type uint16) *EthernetFrame
- func ParseEthernetFrame(frame []byte) (*EthernetFrame, error)
- func (e *EthernetFrame) Bytes() []byte
- func (e *EthernetFrame) Write(w io.Writer) error
- type InitMessage
- type Ipv4
- func NewIpv4(Dst, Src net.IP) *Ipv4
- func ParseIpv4(packet []byte) (*Ipv4, error)
- func (i *Ipv4) Bytes() []byte
- func (i *Ipv4) HeaderBytes() []byte
- type PcapWriter
- func NewPcapWriter(w io.Writer) (*PcapWriter, error)
- func (p *PcapWriter) Write(packet []byte) error
- type Port
- func ListExposed(connection *Connection) ([]*Port, error)
- func NewPort(connection *Connection, proto string, outIP net.IP, outPort uint16, inIP net.IP, inPort uint16) *Port
- func (p *Port) Expose(ctx context.Context) error
- func (p *Port) InIP() net.IP
- func (p *Port) InPort() uint16
- func (p *Port) OutIP() net.IP
- func (p *Port) OutPort() uint16
- func (p *Port) Proto() string
- func (p *Port) String() string
- func (p *Port) Unexpose(ctx context.Context) error
- type Udpv4
- func NewUdpv4(ipv4 *Ipv4, Dst, Src uint16, Data []byte) *Udpv4
- func ParseUdpv4(packet []byte) (*Udpv4, error)
- func (u *Udpv4) Bytes() []byte
- func (u *Udpv4) Write(w io.Writer) error
- type Vif
- type Vmnet
Types ¶
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
type DhcpRequest ¶
type DhcpRequest struct { MAC net.HardwareAddr }
DhcpRequest is a simple DHCP request
func NewDhcpRequest ¶
func NewDhcpRequest(MAC net.HardwareAddr) *DhcpRequest
NewDhcpRequest constructs a DHCP request
func (*DhcpRequest) Bytes ¶
func (d *DhcpRequest) Bytes() []byte
Bytes returns the marshalled DHCP request
type Ethernet ¶
type Ethernet struct {
// contains filtered or unexported fields
}
Ethernet requests the creation of a network connection with a given uuid and optional IP
func NewEthernet ¶
NewEthernet creates an Ethernet frame
func (*Ethernet) Write ¶
Write marshals an Ethernet message
type EthernetFrame ¶
type EthernetFrame struct { Dst net.HardwareAddr Src net.HardwareAddr Type uint16 Data []byte }
EthernetFrame is an ethernet frame
func NewEthernetFrame ¶
func NewEthernetFrame(Dst, Src net.HardwareAddr, Type uint16) *EthernetFrame
NewEthernetFrame constructs an Ethernet frame
func ParseEthernetFrame ¶
func ParseEthernetFrame(frame []byte) (*EthernetFrame, error)
ParseEthernetFrame parses the ethernet frame
func (*EthernetFrame) Bytes ¶
func (e *EthernetFrame) Bytes() []byte
Bytes returns the marshalled ethernet frame
func (*EthernetFrame) Write ¶
func (e *EthernetFrame) Write(w io.Writer) error
Write marshals an Ethernet frame
type InitMessage ¶
type InitMessage struct {
// contains filtered or unexported fields
}
InitMessage is used for the initial version exchange
func (*InitMessage) String ¶
func (m *InitMessage) String() string
String returns a human-readable string.
func (*InitMessage) Write ¶
func (m *InitMessage) Write(c net.Conn) error
Write marshals an init message to a connection
type Ipv4 ¶
Ipv4 is an IPv4 frame
func NewIpv4 ¶
NewIpv4 constructs a new empty IPv4 packet
func ParseIpv4 ¶
ParseIpv4 parses an IP packet
func (*Ipv4) Bytes ¶
Bytes returns the marshalled IPv4 packet
func (*Ipv4) HeaderBytes ¶
HeaderBytes returns the marshalled form of the IPv4 header
type PcapWriter ¶
type PcapWriter struct {
// contains filtered or unexported fields
}
PcapWriter writes pcap-formatted packet streams
func NewPcapWriter ¶
func NewPcapWriter(w io.Writer) (*PcapWriter, error)
NewPcapWriter creates a PcapWriter and writes the initial header
func (*PcapWriter) Write ¶
func (p *PcapWriter) Write(packet []byte) error
Write appends a packet with a pcap-format header
type Port ¶
type Port struct {
// contains filtered or unexported fields
}
Port describes a UDP or TCP port forward
func ListExposed ¶
func ListExposed(connection *Connection) ([]*Port, error)
ListExposed returns a list of currently exposed ports
func NewPort ¶
func NewPort(connection *Connection, proto string, outIP net.IP, outPort uint16, inIP net.IP, inPort uint16) *Port
NewPort constructs an instance of Port
func (*Port) Expose ¶
Expose asks vpnkit to expose the port
func (*Port) InIP ¶
InIP returns the private IP
func (*Port) InPort ¶
InPort returns the private port number
func (*Port) OutIP ¶
OutIP returns the public IP
func (*Port) OutPort ¶
OutPort returns the public port number
func (*Port) Proto ¶
Proto returns the protocol: either "tcp" or "udp"
func (*Port) String ¶
String returns a human-readable string
func (*Port) Unexpose ¶
Unexpose asks vpnkit to hide the port again
type Udpv4 ¶
Udpv4 is a Udpv4 frame
func NewUdpv4 ¶
NewUdpv4 constructs a Udpv4 frame
func ParseUdpv4 ¶
ParseUdpv4 parses a Udpv4 packet
func (*Udpv4) Bytes ¶
Bytes returns the marshalled Udpv4 frame
func (*Udpv4) Write ¶
Write marshalls a Udpv4 frame
type Vif ¶
type Vif struct { MTU uint16 MaxPacketSize uint16 ClientMAC net.HardwareAddr IP net.IP // contains filtered or unexported fields }
Vif represents an Ethernet device
func (*Vif) Read ¶
Read reads the next packet from a Vif
func (*Vif) Write ¶
Write writes a packet to a Vif
type Vmnet ¶
type Vmnet struct {
// contains filtered or unexported fields
}
Vmnet describes a "vmnet protocol" connection which allows ethernet frames to be sent to and received by vpnkit.
func NewVmnet ¶
NewVmnet constructs an instance of Vmnet.
func (*Vmnet) Close ¶
Close closes the connection.
func (*Vmnet) ConnectVif ¶
ConnectVif returns a connected network interface with the given uuid.
func (*Vmnet) ConnectVifIP ¶
ConnectVifIP returns a connected network interface with the given uuid and IP. If the IP is already in use then return an error.
Source Files ¶
connection.go doc.go port.go vmnet.go
- Version
- v0.2.0
- Published
- Jan 3, 2018
- Platform
- js/wasm
- Imports
- 15 packages
- Last checked
- 1 day ago –
Tools for package owners.