p2p

package
v0.0.0-...-2e8d15a Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DHTClient

type DHTClient struct {
	Routers           string                                 // Comma-separated list of bootstrap nodes
	NetworkHash       string                                 // Saved network hash
	ID                string                                 // Current instance ID
	FailedRouters     []string                               // List of routes that we failed to connect to
	LocalPort         int                                    // UDP port number used by this instance
	RemotePort        int                                    // UDP port number reported by echo server
	Forwarders        []Forwarder                            // List of worwarders
	TCPCallbacks      map[protocol.DHTPacketType]dhtCallback // Callbacks for incoming packets
	Mode              OperatingMode                          // DHT Client mode ???
	IPList            []net.IP                               // List of network active interfaces
	IP                net.IP                                 // IP of local interface received from DHCP or specified manually
	Network           *net.IPNet                             // Network information about current network. Used to inform p2p about mask for interface
	Connected         bool                                   // Whether connection with bootstrap nodes established or not
	LastUpdate        time.Time                              // When last `find` packet was sent
	OutboundIP        net.IP                                 // Outbound IP
	ListenerIsRunning bool                                   // True if listener is runnning

}

DHT 客户端结构

func (*DHTClient) Close

func (dht *DHTClient) Close() error

Close will close all connections and switch DHT object to shutdown mode, which will terminate every loop/goroutine

func (*DHTClient) Connect

func (dht *DHTClient) Connect(ipList []net.IP, proxyList []*proxyServer) error

Connect sends `conn` packet to a DHT/

func (*DHTClient) Init

func (dht *DHTClient) Init(hash string) error

func (*DHTClient) RegisterProxy

func (dht *DHTClient) RegisterProxy(ip net.IP, port int) error

RegisterProxy will register current node as a proxy on bootstrap node

func (*DHTClient) ReportLoad

func (dht *DHTClient) ReportLoad(clientsNum int) error

ReportLoad will send amount of tunnels created on particular proxy

func (*DHTClient) WaitID

func (dht *DHTClient) WaitID() error

WaitID will block DHT until valid instance ID is received from Bootstrap node or specified timeout passes.

type Forwarder

type Forwarder struct {
	Addr          *net.UDPAddr
	DestinationID string
}

type OperatingMode

type OperatingMode int

Mode DHT client is operating

const (
	DHTModeClient OperatingMode = 1
	DHTModeProxy  OperatingMode = 2
)

可能的操作模式

type P2PServerV2

type P2PServerV2 struct {
}

type PeerIP

type PeerIP struct {
	ID  string
	Ips []*net.UDPAddr
}

type Peerstate

type Peerstate struct {
}

节点状态

type RemotePeerState

type RemotePeerState struct {
	ID    string
	State Peerstate
}

远程某个节点状态

Jump to

Keyboard shortcuts

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