mtvnode

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 32 Imported by: 1

README

mtv-node

Documentation

Index

Constants

View Source
const (
	NameID     = "id"
	NameConfig = "config"
	NamePSK    = "swarmkey"
)

Define the names of arguments here.

Variables

This section is empty.

Functions

func CreateLdb

func CreateLdb(dbRootDir string) (*levelds.Datastore, error)

func GenerateIdentity

func GenerateIdentity(path string) (crypto.PrivKey, error)

GenerateIdentity writes a new random private key to the given path.

func LoadIdentity

func LoadIdentity(idPath string) (crypto.PrivKey, error)

LoadIdentity reads a private key from the given path and, if it does not exist, generates a new one.

func ReadIdentity

func ReadIdentity(path string) (crypto.PrivKey, error)

ReadIdentity reads a private key from the given path.

Types

type ACLConfig

type ACLConfig struct {
	AllowPeers   []string
	AllowSubnets []string
}

ACLConfig provides filtering configuration to allow specific peers or subnets to be fronted by relays. In V2, this specifies the peers/subnets that are able to make reservations on the relay. In V1, this specifies the peers/subnets that can be contacted through the relays.

type ACLFilter

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

ACLFilter implements the libp2p relay ACL interface.

func NewACL

func NewACL(h host.Host, cfg ACLConfig) (*ACLFilter, error)

NewACL returns an implementation of the relay ACL interface using the given host and relay daemon ACL config.

func (*ACLFilter) AllowConnect

func (a *ACLFilter) AllowConnect(src peer.ID, srcAddr ma.Multiaddr, dest peer.ID) bool

AllowConnect is always true, as we are accepting any public node to be able to contact the nodes allowed to make reservations through this relay.

func (*ACLFilter) AllowHop

func (a *ACLFilter) AllowHop(src, dest peer.ID) bool

AllowHop is relevant for relayv1 ACL implementation.

func (*ACLFilter) AllowReserve

func (a *ACLFilter) AllowReserve(p peer.ID, addr ma.Multiaddr) bool

AllowReserve is relevant for the relayv2 ACL implementation.

func (*ACLFilter) Connected

func (a *ACLFilter) Connected(n network.Network, c network.Conn)

Connected handles the Connect notification and stores the address of the connected node so that the ACL can decide whether other nodes can connect to it (relayV1).

func (*ACLFilter) Disconnected

func (a *ACLFilter) Disconnected(n network.Network, c network.Conn)

Disconnected handles the Disconnect notification and deletes the address of the disconnected node.

type BootstrapConfig

type BootstrapConfig struct {
	BootstrapPeers []string
}

type Config

type Config struct {
	Network NetworkConfig
	ConnMgr ConnMgrConfig
	// RelayV1 RelayV1Config
	RelayV2   RelayV2Config
	ACL       ACLConfig
	Daemon    DaemonConfig
	Bootstrap BootstrapConfig
	DHT       DHTConfig
}

Config stores the full configuration of the relays, ACLs and other settings that influence behaviour of a relay daemon.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a default relay configuration using default resource settings and no ACLs.

func LoadConfig

func LoadConfig(cfgPath string) (Config, error)

LoadConfig reads a relay daemon JSON configuration from the given path. The configuration is first initialized with DefaultConfig, so all unset fields will take defaults from there.

type ConnMgrConfig

type ConnMgrConfig struct {
	ConnMgrLo    int
	ConnMgrHi    int
	ConnMgrGrace time.Duration
}

ConnMgrConfig controls the libp2p connection manager settings.

type DHTConfig

type DHTConfig struct {
	DatastoreRootDir string
}

type DaemonConfig

type DaemonConfig struct {
	PprofPort int
}

DaemonConfig controls settings for the relay-daemon itself.

type MtvNode

type MtvNode struct {
	Host  host.Host
	Addrs peer.AddrInfo
	Dht   *dht.IpfsDHT
}

func NewMtvNode

func NewMtvNode() (*MtvNode, error)

func (*MtvNode) StartNode

func (m *MtvNode) StartNode()

type NetworkConfig

type NetworkConfig struct {
	ListenAddrs   []string
	AnnounceAddrs []string
}

NetworkConfig controls listen and annouce settings for the libp2p host.

type PNetFingerprint

type PNetFingerprint []byte

func LoadSwarmKey

func LoadSwarmKey(path string) (pnet.PSK, PNetFingerprint, error)

LoadSwarmKey loads a swarm key at the given filepath and decodes it as a PSKv1.

type RelayV2Config

type RelayV2Config struct {
	Enabled   bool
	Resources relayv2.Resources
}

RelayV2Config controls activation of V2 circuits and resouce configuration for them.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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