hvsock

package
v0.0.0-...-8be290c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package hvsock provides a Go interface to Hyper-V sockets both on Windows and on Linux. The Linux bindings require patches for the 4.9.x kernel. If you are using a Linux kernel 4.14.x or newer you should use the vsock package instead as the Hyper-V socket support in these kernels have been merged with the virtio sockets implementation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// GUIDZero used by listeners to accept connections from all partitions
	GUIDZero, _ = GUIDFromString("00000000-0000-0000-0000-000000000000")
	// GUIDWildcard used by listeners to accept connections from all partitions
	GUIDWildcard, _ = GUIDFromString("00000000-0000-0000-0000-000000000000")
	// GUIDBroadcast undocumented
	GUIDBroadcast, _ = GUIDFromString("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF")
	// GUIDChildren used by listeners to accept connections from children
	GUIDChildren, _ = GUIDFromString("90db8b89-0d35-4f79-8ce9-49ea0ac8b7cd")
	// GUIDLoopback use to connect in loopback mode
	GUIDLoopback, _ = GUIDFromString("e0e16197-dd56-4a10-9195-5ee7a155a838")
	// GUIDParent use to connect to the parent partition
	GUIDParent, _ = GUIDFromString("a42e7cda-d03f-480c-9cc2-a4de20abb878")
)

Functions

func Listen

func Listen(addr Addr) (net.Listener, error)

Listen returns a net.Listener which can accept connections on the given port

func Supported

func Supported() bool

Supported returns if hvsocks are supported on your platform

Types

type Addr

type Addr struct {
	VMID      GUID
	ServiceID GUID
}

Addr represents a Hyper-V socket address

func (Addr) Network

func (a Addr) Network() string

Network returns the type of network for Hyper-V sockets

func (Addr) String

func (a Addr) String() string

type Conn

type Conn interface {
	net.Conn
	CloseRead() error
	CloseWrite() error
}

Conn is a hvsock connection which supports half-close.

func Dial

func Dial(raddr Addr) (Conn, error)

Dial a Hyper-V socket address

type GUID

type GUID [16]byte

GUID is used by Hypper-V sockets for "addresses" and "ports"

func GUIDFromString

func GUIDFromString(s string) (GUID, error)

GUIDFromString parses a string and returns a GUID

func (*GUID) Port

func (g *GUID) Port() (uint32, error)

Port converts a Service GUID to a "port" usable by the vsock package. It can be used to convert hvsock code to vsock code. On 4.14.x kernels Service GUIDs for talking to Linux should have the form of xxxxxxxx-facb-11e6-bd58-64006a7986d3, where xxxxxxxx is the vsock port.

func (*GUID) String

func (g *GUID) String() string

Convert a GUID into a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL