addresses

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 10 Imported by: 0

Documentation

Overview

Package addresses defines the message format that provides the network multi-address of a peer with a given public identity key.

Index

Constants

View Source
const (
	Magic = "adad"
	Len   = ad.Len + splice.AddrLen
)

Variables

This section is empty.

Functions

func Gen

func Gen() codec.Codec

Gen is a factory function to generate an Ad.

func Splice

func Splice(s *splice.Splice, id nonce.ID, key *crypto.Pub,
	addrs []*netip.AddrPort, expiry time.Time)

Splice is a function that serializes the parts of an Ad.

Types

type Ad struct {

	// Embed ad.Ad for the common fields
	ad.Ad

	// Addresses that the peer can be reached on.
	Addresses []*netip.AddrPort
}

Ad stores a specification for the fee rate and the service ports of a set of services being offered at a relay

These must be a well known port to match with a type of service, eg 80 for web, 53 for DNS, 8333 for bitcoin p2p, 8334 for bitcoin JSONRPC... For simplicity.

func New

func New(id nonce.ID, key *crypto.Prv, addrs []*netip.AddrPort,
	expiry time.Time) (addrAd *Ad)

New creates a new addresses.Ad.

func (*Ad) Decode

func (x *Ad) Decode(s *splice.Splice) (e error)

Decode a splice.Splice's next bytes into an Ad.

func (*Ad) Encode

func (x *Ad) Encode(s *splice.Splice) (e error)

Encode an Ad into a splice.Splice's next bytes.

func (*Ad) Len

func (x *Ad) Len() int

Len returns the length of bytes required to encode the Ad, based on the number of Addresses inside it.

func (*Ad) Magic

func (x *Ad) Magic() string

Magic bytes that identify this message

func (*Ad) Sign

func (x *Ad) Sign(prv *crypto.Prv) (e error)

Sign the encoded form of the bytes in order to authorise it.

func (*Ad) Splice

func (x *Ad) Splice(s *splice.Splice)

Splice together an Ad.

func (*Ad) SpliceNoSig

func (x *Ad) SpliceNoSig(s *splice.Splice)

SpliceNoSig splices until the signature.

func (*Ad) Unwrap

func (x *Ad) Unwrap() interface{}

Unwrap returns nothing because there isn't an onion inside an Ad.

func (*Ad) Validate

func (x *Ad) Validate() (valid bool)

Validate checks that the signature matches the public key.

Jump to

Keyboard shortcuts

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