edgevpn

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Protocol        = "/edgevpn/0.1"
	ServiceProtocol = "/edgevpn/service/0.1"
	FileProtocol    = "/edgevpn/file/0.1"
)
View Source
const (
	ServicesLedgerKey = "services"
	UsersLedgerKey    = "users"
)
View Source
const (
	FilesLedgerKey = "files"
)
View Source
const MachinesLedgerKey = "machines"

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 FromBase64 added in v0.0.6

func FromBase64(bb 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 LibP2PLogLevel added in v0.2.2

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

func ListenAddresses

func ListenAddresses(ss ...string) func(cfg *Config) error

func Logger

func Logger(l log.StandardLogger) func(cfg *Config) error

func MaxMessageSize

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

func Message

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

func NetLinkBootstrap added in v0.0.3

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

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 WithLibp2pAdditionalOptions added in v0.0.4

func WithLibp2pAdditionalOptions(i ...libp2p.Option) func(cfg *Config) error

func WithLibp2pOptions added in v0.0.3

func WithLibp2pOptions(i ...libp2p.Option) func(cfg *Config) error

WithLibp2pOptions Overrides defaults options

func WithMaxBlockChainSize added in v0.0.5

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

func WithPacketMTU added in v0.0.5

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

func WithStreamHandler added in v0.1.0

func WithStreamHandler(id protocol.ID, h StreamHandler) func(cfg *Config) error

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

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
	SealKeyInterval  int
	Interface        *water.Interface
	InterfaceName    string
	InterfaceAddress string
	InterfaceMTU     int
	MTU              int
	DeviceType       water.DeviceType
	ServiceDiscovery []ServiceDiscovery
	Logger           log.StandardLogger

	SealKeyLength int

	MaxBlockChainLength int

	NetLinkBootstrap bool

	// Handle is a handle consumed by HumanInterfaces to handle received messages
	Handle                     func(bool, *hub.Message)
	StreamHandlers             map[protocol.ID]StreamHandler
	AdditionalOptions, Options []libp2p.Option

	LedgerSyncronizationTime, LedgerAnnounceTime time.Duration
}

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) ConnectToService added in v0.2.0

func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string, srcaddr string) error

func (*EdgeVPN) ExposeService added in v0.2.0

func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress string)

func (*EdgeVPN) Host

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

func (*EdgeVPN) Join added in v0.1.0

func (e *EdgeVPN) Join(ledger *blockchain.Ledger) error

Join the network with the ledger. It does the minimal action required to be connected without any active packet routing

func (*EdgeVPN) Logger added in v0.2.2

func (e *EdgeVPN) Logger() log.StandardLogger

func (*EdgeVPN) MessageWriter

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

MessageWriter returns a new MessageWriter bound to the edgevpn instance with the given options

func (*EdgeVPN) ReceiveFile added in v0.2.1

func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path string) error

func (*EdgeVPN) SendFile added in v0.2.1

func (e *EdgeVPN) SendFile(ledger *blockchain.Ledger, fileID, filepath string) error

func (*EdgeVPN) Start

func (e *EdgeVPN) Start() error

Start the vpn. Returns an error in case of failure

func (*EdgeVPN) Stop

func (e *EdgeVPN) Stop()

end signals the event loop to exit gracefully

type Handler

type Handler func(*hub.Message) error

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)

func (*MessageWriter) WriteString added in v0.0.5

func (mw *MessageWriter) WriteString(p string) (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(log.StandardLogger, context.Context, host.Host) error
	Option(context.Context) func(c *libp2p.Config) error
}

type StreamHandler added in v0.1.0

type StreamHandler func(stream network.Stream)

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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