Documentation ¶
Index ¶
- Variables
- func Ping(ctx context.Context, h host.Host, p peer.ID) (<-chan ping.Result, network.Stream)
- func RootAction(c *cli.Context) error
- type HolePunchAttempt
- type HolePunchState
- type Host
- func (h *Host) Bootstrap(ctx context.Context) error
- func (h *Host) Close() error
- func (h *Host) FilterLocal(remoteID peer.ID, maddrs []multiaddr.Multiaddr) []multiaddr.Multiaddr
- func (h *Host) FilterRemote(remoteID peer.ID, maddrs []multiaddr.Multiaddr) []multiaddr.Multiaddr
- func (h *Host) GetAgentVersion(pid peer.ID) *string
- func (h *Host) GetProtocols(pid peer.ID) []string
- func (h *Host) HolePunch(ctx context.Context, addrInfo peer.AddrInfo) (*HolePunchState, <-chan LatencyMeasurement)
- func (h *Host) MeasurePing(ctx context.Context, pid peer.ID, mType pb.LatencyMeasurementType) <-chan LatencyMeasurement
- func (h *Host) PingRelays(ctx context.Context, addrInfo map[peer.ID]*peer.AddrInfo) []LatencyMeasurement
- func (h *Host) ProtocolFilters() []int32
- func (h *Host) RegisterPeerToTrace(pid peer.ID) <-chan *holepunch.Event
- func (h *Host) Trace(evt *holepunch.Event)
- func (h *Host) UnregisterPeerToTrace(pid peer.ID)
- func (h *Host) WaitForDCUtRStream(pid peer.ID) <-chan struct{}
- func (h *Host) WaitForPublicAddr(ctx context.Context) error
- type LatencyMeasurement
- type Punchr
- func (p Punchr) Bootstrap(ctx context.Context) error
- func (p Punchr) Close() error
- func (p Punchr) InitHosts(c *cli.Context) error
- func (p Punchr) Register(c *cli.Context) error
- func (p Punchr) RequestAddrInfo(ctx context.Context, clientID peer.ID) (*peer.AddrInfo, []int32, error)
- func (p Punchr) StartHolePunching(ctx context.Context) error
- func (p Punchr) TrackHolePunchResult(ctx context.Context, hps *HolePunchState) error
- type ResourceManager
- type StreamManagementScope
Constants ¶
This section is empty.
Variables ¶
var ( CommunicationTimeout = 30 * time.Second RetryCount = 3 PingDuration = 10 * time.Second MaxPingCount = 10 )
var App = &cli.App{ Name: "punchrclient", Usage: "A libp2p host that is capable of DCUtR.", UsageText: "punchrclient [global options] command [command options] [arguments...]", Action: RootAction, Version: Version, Flags: []cli.Flag{ &cli.StringFlag{ Name: "telemetry-host", Usage: "To which network address should the telemetry (prometheus, pprof) server bind", EnvVars: []string{"PUNCHR_CLIENT_TELEMETRY_HOST"}, Value: "localhost", DefaultText: "localhost", }, &cli.StringFlag{ Name: "telemetry-port", Usage: "On which port should the telemetry (prometheus, pprof) server listen", EnvVars: []string{"PUNCHR_CLIENT_TELEMETRY_PORT"}, Value: "12001", DefaultText: "12001", }, &cli.StringFlag{ Name: "server-host", Usage: "Where does the the punchr server listen", EnvVars: []string{"PUNCHR_CLIENT_SERVER_HOST"}, Value: "punchr.dtrautwein.eu", DefaultText: "punchr.dtrautwein.eu", }, &cli.StringFlag{ Name: "server-port", Usage: "On which port listens the punchr server", EnvVars: []string{"PUNCHR_CLIENT_SERVER_PORT"}, Value: "443", DefaultText: "443", }, &cli.BoolFlag{ Name: "server-ssl", Usage: "Whether or not to use a SSL connection to the server.", EnvVars: []string{"PUNCHR_CLIENT_SERVER_SSL"}, Value: true, DefaultText: "true", }, &cli.BoolFlag{ Name: "server-ssl-skip-verify", Usage: "Whether or not to skip SSL certificate verification.", EnvVars: []string{"PUNCHR_CLIENT_SERVER_SSL_SKIP_VERIFY"}, Value: false, DefaultText: "false", }, &cli.IntFlag{ Name: "host-count", Usage: "How many libp2p hosts should be used to hole punch", EnvVars: []string{"PUNCHR_CLIENT_HOST_COUNT"}, DefaultText: "10", Value: 10, }, &cli.StringFlag{ Name: "api-key", Usage: "The key to authenticate against the API. If not set, it's read from $XDG_CONFIG_HOME/punchr/api-key.txt", EnvVars: []string{"PUNCHR_CLIENT_API_KEY"}, }, &cli.StringFlag{ Name: "key-file", Usage: "File where punchr saves the host identities.", TakesFile: true, EnvVars: []string{"PUNCHR_CLIENT_KEY_FILE"}, DefaultText: "$XDG_CONFIG_HOME/punchr/client.keys", Value: "$XDG_CONFIG_HOME/punchr/client.keys", }, &cli.StringSliceFlag{ Name: "bootstrap-peers", Usage: "Comma separated list of multi addresses of bootstrap peers", EnvVars: []string{"PUNCHR_BOOTSTRAP_PEERS"}, }, &cli.BoolFlag{ Name: "disable-router-check", Usage: "Set this flag if you don't want punchr to check your router home page", Value: false, }, }, EnableBashCompletion: true, }
var Version = "dev"
Functions ¶
func Ping ¶ added in v0.6.0
Ping pings the remote peer until the context is canceled, returning a stream of RTTs or errors.
func RootAction ¶
func RootAction(c *cli.Context) error
Types ¶
type HolePunchAttempt ¶
type HolePunchAttempt struct { HostID peer.ID RemoteID peer.ID RemoteAddrs []multiaddr.Multiaddr // Time when the /libp2p/dcutr stream was opened OpenedAt time.Time // Time when we received a hole punch started event StartedAt time.Time // Time when this hole punch attempt stopped (failure, cancel, timeout) EndedAt time.Time // The measured round trip time from the holepunch start event StartRTT time.Duration ElapsedTime time.Duration Error string DirectDialError string Outcome pb.HolePunchAttemptOutcome }
func (*HolePunchAttempt) ToProto ¶
func (hpa *HolePunchAttempt) ToProto() *pb.HolePunchAttempt
type HolePunchState ¶
type HolePunchState struct { // The host that established the connection to the remote peer via a relay, and it's listening multi addresses HostID peer.ID LocalMaddrs []multiaddr.Multiaddr // The remote peer and its multi addresses - usually relayed ones. We use that set for the first connection. RemoteID peer.ID RemoteMaddrs []multiaddr.Multiaddr // Start and end times for the establishment of the relayed connection ConnectStartedAt time.Time ConnectEndedAt time.Time // Multi addresses of the open connections before the hole punch aka the multi addresses we // managed to get a connection to the remote peer. OpenMaddrsBefore []multiaddr.Multiaddr // Information about each individual hole punch attempt HolePunchAttempts []*HolePunchAttempt // Multi addresses of the open connections after the hole punch OpenMaddrsAfter []multiaddr.Multiaddr HasDirectConns bool Error string Outcome pb.HolePunchOutcome EndedAt time.Time NetworkInformation *pb.NetworkInformation ProtocolFilters []int32 // Remote Peer data RemoteRttAfterHolePunch time.Duration // LatencyMeasurements of different types LatencyMeasurements []LatencyMeasurement // NAT Mappings NATMappings []nat.Mapping }
func NewHolePunchState ¶
func (HolePunchState) ToProto ¶
func (hps HolePunchState) ToProto(apiKey string) (*pb.TrackHolePunchRequest, error)
func (HolePunchState) TrackHolePunch ¶
func (hps HolePunchState) TrackHolePunch(ctx context.Context, remoteID peer.ID, evtChan <-chan *holepunch.Event) HolePunchAttempt
type Host ¶
Host holds information of the honeypot libp2p host.
func (*Host) FilterLocal ¶ added in v0.6.0
func (*Host) FilterRemote ¶ added in v0.6.0
func (*Host) GetAgentVersion ¶
GetAgentVersion pulls the agent version from the peer store. Returns nil if no information is available.
func (*Host) GetProtocols ¶
GetProtocols pulls the supported protocols of a peer from the peer store. Returns nil if no information is available.
func (*Host) HolePunch ¶
func (h *Host) HolePunch(ctx context.Context, addrInfo peer.AddrInfo) (*HolePunchState, <-chan LatencyMeasurement)
func (*Host) MeasurePing ¶ added in v0.6.0
func (h *Host) MeasurePing(ctx context.Context, pid peer.ID, mType pb.LatencyMeasurementType) <-chan LatencyMeasurement
func (*Host) PingRelays ¶ added in v0.6.0
func (*Host) ProtocolFilters ¶ added in v0.6.0
ProtocolFilters copies the slice
func (*Host) RegisterPeerToTrace ¶
func (*Host) UnregisterPeerToTrace ¶
func (*Host) WaitForDCUtRStream ¶
func (*Host) WaitForPublicAddr ¶
WaitForPublicAddr blocks execution until the host has identified its public address. As we currently don't have an event like this, just check our observed addresses regularly (exponential backoff starting at 250 ms, capped at 5s). TODO: There should be an event here that fires when identify discovers a new address
type LatencyMeasurement ¶ added in v0.6.0
type LatencyMeasurement struct {
// contains filtered or unexported fields
}
type Punchr ¶
type Punchr struct {
// contains filtered or unexported fields
}
Punchr is responsible for fetching information from the server, distributing the work load to different hosts and then reporting the results back.
func (Punchr) Bootstrap ¶
Bootstrap loops through all hosts, connects each of them to the canonical bootstrap nodes, and waits until they have identified their public address(es).
func (Punchr) RequestAddrInfo ¶
func (p Punchr) RequestAddrInfo(ctx context.Context, clientID peer.ID) (*peer.AddrInfo, []int32, error)
RequestAddrInfo calls the hole punching server for a new peer + multi address to hole punch.
func (Punchr) StartHolePunching ¶
StartHolePunching requests a peer from the server, chooses a host to perform a hole punch, and then reports back the result.
func (Punchr) TrackHolePunchResult ¶
func (p Punchr) TrackHolePunchResult(ctx context.Context, hps *HolePunchState) error
type ResourceManager ¶
type ResourceManager struct { network.ResourceManager // contains filtered or unexported fields }
func NewResourceManager ¶
func NewResourceManager() (*ResourceManager, error)
func (*ResourceManager) OpenStream ¶
func (r *ResourceManager) OpenStream(p peer.ID, dir network.Direction) (network.StreamManagementScope, error)
func (*ResourceManager) Register ¶
func (r *ResourceManager) Register(pid peer.ID) <-chan struct{}
func (*ResourceManager) Unregister ¶
func (r *ResourceManager) Unregister(pid peer.ID)
type StreamManagementScope ¶
type StreamManagementScope struct { network.StreamManagementScope // contains filtered or unexported fields }
func (*StreamManagementScope) SetProtocol ¶
func (s *StreamManagementScope) SetProtocol(proto protocol.ID) error