Documentation ¶
Overview ¶
Package vsockconn implements a WireGuard bind supporting TCP and VSOCK transport protocols.
Index ¶
- Constants
- Variables
- func NewBind(logger *device.Logger, opts ...Option) conn.Bind
- func ParseVsockAddress(s string) (uint32, uint32, error)
- type Option
- type VSOCKBind
- func (s *VSOCKBind) BatchSize() int
- func (bind *VSOCKBind) Close() error
- func (bind *VSOCKBind) Open(port uint16) ([]conn.ReceiveFunc, uint16, error)
- func (bind *VSOCKBind) ParseEndpoint(s string) (conn.Endpoint, error)
- func (bind *VSOCKBind) Send(bufs [][]byte, end conn.Endpoint) error
- func (bind *VSOCKBind) SetMark(value uint32) error
- type VSOCKEndpoint
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 ¶
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.
type VSOCKBind ¶ added in v0.2.2
type VSOCKBind struct {
// contains filtered or unexported fields
}
func (*VSOCKBind) ParseEndpoint ¶ added in v0.2.2
type VSOCKEndpoint ¶ added in v0.2.2
type VSOCKEndpoint struct {
// contains filtered or unexported fields
}
func (*VSOCKEndpoint) ClearSrc ¶ added in v0.2.2
func (e *VSOCKEndpoint) ClearSrc()
func (VSOCKEndpoint) DstIP ¶ added in v0.2.2
func (e VSOCKEndpoint) DstIP() netip.Addr
func (VSOCKEndpoint) DstToBytes ¶ added in v0.2.2
func (e VSOCKEndpoint) DstToBytes() []byte
func (VSOCKEndpoint) DstToString ¶ added in v0.2.2
func (e VSOCKEndpoint) DstToString() string
func (VSOCKEndpoint) SrcIP ¶ added in v0.2.2
func (e VSOCKEndpoint) SrcIP() netip.Addr
func (VSOCKEndpoint) SrcToString ¶ added in v0.2.2
func (e VSOCKEndpoint) SrcToString() string