network

package
v0.0.0-...-2e0d377 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const DiscoveryTopic = "plural-star:discovery:networks"
View Source
const GlobalScope = "global"
View Source
const NetworkDBDefault = "./networks.db"

Variables

View Source
var DefaultBootstrapPeers = []string{
	"/dns4/pluralstar.dedyn.io/tcp/4001/p2p/12D3KooWL4A25M2sWt1HoFY3r8hWn2idbc4yVdsdBqpFitRTNyfz",
}

Functions

func AdvertiseAndDiscover

func AdvertiseAndDiscover(ctx context.Context, h host.Host, rd *drouting.RoutingDiscovery, rendezvous string, interval, dialTimeout time.Duration)

func ApplyInvite

func ApplyInvite(cfg config.Config, inv Invite, pskPath string) (config.Config, error)

func BootstrapPeers

func BootstrapPeers(cfg *config.Config) []string

func DHTPrefix

func DHTPrefix(cfg *config.Config) string

func EncodeInvite

func EncodeInvite(inv Invite) (string, error)

func FetchDirectory

func FetchDirectory(ctx context.Context, url string, store *Store, timeout time.Duration) (int, error)

func GossipPrefix

func GossipPrefix(cfg *config.Config) string

func LoadPSK

func LoadPSK(path string) ([]byte, error)

func NewGossipSub

func NewGossipSub(ctx context.Context, h host.Host, kdht *dht.IpfsDHT) (*pubsub.PubSub, *drouting.RoutingDiscovery, error)

func Scope

func Scope(cfg *config.Config) string

func SetupMDNS

func SetupMDNS(ctx context.Context, h host.Host, dialTimeout time.Duration) (mdns.Service, error)

func SignNetworkCard

func SignNetworkCard(c *NetworkCard, priv crypto.PrivKey) error

func VerifyNetworkCard

func VerifyNetworkCard(c *NetworkCard) error

Types

type Invite

type Invite struct {
	Multiaddrs []ma.Multiaddr
	PSK        []byte
	Label      string
}

func DecodeInvite

func DecodeInvite(s string) (Invite, error)

type NetworkCard

type NetworkCard struct {
	ID             string   `json:"id"`
	Name           string   `json:"name"`
	Description    string   `json:"description"`
	BootstrapPeers []string `json:"bootstrap_peers"`
	NodeCountHint  int      `json:"node_count_hint"`
	CreatedBy      string   `json:"created_by"`
	CreatedAt      int64    `json:"created_at"`
	Signature      string   `json:"signature"`
}

type NetworkDiscovery

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

func NewNetworkDiscovery

func NewNetworkDiscovery(ctx context.Context, ps *pubsub.PubSub, self peer.ID, store *Store) (*NetworkDiscovery, error)

type Store

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

func OpenStore

func OpenStore(path string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) Get

func (s *Store) Get(id string) (NetworkCard, bool, error)

func (*Store) List

func (s *Store) List() ([]NetworkCard, error)

func (*Store) Put

func (s *Store) Put(card NetworkCard) error

Jump to

Keyboard shortcuts

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