dht

package
v0.0.0-...-709791a Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2015 License: AGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const AF_INET byte = 2

http://lxr.free-electrons.com/source/include/linux/socket.h TODO: get these from the source

View Source
const AF_INET6 byte = 10
View Source
const TCP_INET byte = 130
View Source
const TCP_INET6 byte = 138

Variables

View Source
var DhtServerList []DHTPeer

Functions

This section is empty.

Types

type DHTID

type DHTID [gotox.PublicKeySize]byte

type DHTPeer

type DHTPeer struct {
	PublicKey [gotox.PublicKeySize]byte
	Addr      net.UDPAddr
}

func (*DHTPeer) MarshalBinary

func (n *DHTPeer) MarshalBinary() ([]byte, error)

func (*DHTPeer) UnmarshalBinary

func (n *DHTPeer) UnmarshalBinary(data []byte) error

func (*DHTPeer) UnmarshalJSON

func (n *DHTPeer) UnmarshalJSON(data []byte) error

type EncryptedPacket

type EncryptedPacket struct {
	Kind    uint8
	Sender  *[gotox.PublicKeySize]byte
	Nonce   *[gotox.NonceSize]byte
	Payload []byte
}

func (*EncryptedPacket) MarshalBinary

func (p *EncryptedPacket) MarshalBinary() ([]byte, error)

func (*EncryptedPacket) UnmarshalBinary

func (p *EncryptedPacket) UnmarshalBinary(data []byte) error

type GetNodes

type GetNodes struct {
	RequestedNodeID *[gotox.PublicKeySize]byte
	RequestID       uint64
}

func (*GetNodes) Kind

func (sn *GetNodes) Kind() uint8

func (*GetNodes) MarshalBinary

func (sn *GetNodes) MarshalBinary() ([]byte, error)

func (*GetNodes) UnmarshalBinary

func (sn *GetNodes) UnmarshalBinary(data []byte) error

type GetNodesReply

type GetNodesReply struct {
	Nodes        []DHTPeer
	SendbackData uint64
}

func (*GetNodesReply) Kind

func (sn *GetNodesReply) Kind() uint8

func (*GetNodesReply) MarshalBinary

func (sn *GetNodesReply) MarshalBinary() ([]byte, error)

func (*GetNodesReply) UnmarshalBinary

func (sn *GetNodesReply) UnmarshalBinary(data []byte) error

type Identity

type Identity struct {
	SymmetricKey [gotox.SymmetricKeySize]byte // used for encrypting cookies?
	PublicKey    [gotox.PublicKeySize]byte
	PrivateKey   [gotox.PrivateKeySize]byte
}

func GenerateIdentity

func GenerateIdentity() (*Identity, error)

func (*Identity) DecryptPacket

func (id *Identity) DecryptPacket(encrypted *EncryptedPacket) (*PlainPacket, error)

func (*Identity) Encrypt

func (id *Identity) Encrypt(plain []byte, publicKey *[gotox.PublicKeySize]byte) (*[gotox.NonceSize]byte, []byte, error)

TODO: cache the shared key

func (*Identity) EncryptPacket

func (id *Identity) EncryptPacket(plain *PlainPacket, publicKey *[gotox.PublicKeySize]byte) (*EncryptedPacket, error)

type LocalTransport

type LocalTransport struct {
	ChOut    *chan []byte
	ChIn     *chan []byte
	ChStop   chan struct{}
	Identity *Identity
	// contains filtered or unexported fields
}

func NewLocalTransport

func NewLocalTransport(id *Identity) (*LocalTransport, error)

func (*LocalTransport) DataChan

func (t *LocalTransport) DataChan() chan TransportMessage

func (*LocalTransport) Listen

func (t *LocalTransport) Listen()

func (*LocalTransport) Send

func (t *LocalTransport) Send(payload Payload, dest *DHTPeer) error

func (*LocalTransport) Stop

func (t *LocalTransport) Stop()

type Payload

type Payload interface {
	Kind() uint8
	MarshalBinary() (data []byte, err error)
	UnmarshalBinary(data []byte) error
}

type PingPong

type PingPong struct {
	IsPing    bool
	RequestID uint64
}

func (*PingPong) Kind

func (p *PingPong) Kind() uint8

func (*PingPong) MarshalBinary

func (p *PingPong) MarshalBinary() ([]byte, error)

func (*PingPong) UnmarshalBinary

func (p *PingPong) UnmarshalBinary(data []byte) error

type PlainPacket

type PlainPacket struct {
	Sender  *[gotox.PublicKeySize]byte
	Payload Payload
}

type Transport

type Transport interface {
	Send(payload Payload, dest *DHTPeer) error
	Listen()
	Stop()
	DataChan() chan TransportMessage
}

type TransportMessage

type TransportMessage struct {
	Packet PlainPacket
	Addr   net.UDPAddr
}

type UDPTransport

type UDPTransport struct {
	Server   net.UDPConn
	Identity *Identity

	ChStop chan struct{}
	// contains filtered or unexported fields
}

func NewUDPTransport

func NewUDPTransport(id *Identity) (*UDPTransport, error)

func (*UDPTransport) DataChan

func (t *UDPTransport) DataChan() chan TransportMessage

func (*UDPTransport) Listen

func (t *UDPTransport) Listen()

func (*UDPTransport) Send

func (t *UDPTransport) Send(payload Payload, dest *DHTPeer) error

func (*UDPTransport) Stop

func (t *UDPTransport) Stop()

Jump to

Keyboard shortcuts

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