pnet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPortMapping added in v0.3.0

func AddPortMapping(ctx context.Context, ports ...int) error

func DialContext

func DialContext(ctx context.Context, network, laddr, raddr string) (net.Conn, error)

func Listen

func Listen(ctx context.Context, network, address string) (net.Listener, error)

func ListenPacket

func ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)

func RendezvousWithTimeout added in v0.3.0

func RendezvousWithTimeout(ctx context.Context, laddr string, peerAddrs []AddrPair) (conn net.Conn, err error)

RendezvousWithTimeout performs simultaneous connection opening for TCP hole punching, with `rendezvousTimeout`

func SetLogger added in v0.3.0

func SetLogger(l Logger)

SetLogger sets the internal logger for pnet

Types

type AddrPair added in v0.3.0

type AddrPair struct {
	PriAddr string `json:"priAddr"`
	PubAddr string `json:"pubAddr"`
}

type HTTPClient

type HTTPClient struct {
	*http.Client
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(useIpv6 bool, laddr string) *HTTPClient

func (*HTTPClient) GetLAddr

func (cl *HTTPClient) GetLAddr() <-chan net.Addr

type Logger

type Logger interface {
	Infof(format string, a ...any)
	Debugf(format string, a ...any)
}

Logger interface accepted by pnet for internal logging

type PeerInfo added in v0.3.0

type PeerInfo struct {
	Laddr     string
	PeerAddrs []AddrPair `json:"peerAddrs"`
	Strategy  []string   `json:"strategy,omitempty"`
	PeerNPlan int        `json:"peerNPlan,omitempty"`
	TSAddr    string     `json:"tsAddr,omitempty"`
	TSCap     uint       `json:"tsCap,omitempty"`
}

func ExchangeConnInfo added in v0.3.0

func ExchangeConnInfo(ctx context.Context, bridgeURL string, info *SelfInfo, port int, useIPv6 bool) (*PeerInfo, error)

ExchangeConnInfo exchanges oneself's info for the peer's info, which can be used to establish a connection

type SelfInfo added in v0.3.0

type SelfInfo struct {
	PriAddr  string   `json:"priAddr"`
	ChanName string   `json:"chanName"`
	Strategy []string `json:"strategy,omitempty"`
	NPlan    int      `json:"nPlan,omitempty"`
	TSAddr   string   `json:"tsAddr,omitempty"`
	TSCap    uint     `json:"tsCap,omitempty"`
}

Jump to

Keyboard shortcuts

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