networking

package
v0.0.0-...-21c0dde Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPrivateKey

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

Types

type Network

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

func NewNetwork

func NewNetwork(ctx context.Context, port int, pkey string, bootstrapNodes []string, fs *storage.FileStore) *Network

func (*Network) AnnounceFile

func (n *Network) AnnounceFile(id string) error

func (*Network) AnnounceToPeers

func (n *Network) AnnounceToPeers(nodeID, address string)

func (*Network) ConnectToBootstrapNodes

func (n *Network) ConnectToBootstrapNodes()

func (*Network) ConnectToPeer

func (n *Network) ConnectToPeer(addr string) (err error)

func (*Network) FindFile

func (n *Network) FindFile(id string) ([]peer.AddrInfo, error)

func (*Network) FindPeer

func (n *Network) FindPeer(peerID string) (peer.AddrInfo, error)

func (*Network) GetHost

func (n *Network) GetHost() host.Host

func (*Network) RequestFile

func (n *Network) RequestFile(peerID peer.ID, protocolID protocol.ID, cid string) error

func (*Network) RetrieveFile

func (n *Network) RetrieveFile(cid, outputPath string) error

func (*Network) SendMessage

func (n *Network) SendMessage(peerID peer.ID, protocolID protocol.ID, msg string) (err error)

func (*Network) ShareFile

func (n *Network) ShareFile(path string) (cid string, err error)

func (*Network) Shutdown

func (n *Network) Shutdown() error

func (*Network) StartSimpleProtocol

func (n *Network) StartSimpleProtocol(protocolID protocol.ID)

type Node

type Node struct {
	ID       string `json:"id"`
	APIPort  string `json:"api_port"`
	Address  string `json:"address"`
	IsOnline bool   `json:"is_online"`
}

type NodeRegistry

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

func NewNodeRegistry

func NewNodeRegistry() *NodeRegistry

func (*NodeRegistry) GetAllNodes

func (nr *NodeRegistry) GetAllNodes() []Node

func (*NodeRegistry) RegisterNode

func (nr *NodeRegistry) RegisterNode(node Node)

Jump to

Keyboard shortcuts

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