usrwg

package
v0.0.0-...-9019093 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 20 Imported by: 0

README

Wireguard Userspace

WIP: This folder contains a WireGuardHost ran in userspace.

See this ongoing issue for more context: https://github.com/ShadowJonathan/eduP2P/issues/49.

On all platforms; The userspace wireguard implementation needs sufficient permissions to;

  • Create a network interface
  • (MacOS/Linux) Run ip/route commands.

For now, practically, this requires sudo on linux and macos, and an elevated prompt on windows (or gsudo).

(See this issue for more information about permission refinement: https://github.com/ShadowJonathan/eduP2P/issues/56)

This implementation will configure its own routing, interface, and IP address, as given by Control.

As for now, NewUsrWGHost() will create a new userspace host, which can be passed to toversok.Engine directly.

Permission errors bubble up at (*toversok.Engine).Start().

Documentation

Index

Constants

View Source
const ChannelConnBufferSize = 16
View Source
const SendTimeout = time.Second * 30
View Source
const WGGOIPCAddPeer = `public_key=%s
replace_allowed_ips=true
allowed_ip=%s/32
allowed_ip=%s/128
endpoint=%s
`
View Source
const WGGOIPCDevSetup = `private_key=%s
`

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelConn

type ChannelConn struct {
	// contains filtered or unexported fields
}

ChannelConn is a types.UDPConn based on two internal channels.

On the "frontend" (types.UDPConn) it supports SetReadDeadLine, as normal.

func (*ChannelConn) Close

func (cc *ChannelConn) Close() error

func (*ChannelConn) ReadFromUDPAddrPort

func (cc *ChannelConn) ReadFromUDPAddrPort(b []byte) (n int, addr netip.AddrPort, err error)

func (*ChannelConn) SetReadDeadline

func (cc *ChannelConn) SetReadDeadline(t time.Time) error

func (*ChannelConn) Write

func (cc *ChannelConn) Write(b []byte) (int, error)

func (*ChannelConn) WriteToUDPAddrPort

func (cc *ChannelConn) WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error)

type ToverSokBind

type ToverSokBind struct {
	// contains filtered or unexported fields
}

func (*ToverSokBind) BatchSize

func (b *ToverSokBind) BatchSize() int

func (*ToverSokBind) Close

func (b *ToverSokBind) Close() error

func (*ToverSokBind) CloseConn

func (b *ToverSokBind) CloseConn(peer key.NodePublic)

func (*ToverSokBind) GetConn

func (b *ToverSokBind) GetConn(peer key.NodePublic) *ChannelConn

func (*ToverSokBind) Open

func (b *ToverSokBind) Open(uint16) (fns []conn.ReceiveFunc, fakePort uint16, err error)

func (*ToverSokBind) ParseEndpoint

func (b *ToverSokBind) ParseEndpoint(s string) (conn.Endpoint, error)

func (*ToverSokBind) ReadFromConns

func (b *ToverSokBind) ReadFromConns(packets [][]byte, sizes []int, eps []conn.Endpoint) (n int, err error)

ReadFromConns implements conn.ReceiveFunc

func (*ToverSokBind) Send

func (b *ToverSokBind) Send(bufs [][]byte, ep conn.Endpoint) error

func (*ToverSokBind) SetMark

func (b *ToverSokBind) SetMark(mark uint32) error

SetMark is used by wireguard-go to avoid routing loops. TODO: double-check

type UserSpaceWireGuardController

type UserSpaceWireGuardController struct {
	// contains filtered or unexported fields
}

func (*UserSpaceWireGuardController) Close

func (u *UserSpaceWireGuardController) Close()

func (*UserSpaceWireGuardController) ConnFor

func (*UserSpaceWireGuardController) GetStats

func (u *UserSpaceWireGuardController) GetStats(publicKey key.NodePublic) (*toversok.WGStats, error)

func (*UserSpaceWireGuardController) RemovePeer

func (u *UserSpaceWireGuardController) RemovePeer(publicKey key.NodePublic) error

func (*UserSpaceWireGuardController) UpdatePeer

func (u *UserSpaceWireGuardController) UpdatePeer(publicKey key.NodePublic, cfg toversok.PeerCfg) error

type UserSpaceWireGuardHost

type UserSpaceWireGuardHost struct {
	// contains filtered or unexported fields
}

func NewUsrWGHost

func NewUsrWGHost() *UserSpaceWireGuardHost

func (*UserSpaceWireGuardHost) Controller

func (u *UserSpaceWireGuardHost) Controller(privateKey key.NodePrivate, addr4, addr6 netip.Prefix) (toversok.WireGuardController, error)

func (*UserSpaceWireGuardHost) Reset

func (u *UserSpaceWireGuardHost) Reset() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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