Documentation ¶
Index ¶
- Constants
- type GetNodesPacket
- type Ident
- func (i *Ident) DecryptBlob(data []byte, publicKey *[crypto.PublicKeySize]byte, ...) ([]byte, error)
- func (i *Ident) DecryptPacket(p *Packet) (transport.Packet, error)
- func (i *Ident) EncryptBlob(data []byte, publicKey *[crypto.PublicKeySize]byte) ([]byte, *[crypto.NonceSize]byte, error)
- func (i *Ident) EncryptPacket(packet transport.Packet, publicKey *[crypto.PublicKeySize]byte) (*Packet, error)
- type Node
- type NodeType
- type Packet
- type PingRequestPacket
- type PingResponsePacket
- type SendNodesPacket
Constants ¶
const ( PacketIDPingRequest byte = 0 PacketIDPingResponse byte = 1 PacketIDGetNodes byte = 2 PacketIDSendNodes byte = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetNodesPacket ¶
type GetNodesPacket struct { PublicKey *[crypto.PublicKeySize]byte PingID uint64 }
GetNodesPacket represents the encrypted portion of the GetNodes request.
func (GetNodesPacket) ID ¶
func (p GetNodesPacket) ID() byte
ID returns the packet ID of this packet.
func (*GetNodesPacket) MarshalBinary ¶
func (p *GetNodesPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*GetNodesPacket) UnmarshalBinary ¶
func (p *GetNodesPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryMarshaler interface.
type Ident ¶
type Ident struct { PublicKey *[crypto.PublicKeySize]byte SecretKey *[crypto.SecretKeySize]byte }
Ident represents a DHT identity.
func (*Ident) DecryptBlob ¶
func (i *Ident) DecryptBlob(data []byte, publicKey *[crypto.PublicKeySize]byte, nonce *[crypto.NonceSize]byte) ([]byte, error)
DecryptBlob decrypts the given slice of data.
func (*Ident) DecryptPacket ¶
DecryptPacket decrypts the given packet.
func (*Ident) EncryptBlob ¶
func (i *Ident) EncryptBlob(data []byte, publicKey *[crypto.PublicKeySize]byte) ([]byte, *[crypto.NonceSize]byte, error)
EncryptBlob encrypts the given slice of data.
func (*Ident) EncryptPacket ¶
func (i *Ident) EncryptPacket(packet transport.Packet, publicKey *[crypto.PublicKeySize]byte) (*Packet, error)
EncryptPacket encrypts the given packet.
type Node ¶
Node represents a node in the DHT.
func (*Node) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Node) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type NodeType ¶
type NodeType byte
NodeType represents the type of Node. This can be a regular node (UDP) or a TCP relay.
type Packet ¶
type Packet struct { Type byte SenderPublicKey *[crypto.PublicKeySize]byte Nonce *[crypto.NonceSize]byte Payload []byte /* encrypted */ }
Packet represents the base of all DHT packets.
func (*Packet) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Packet) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryMarshaler interface.
type PingRequestPacket ¶
type PingRequestPacket struct { //ping type: 0x00 PingID uint64 }
PingRequestPacket represents the encrypted portion of the PingRequest packet.
func (PingRequestPacket) ID ¶
func (p PingRequestPacket) ID() byte
ID returns the packet ID of this packet.
func (*PingRequestPacket) MarshalBinary ¶
func (p *PingRequestPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*PingRequestPacket) UnmarshalBinary ¶
func (p *PingRequestPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type PingResponsePacket ¶
type PingResponsePacket struct { //ping type: 0x01 PingID uint64 }
PingResponsePacket represents the encrypted portion of the PingResponse packet.
func (PingResponsePacket) ID ¶
func (p PingResponsePacket) ID() byte
ID returns the packet ID of this packet.
func (*PingResponsePacket) MarshalBinary ¶
func (p *PingResponsePacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*PingResponsePacket) UnmarshalBinary ¶
func (p *PingResponsePacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type SendNodesPacket ¶
SendNodesPacket represents the encrypted portion of the SendNodes packet.
func (SendNodesPacket) ID ¶
func (p SendNodesPacket) ID() byte
ID returns the packet ID of this packet.
func (*SendNodesPacket) MarshalBinary ¶
func (p *SendNodesPacket) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*SendNodesPacket) UnmarshalBinary ¶
func (p *SendNodesPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.