dht

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ErrCodeGeneric = 201
View Source
const ErrCodeMethod = 204
View Source
const ErrCodeProtocol = 203
View Source
const ErrCodeServer = 202

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	GetClosestNode(id []byte) Node
}

type Error

type Error struct {
	Code    int64
	Message string
}

func (*Error) MarshalBencode

func (e *Error) MarshalBencode() ([]byte, error)

func (*Error) UnmarshalBencode

func (e *Error) UnmarshalBencode(d []byte) error

type FindNode

type FindNode struct {
}

type Message

type Message struct {
	Query string                 `bencode:"q",omitempty`
	TID   string                 `bencode:"t"`
	Reply string                 `bencode:"y"`
	Err   *Error                 `bencode:"e",omitempty`
	Args  map[string]interface{} `bencode:"a",omitempty`
}

func NewError

func NewError(txid string, code int, errMsg string) *Message

NewError generates a new error reply message

func NewFindNodeRequest

func NewFindNodeRequest(txid, id, target string) *Message

func (*Message) IsError

func (m *Message) IsError() bool

type Node

type Node interface {
	SendLowLevel([]byte) error
	ID() string
}

type Payload

type Payload interface {
	Serialize
	Process(ctx Context, ch chan *Message) // reply to this message by sending the reply down ch
}

type Serialize

type Serialize interface {
	bencode.Marshaler
	bencode.Unmarshaler
}

type XDHT

type XDHT struct {
}

func (*XDHT) HandleError

func (dht *XDHT) HandleError(err *Error)

func (*XDHT) HandleMessage

func (dht *XDHT) HandleMessage(msg extensions.Message, src common.PeerID) (err error)

Jump to

Keyboard shortcuts

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