edgevpn

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoveryService

func DiscoveryService(s ...ServiceDiscovery) func(cfg *Config) error

DiscoveryService Adds the service given as argument to the discovery services

func ExchangeKeys

func ExchangeKeys(s string) func(cfg *Config) error

func FromYaml

func FromYaml(path string) func(cfg *Config) error

func Handlers

func Handlers(h ...Handler) func(cfg *Config) error

Handlers adds a handler to the list that is called on each received message

func Insecure

func Insecure(b bool) func(cfg *Config) error

func ListenAddresses

func ListenAddresses(s string) func(cfg *Config) error

func LogLevel

func LogLevel(l log.LogLevel) func(cfg *Config) error

func Logger

func Logger(l *zap.Logger) func(cfg *Config) error

func MaxMessageSize

func MaxMessageSize(i int) func(cfg *Config) error

func Message

func Message(template string, opts ...interface{}) []byte

func RoomName

func RoomName(s string) func(cfg *Config) error

func SealKeyInterval

func SealKeyInterval(i int) func(cfg *Config) error

func SealKeyLength

func SealKeyLength(i int) func(cfg *Config) error

func WithInterface

func WithInterface(i *water.Interface) func(cfg *Config) error

func WithInterfaceAddress

func WithInterfaceAddress(i string) func(cfg *Config) error

func WithInterfaceMTU

func WithInterfaceMTU(i int) func(cfg *Config) error

func WithInterfaceName

func WithInterfaceName(i string) func(cfg *Config) error

func WithInterfaceType

func WithInterfaceType(d water.DeviceType) func(cfg *Config) error

func WithMTU

func WithMTU(i int) func(cfg *Config) error

Types

type Config

type Config struct {
	// ExchangeKey is a Symmetric key used to seal the messages
	ExchangeKey string

	// RoomName is the gossip room where all peers are subscribed to
	RoomName string

	// ListenAddresses is the discovery peer initial bootstrap addresses
	ListenAddresses discovery.AddrList

	// Insecure disables secure p2p e2e encrypted communication
	Insecure bool

	// Handlers are a list of handlers subscribed to messages received by the vpn interface
	Handlers []Handler

	MaxMessageSize   int
	MTU              int
	SealKeyInterval  int
	Interface        *water.Interface
	InterfaceName    string
	InterfaceAddress string
	InterfaceMTU     int
	DeviceType       water.DeviceType
	ServiceDiscovery []ServiceDiscovery
	Logger           *zap.Logger

	SealKeyLength int

	// Handle is a handle consumed by HumanInterfaces to handle received messages
	Handle func(bool, *hub.Message)
}

func (*Config) Apply

func (cfg *Config) Apply(opts ...Option) error

Apply applies the given options to the config, returning the first error encountered (if any).

type EdgeVPN

type EdgeVPN struct {
	HubRoom *hub.Room
	// contains filtered or unexported fields
}

func New

func New(p ...Option) *EdgeVPN

func (*EdgeVPN) Host

func (e *EdgeVPN) Host() host.Host

func (*EdgeVPN) MessageWriter

func (e *EdgeVPN) MessageWriter(opts ...hub.MessageOption) (*MessageWriter, error)

func (*EdgeVPN) Start

func (e *EdgeVPN) Start() error

func (*EdgeVPN) Stop

func (e *EdgeVPN) Stop()

end signals the event loop to exit gracefully

type Handler

type Handler func(*hub.Message) error

func IfaceWriter

func IfaceWriter(i *water.Interface) Handler

type MessageWriter

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

func (*MessageWriter) Send

func (mw *MessageWriter) Send(copy *hub.Message) (n int, err error)

func (*MessageWriter) Write

func (mw *MessageWriter) Write(p []byte) (n int, err error)

type OTP

type OTP struct {
	DHT    OTPConfig `yaml:"dht"`
	Crypto OTPConfig `yaml:"crypto"`
}

type OTPConfig

type OTPConfig struct {
	Interval int    `yaml:"interval"`
	Key      string `yaml:"key"`
	Length   int    `yaml:"length"`
}

type Option

type Option func(cfg *Config) error

type ServiceDiscovery

type ServiceDiscovery interface {
	Run(*zap.Logger, context.Context, host.Host) error
	Option(context.Context) func(c *libp2p.Config) error
}

type YAMLConnectionConfig

type YAMLConnectionConfig struct {
	OTP OTP `yaml:"otp"`

	RoomName   string `yaml:"room"`
	Rendezvous string `yaml:"rendezvous"`
	MDNS       string `yaml:"mdns"`
}

func GenerateNewConnectionData

func GenerateNewConnectionData() (*YAMLConnectionConfig, error)

func (YAMLConnectionConfig) Fill

func (y YAMLConnectionConfig) Fill(cfg *Config)

Jump to

Keyboard shortcuts

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