Documentation ¶
Index ¶
- func DetectIP() string
- type DHTClient
- func (dht *DHTClient) AddConnection(connections []*net.UDPConn, conn *net.UDPConn) []*net.UDPConn
- func (dht *DHTClient) Compose(command, id, hash string, port string) string
- func (dht *DHTClient) ConnectAndHandshake(router string, ips []net.IP) (*net.UDPConn, error)
- func (dht *DHTClient) DHTClientConfig() *DHTClient
- func (dht *DHTClient) EncodeRequest(req commons.DHTRequest) string
- func (dht *DHTClient) Extract(b []byte) (response commons.DHTResponse, err error)
- func (dht *DHTClient) HandleConn(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandleCp(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandleFind(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandleNode(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandleNotify(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandlePing(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandleRegCp(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) HandleStop(data commons.DHTResponse, conn *net.UDPConn)
- func (dht *DHTClient) Initialize(config *DHTClient, ips []net.IP) *DHTClient
- func (dht *DHTClient) ListenDHT(conn *net.UDPConn) string
- func (dht *DHTClient) RegisterControlPeer()
- func (dht *DHTClient) ReportControlPeerLoad(amount int)
- func (dht *DHTClient) RequestControlPeer(id string)
- func (dht *DHTClient) RequestPeerIPs(id string)
- func (dht *DHTClient) Stop()
- func (dht *DHTClient) UpdateLastCatch(catch string)
- func (dht *DHTClient) UpdatePeers()
- type DHTResponseCallback
- type Forwarder
- type OperatingMode
- type PeerIP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DHTClient ¶
type DHTClient struct { Routers string FailedRouters []string Connection []*net.UDPConn NetworkHash string NetworkPeers []string P2PPort int LastCatch []string ID string Peers []PeerIP Forwarders []Forwarder ResponseHandlers map[string]DHTResponseCallback Mode OperatingMode Shutdown bool }
func (*DHTClient) AddConnection ¶
AddConnection adds new UDP Connection reference onto list of DHT node connections
func (*DHTClient) ConnectAndHandshake ¶
ConnectAndHandshake sends an initial packet to a DHT bootstrap node
func (*DHTClient) DHTClientConfig ¶
func (*DHTClient) EncodeRequest ¶
func (dht *DHTClient) EncodeRequest(req commons.DHTRequest) string
func (*DHTClient) Extract ¶
func (dht *DHTClient) Extract(b []byte) (response commons.DHTResponse, err error)
Extracts DHTRequest from received packet
func (*DHTClient) HandleConn ¶
func (dht *DHTClient) HandleConn(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandleCp ¶
func (dht *DHTClient) HandleCp(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandleFind ¶
func (dht *DHTClient) HandleFind(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandleNode ¶
func (dht *DHTClient) HandleNode(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandleNotify ¶
func (dht *DHTClient) HandleNotify(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandlePing ¶
func (dht *DHTClient) HandlePing(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandleRegCp ¶
func (dht *DHTClient) HandleRegCp(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) HandleStop ¶
func (dht *DHTClient) HandleStop(data commons.DHTResponse, conn *net.UDPConn)
func (*DHTClient) Initialize ¶
This method initializes DHT by splitting list of routers and connect to each one
func (*DHTClient) ListenDHT ¶
Listens for packets received from DHT bootstrap node Every packet is unmarshaled and turned into Request structure which we should analyze and respond
func (*DHTClient) RegisterControlPeer ¶
func (dht *DHTClient) RegisterControlPeer()
This method register control peer on a Bootstrap node
func (*DHTClient) ReportControlPeerLoad ¶
func (*DHTClient) RequestControlPeer ¶
This method request a new control peer for particular host
func (*DHTClient) RequestPeerIPs ¶
This function sends a request to DHT bootstrap node with ID of target node we want to connect to
func (*DHTClient) UpdateLastCatch ¶
After receiving a list of peers from DHT we will parse the list and add every new peer into list of peers
func (*DHTClient) UpdatePeers ¶
func (dht *DHTClient) UpdatePeers()
UpdatePeers sends "find" request to a DHT Bootstrap node, so it can respond with a list of peers that we can connect to This method should be called periodically in case any new peers was discovered
type DHTResponseCallback ¶
type DHTResponseCallback func(data commons.DHTResponse, conn *net.UDPConn)
type OperatingMode ¶
type OperatingMode int
const ( MODE_CLIENT OperatingMode = 1 MODE_CP OperatingMode = 2 )