stun

package module
v0.0.0-...-646d467 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 29 Imported by: 0

README

stun

Dumb vpn implementation on L3 level and udp as client server transport protocol.

Server support only linux. Client support mac os x and linux.

Build

make build

Run

Server

./stun -server -n=192.168.50.1/24

Client

sudo ./stun -p 100.100.100.100:1300  -n 192.168.50.5/24   -f domains.csv

Documentation

Index

Constants

View Source
const (
	KeepAliveMaxDuration           = 40 * time.Second
	KeepAliveRequestDuration       = KeepAliveMaxDuration - 10*time.Second
	RetryDelay                     = 2 * time.Second
	HandshakeDelay                 = 5 * time.Second
	DeviceMTU                int32 = 1280
	DeviceBufferSize               = tmsgMaxHeaderSize + int(DeviceMTU)
)

Variables

This section is empty.

Functions

func KeepRoutesToDomains

func KeepRoutesToDomains(ctx context.Context, tunDevice TunDevice, dnsServer string, domainsReader io.ReadCloser) error

func NotifyNetworkAddressesChanges

func NotifyNetworkAddressesChanges(ctx context.Context) (<-chan any, error)

func RunClient

func RunClient(ctx context.Context, tun TunDevice, config ClientConfig) error

func RunServer

func RunServer(ctx context.Context, tun TunDevice, config ServerConfig) error

func SubscribeSystemEvents

func SubscribeSystemEvents() (events <-chan SystemEvent, cancel func())

Types

type ClientConfig

type ClientConfig struct {
	NetworkCIDR           string
	ClientPort            int
	ServerInternetAddress string
	ServerPort            int
}

type Device

type Device struct {
	Addr netip.Addr
	Mask net.IPMask
	MTU  int
	FD   uintptr
}

type ServerConfig

type ServerConfig struct {
	ServerPort  int
	NetworkCIDR string
}

type TunDevice

type TunDevice interface {
	io.Reader
	io.Writer
	io.Closer
	LookupDeviceInfo() Device
	LinkName() string
}

func InitTunDevice

func InitTunDevice(n int) (ifce TunDevice, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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