Documentation ¶
Overview ¶
Package vsockconn implements a WireGuard bind supporting TCP and VSOCK transport protocols.
Index ¶
Constants ¶
const ( // AnyCID can be used to check if the context ID of a VSOCK address is // equivalent to VMADDR_CID_ANY. AnyCID = math.MaxUint32 // AnyCID can be used to check if the port of a VSOCK address is equivalent // to VMADDR_PORT_ANY. AnyPort = math.MaxUint32 )
Variables ¶
var ( ErrInvalid = errors.New("invalid address") ErrPacketTooLong = errors.New("packet is too long (>64kb)") )
Functions ¶
func ParseVsockAddress ¶
ParseVsockAddress returns the context ID and port of a VSOCK string address in the format
`\(hypervisor(0)|local(1)|host(\([2-9]|[1-9][0-9]+\))\):[0-9]*`
Example:
vsockconn.ParseVsockAddress("host(2):12201")
will return context ID 2 and port 12201.
Types ¶
type Option ¶
type Option func(bind *vsockBind)
func WithNetwork ¶
WithNetwork returns an Option to define thee network to be used while creating listening sockets and connecting to peers. It can be 'vsock' or 'tcp'. The 'tcp' option doesn't provide a much robust implementation of a WireGuard transport; it should be used only for testing purposes on architectures lacking VSOCK. Defaults to 'vsock'.
func WithReconnectIntervalFactor ¶
WithReconnectInterval returns an Option defining the multiplying factor for each increment step while reconnecting. Defaults to 2.
func WithReconnectIntervalJitter ¶
WithReconnectInterval returns an Option defining the jitter used at reconnecting. Jitter eases contention by randomizing backoff steps. Defaults to true.
func WithReconnectIntervalMax ¶
WithReconnectIntervalMax returns an Option that defines the maximum interval to attempt reconnecting. Defaults to 30s.
func WithReconnectIntervalMin ¶
WithReconnectIntervalMin returns an Option that defines the minimum interval to attempt reconnecting. Defaults to 500ms.