services

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: 9 Imported by: 0

Documentation

Overview

Package services provides a message type for advertising what kinds of exit services a peer provides to clients, including the port number and the cost per megabyte of data.

Index

Constants

View Source
const (
	Magic = "svad"
	Len   = ad.Len +
		slice.Uint16Len +
		slice.Uint32Len
)

Variables

This section is empty.

Functions

func Gen

func Gen() codec.Codec

Gen is the factory function for an Ad.

func ServiceSplice

func ServiceSplice(s *splice.Splice, id nonce.ID, key *crypto.Pub, services []Service, expiry time.Time)

ServiceSplice creates the message part up to the signature for an Ad.

Types

type Ad struct {

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

	// Services available on the relay identified by the public key.
	Services []Service
}

Ad stores a specification for the fee rate and the service port, which must be a well known port to match with a type of service, eg 80 for web, 53 for DNS, etc. These are also attached to the PeerAd entry via concatenating "/service/N" where N is the index of the entry. A zero value at an index signals to stop scanning for more subsequent values.

func New

func New(id nonce.ID, key *crypto.Prv, services []Service,
	expiry time.Time) (svcAd *Ad)

New creates a new Ad and signs it.

func (*Ad) Decode

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

Decode an Ad out of the next bytes of a splice.Splice.

func (*Ad) Encode

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

Encode an Ad into the next bytes of a splice.Splice.

func (*Ad) Len

func (x *Ad) Len() int

Len returns the length of the binary encoded Ad.

This gives different values depending on how many services are listed.

func (*Ad) Magic

func (x *Ad) Magic() string

Magic is the identifier indicating an Ad is encoded in the following bytes.

func (*Ad) Sign

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

Sign the Ad with the provided private key. It must match the embedded ad.Ad Key.

func (*Ad) Splice

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

Splice serializes an Ad into a splice.Splice.

func (*Ad) SpliceNoSig

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

SpliceNoSig serializes the Ad but stops at the signature.

func (*Ad) Unwrap

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

Unwrap returns nil because there is no onion inside.

func (*Ad) Validate

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

Validate checks the signature matches the public key of the Ad.

type Service

type Service struct {
	Port      uint16
	RelayRate uint32
}

Jump to

Keyboard shortcuts

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