node

package
v0.0.0-...-14476bf Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_DEBUG = 4
	LOG_INFO  = 3
	LOG_WARN  = 2
	LOG_ERROR = 1
)

Variables

This section is empty.

Functions

func Addr

func Addr() net.Addr

func CiphertextLength

func CiphertextLength(msgLen int) int

func Decrypt

func Decrypt(ciphertext []byte, sharedKey *[sessionKeyLen]byte) (msg []byte, err error)

func Encrypt

func Encrypt(msg []byte, sharedKey *[sessionKeyLen]byte) (ciphertext []byte, err error)

func Log

func Log(level byte, format string, args ...interface{})

func MsgLength

func MsgLength(cipherLen int) int

func RsaKeyFromPEM

func RsaKeyFromPEM(filename string) (key *rsa.PrivateKey, err error)

Types

type ChanSet

type ChanSet struct {
	// contains filtered or unexported fields
}

holy mother of god... no set type and no generics

func (*ChanSet) Add

func (set *ChanSet) Add(ch PeerChan) bool

func (*ChanSet) Remove

func (set *ChanSet) Remove(ch PeerChan)

type Config

type Config struct {
	// contains filtered or unexported fields
}

type Conn

type Conn struct {
	net.Conn // underlying network connection
	// contains filtered or unexported fields
}

CONNECTION

func HandleClientConn

func HandleClientConn(rawConn net.Conn,
	ownKey *rsa.PrivateKey,
	peerPubKey *rsa.PublicKey) (conn *Conn, err error)

func HandleServerConn

func HandleServerConn(rawConn net.Conn,
	ownKey *rsa.PrivateKey,
	contacts *ContactList) (conn *Conn, err error)

func (Conn) Close

func (c Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (readBytes int, err error)

func (*Conn) Write

func (c *Conn) Write(msg []byte) (n int, err error)

type ConnRequest

type ConnRequest struct {
	// contains filtered or unexported fields
}

connection request

func (*ConnRequest) MarshalBinary

func (r *ConnRequest) MarshalBinary() (data []byte, err error)

func (*ConnRequest) UnmarshalBinary

func (r *ConnRequest) UnmarshalBinary(data []byte) (err error)

type ConnResponse

type ConnResponse struct {
	// contains filtered or unexported fields
}

type Contact

type Contact struct {
	PublicKey *rsa.PublicKey
}

type ContactList

type ContactList struct {
	Contacts *map[[sha256.Size]byte]*Contact
	Mut      *sync.Mutex
}

func NewContactList

func NewContactList() *ContactList

func (*ContactList) AddContact

func (contacts *ContactList) AddContact(contact *Contact) (err error)

func (*ContactList) GetContact

func (contacts *ContactList) GetContact(key [sha256.Size]byte) *Contact

returns nil of not found

type ContactNotFoundError

type ContactNotFoundError struct {
	// contains filtered or unexported fields
}

func (ContactNotFoundError) Error

func (e ContactNotFoundError) Error() string

type DHT

type DHT struct {
	*dht.DHT
	// contains filtered or unexported fields
}
DHT

an enhanced version of the DHT that allows per infohash subscriptions with notifications sent down channels

func (*DHT) Run

func (d *DHT) Run()

type DecryptError

type DecryptError struct {
}

func (DecryptError) Error

func (e DecryptError) Error() string

type FileConfig

type FileConfig struct {
	// contains filtered or unexported fields
}

CONFIG

type HolePunchConf

type HolePunchConf struct {
	// contains filtered or unexported fields
}

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

LISTENER

func (*Listener) Accept

func (l *Listener) Accept() (c net.Conn, err error)

func (*Listener) Close

func (l *Listener) Close() error

type Node

type Node struct {
	// contains filtered or unexported fields
}

NODE

func NewNode

func NewNode(conf *Config) (node *Node, err error)

func (*Node) Dial

func (n *Node) Dial(peerPubKey *rsa.PublicKey) (conn Conn, err error)

CLIENT

func (*Node) Listen

func (n *Node) Listen(port int) (listener *Listener, err error)

type PeerChan

type PeerChan (chan<- string)

Jump to

Keyboard shortcuts

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