wireguard

package
v0.0.0-...-c97221a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceType = "wireguard"

ServiceType indicates "wireguard" service type

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap()

Bootstrap is called on program initialization time and registers various deserializers related to wireguard service

Types

type ConnectionEndpoint

type ConnectionEndpoint interface {
	StartConsumerMode(config wgcfg.DeviceConfig) error
	ReconfigureConsumerMode(config wgcfg.DeviceConfig) error
	StartProviderMode(publicIP string, config wgcfg.DeviceConfig) error
	PeerStats() (wgcfg.Stats, error)
	Config() (ServiceConfig, error)
	InterfaceName() string
	Stop() error
}

ConnectionEndpoint represents Wireguard network instance, it provide information required for establishing connection between service provider and consumer.

type ConsumerConfig

type ConsumerConfig struct {
	PublicKey string `json:"PublicKey"`
	// IP is needed when provider is behind NAT. In such case provider parses this IP and tries to ping consumer.
	IP    string `json:"IP,omitempty"`
	Ports []int  `json:"Ports"`
}

ConsumerConfig is used for sending the public key and IP from consumer to provider.

type EndpointFactory

type EndpointFactory func() (ConnectionEndpoint, error)

EndpointFactory creates new connection endpoint.

type ServiceConfig

type ServiceConfig struct {
	// LocalPort and RemotePort are needed for NAT hole punching only.
	LocalPort  int   `json:"-"`
	RemotePort int   `json:"-"`
	Ports      []int `json:"ports"`

	Provider struct {
		PublicKey string
		Endpoint  net.UDPAddr
	}
	Consumer struct {
		IPAddress net.IPNet
		DNSIPs    string
	}
}

ServiceConfig represent a Wireguard service provider configuration that will be passed to the consumer for establishing a connection.

func (ServiceConfig) MarshalJSON

func (s ServiceConfig) MarshalJSON() ([]byte, error)

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

func (*ServiceConfig) UnmarshalJSON

func (s *ServiceConfig) 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