service

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Subnet: net.IPNet{
		IP:   net.ParseIP("10.182.0.0").To4(),
		Mask: net.IPv4Mask(255, 255, 0, 0),
	},
}

DefaultOptions is a wireguard service configuration that will be used if no options provided.

Functions

func ParseJSONOptions

func ParseJSONOptions(request *json.RawMessage) (service.Options, error)

ParseJSONOptions function fills in Wireguard options from JSON request

Types

type Manager

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

Manager represents an instance of Wireguard service

func NewManager

func NewManager(
	ipResolver ip.Resolver,
	country string,
	natService nat.NATService,
	eventBus eventbus.EventBus,
	trafficFirewall firewall.IncomingTrafficFirewall,
	resourcesAllocator *resources.Allocator,
	wgClientFactory *endpoint.WgClientFactory,
	dnsProxy *dns.Proxy,
) *Manager

NewManager creates new instance of Wireguard service

func (*Manager) ProvideConfig

func (m *Manager) ProvideConfig(sessionID string, sessionConfig json.RawMessage, remoteConn *net.UDPConn) (*service.ConfigParams, error)

ProvideConfig provides the config for consumer and handles new WireGuard connection.

func (*Manager) Serve

func (m *Manager) Serve(instance *service.Instance) error

Serve starts service - does block

func (*Manager) Stop

func (m *Manager) Stop() error

Stop stops service.

type Options

type Options struct {
	Subnet net.IPNet
}

Options describes options which are required to start Wireguard service.

func GetOptions

func GetOptions() Options

GetOptions returns effective Wireguard service options from application configuration.

func (Options) MarshalJSON

func (o Options) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface to provide human readable configuration.

func (*Options) UnmarshalJSON

func (o *Options) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface to receive human readable configuration.

Jump to

Keyboard shortcuts

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