Documentation ¶
Index ¶
- Variables
- func RecoverKeyFromSignedData(m SignedData) (ed25519.PublicKey, error)
- type DB
- func (db *DB) Close()
- func (db *DB) LastPing(id identity.ID, ip net.IP) time.Time
- func (db *DB) LastPong(id identity.ID, ip net.IP) time.Time
- func (db *DB) LocalPrivateKey() (privateKey ed25519.PrivateKey, err error)
- func (db *DB) Peer(id identity.ID) (*Peer, error)
- func (db *DB) SeedPeers() []*Peer
- func (db *DB) UpdateLastPing(id identity.ID, ip net.IP, t time.Time) error
- func (db *DB) UpdateLastPong(id identity.ID, ip net.IP, t time.Time) error
- func (db *DB) UpdateLocalPrivateKey(key ed25519.PrivateKey) error
- func (db *DB) UpdatePeer(p *Peer) error
- type Local
- func (l *Local) Database() *DB
- func (l *Local) GetPrivateSalt() *salt.Salt
- func (l *Local) GetPublicSalt() *salt.Salt
- func (l *Local) LocalIdentity() *identity.LocalIdentity
- func (l *Local) SetPrivateSalt(salt *salt.Salt)
- func (l *Local) SetPublicSalt(salt *salt.Salt)
- func (l *Local) Sign(message []byte) ed25519.Signature
- func (l *Local) UpdateService(key service.Key, network string, port int) error
- type Peer
- func (p *Peer) Address() *net.UDPAddr
- func (p *Peer) IP() net.IP
- func (p *Peer) Marshal() ([]byte, error)
- func (p *Peer) MarshalJSON() ([]byte, error)
- func (p *Peer) Network() string
- func (p *Peer) Services() service.Service
- func (p *Peer) String() string
- func (p *Peer) ToProto() *pb.Peer
- func (p *Peer) UnmarshalJSON(b []byte) error
- type PeerDistance
- type PublicKey
- type SignedData
Constants ¶
This section is empty.
Variables ¶
var (
ErrNeedsPeeringService = errors.New("needs peering service")
)
Errors in the peer package.
Functions ¶
func RecoverKeyFromSignedData ¶
func RecoverKeyFromSignedData(m SignedData) (ed25519.PublicKey, error)
RecoverKeyFromSignedData validates and returns the key that was used to sign the data.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the peer database, storing previously seen peers and any collected properties of them.
func (*DB) LocalPrivateKey ¶
func (db *DB) LocalPrivateKey() (privateKey ed25519.PrivateKey, err error)
LocalPrivateKey returns the private key stored in the database or creates a new one.
func (*DB) UpdateLastPing ¶
UpdateLastPing updates that property for the given peer ID and address.
func (*DB) UpdateLastPong ¶
UpdateLastPong updates that property for the given peer ID and address.
func (*DB) UpdateLocalPrivateKey ¶
func (db *DB) UpdateLocalPrivateKey(key ed25519.PrivateKey) error
UpdateLocalPrivateKey stores the provided key in the database.
func (*DB) UpdatePeer ¶
UpdatePeer updates a peer in the database.
type Local ¶
type Local struct { *Peer // contains filtered or unexported fields }
Local defines the struct of a local peer
func NewLocal ¶
NewLocal creates a new local peer linked to the provided store. If an optional seed is provided, the seed is used to generate the private key. Without a seed, the provided key is loaded from the provided database and generated if not stored there.
func (*Local) GetPrivateSalt ¶
GetPrivateSalt returns the private salt
func (*Local) GetPublicSalt ¶
GetPublicSalt returns the public salt
func (*Local) LocalIdentity ¶
func (l *Local) LocalIdentity() *identity.LocalIdentity
LocalIdentity returns the local identity
func (*Local) SetPrivateSalt ¶
SetPrivateSalt sets the private salt
func (*Local) SetPublicSalt ¶
SetPublicSalt sets the public salt
type Peer ¶
Peer defines the immutable data of a peer.
func FromProto ¶
FromProto decodes a given proto buffer Peer message (in) and returns the corresponding Peer.
func (*Peer) MarshalJSON ¶
MarshalJSON serializes Peer into json data.
func (*Peer) UnmarshalJSON ¶
UnmarshalJSON deserializes given json data into a Peer struct.
type PeerDistance ¶
PeerDistance defines the relative distance wrt a remote peer
func NewPeerDistance ¶
func NewPeerDistance(anchorID, salt []byte, remote *Peer) PeerDistance
NewPeerDistance returns a new PeerDistance
func SortBySalt ¶
func SortBySalt(anchor, salt []byte, remotePeers []*Peer) (result []PeerDistance)
SortBySalt returns a slice of PeerDistance given a list of remote peers
type SignedData ¶
SignedData is an interface wrapper around data with key and signature.