Documentation ¶
Index ¶
- Constants
- func RunningVersion() (version uint32, err error)
- func Uninstall() (err error)
- func UninstallLegacyWintun() error
- func Version() string
- type Adapter
- func (wireguard *Adapter) AdapterState() (adapterState AdapterState, err error)
- func (wireguard *Adapter) Close() (err error)
- func (wireguard *Adapter) Configuration() (interfaze *Interface, err error)
- func (wireguard *Adapter) LUID() (luid winipcfg.LUID)
- func (wireguard *Adapter) SetAdapterState(adapterState AdapterState) (err error)
- func (wireguard *Adapter) SetConfiguration(interfaze *Interface, size uint32) (err error)
- func (wireguard *Adapter) SetLogging(logState AdapterLogState) (err error)
- type AdapterLogState
- type AdapterState
- type AllowedIP
- type ConfigBuilder
- func (builder *ConfigBuilder) AppendAllowedIP(allowedIP *AllowedIP)
- func (builder *ConfigBuilder) AppendInterface(interfaze *Interface)
- func (builder *ConfigBuilder) AppendPeer(peer *Peer)
- func (builder *ConfigBuilder) Interface() (*Interface, uint32)
- func (builder *ConfigBuilder) Preallocate(size uint32)
- type Interface
- type InterfaceFlag
- type Peer
- type PeerFlag
- type TimestampedWriter
Constants ¶
const AdapterNameMax = 128
Variables ¶
This section is empty.
Functions ¶
func RunningVersion ¶
RunningVersion returns the version of the loaded driver.
func Uninstall ¶ added in v0.4.11
func Uninstall() (err error)
Uninstall removes the driver from the system if no drivers are currently in use.
func UninstallLegacyWintun ¶ added in v0.5.3
func UninstallLegacyWintun() error
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func CreateAdapter ¶ added in v0.4.11
func CreateAdapter(name, tunnelType string, requestedGUID *windows.GUID) (wireguard *Adapter, err error)
CreateAdapter creates a WireGuard adapter. name is the cosmetic name of the adapter. tunnelType represents the type of adapter and should be "WireGuard". requestedGUID is the GUID of the created network adapter, which then influences NLA generation deterministically. If it is set to nil, the GUID is chosen by the system at random, and hence a new NLA entry is created for each new adapter.
func OpenAdapter ¶ added in v0.4.11
OpenAdapter opens an existing WireGuard adapter by name.
func (*Adapter) AdapterState ¶
func (wireguard *Adapter) AdapterState() (adapterState AdapterState, err error)
AdapterState returns the current state of the adapter.
func (*Adapter) Configuration ¶
Configuration gets the adapter configuration.
func (*Adapter) SetAdapterState ¶
func (wireguard *Adapter) SetAdapterState(adapterState AdapterState) (err error)
SetAdapterState sets the adapter either Up or Down.
func (*Adapter) SetConfiguration ¶
SetConfiguration sets the adapter configuration.
func (*Adapter) SetLogging ¶
func (wireguard *Adapter) SetLogging(logState AdapterLogState) (err error)
SetLogging enables or disables logging on the WireGuard adapter.
type AdapterLogState ¶
type AdapterLogState uint32
const ( AdapterLogOff AdapterLogState = 0 AdapterLogOn AdapterLogState = 1 AdapterLogOnWithPrefix AdapterLogState = 2 )
type AdapterState ¶
type AdapterState uint32
const ( AdapterStateDown AdapterState = 0 AdapterStateUp AdapterState = 1 )
type AllowedIP ¶
type AllowedIP struct { Address [16]byte AddressFamily winipcfg.AddressFamily Cidr uint8 // contains filtered or unexported fields }
func (*AllowedIP) NextAllowedIP ¶
NextAllowedIP returns the subsequent allowed IP of the current one.
type ConfigBuilder ¶
type ConfigBuilder struct {
// contains filtered or unexported fields
}
func (*ConfigBuilder) AppendAllowedIP ¶
func (builder *ConfigBuilder) AppendAllowedIP(allowedIP *AllowedIP)
AppendAllowedIP appends an allowed IP to the building configuration. This should be called after a peer has been added.
func (*ConfigBuilder) AppendInterface ¶
func (builder *ConfigBuilder) AppendInterface(interfaze *Interface)
AppendInterface appends an interface to the building configuration. This should be called first.
func (*ConfigBuilder) AppendPeer ¶
func (builder *ConfigBuilder) AppendPeer(peer *Peer)
AppendPeer appends a peer to the building configuration. This should be called after an interface has been added.
func (*ConfigBuilder) Interface ¶
func (builder *ConfigBuilder) Interface() (*Interface, uint32)
Interface assembles the configuration and returns the interface and length to be passed to SetConfiguration.
func (*ConfigBuilder) Preallocate ¶
func (builder *ConfigBuilder) Preallocate(size uint32)
Preallocate reserves memory in the config builder to reduce allocations of append operations.
type Interface ¶
type Interface struct { Flags InterfaceFlag ListenPort uint16 PrivateKey [32]byte PublicKey [32]byte PeerCount uint32 // contains filtered or unexported fields }
type InterfaceFlag ¶
type InterfaceFlag uint32
const ( InterfaceHasPublicKey InterfaceFlag = 1 << 0 InterfaceHasPrivateKey InterfaceFlag = 1 << 1 InterfaceHasListenPort InterfaceFlag = 1 << 2 InterfaceReplacePeers InterfaceFlag = 1 << 3 )
type Peer ¶
type Peer struct { Flags PeerFlag PublicKey [32]byte PersistentKeepalive uint16 Endpoint winipcfg.RawSockaddrInet TxBytes uint64 RxBytes uint64 LastHandshake uint64 AllowedIPsCount uint32 // contains filtered or unexported fields }
func (*Peer) FirstAllowedIP ¶
FirstAllowedIP returns the first allowed IP attached to the peer.