nat

package
v0.0.0-...-78b8bb9 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPublicAddr

func GetPublicAddr(conn *net.UDPConn) (string, int, error)

func GuessLocalPort

func GuessLocalPort(remoteAddr string) (int, error)

func GuessRemotePort

func GuessRemotePort(remoteIP string, opts ...Option) (int, error)

func SimpleTest

func SimpleTest(remoteIP string) error

Types

type CustomNet

type CustomNet struct {
	*stdnet.Net
	// contains filtered or unexported fields
}

func (*CustomNet) Dial

func (cn *CustomNet) Dial(network string, address string) (net.Conn, error)

type Message

type Message struct {
	Test string `json:"test"`
}

type NAT

type NAT int
const (
	NAT_EASY NAT = iota
	NAT_HARD
)

func (NAT) MarshalText

func (n NAT) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (NAT) String

func (n NAT) String() string

func (*NAT) UnmarshalText

func (n *NAT) UnmarshalText(b []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Option

type Option func(*clientCfg)

func Interactive

func Interactive(i bool) Option

func WithConn

func WithConn(conn *net.UDPConn) Option

func WithPubAddr

func WithPubAddr(pubIP string, pubPort int) Option

type PortInfo

type PortInfo struct {
	PeerPort  int
	LocalPort int
}

type ReusedConn

type ReusedConn struct {
	*net.UDPConn
	// contains filtered or unexported fields
}

func (*ReusedConn) Close

func (rc *ReusedConn) Close() error

func (*ReusedConn) Write

func (rc *ReusedConn) Write(b []byte) (int, error)

type STUNInfo

type STUNInfo struct {
	PublicIP   string `json:"public_ip"`
	PublicPort int    `json:"public_port"`
	NATKind    NAT    `json:"nat_kind"`
}

func GetPublicAddrWithNATKind

func GetPublicAddrWithNATKind(conn *net.UDPConn) (*STUNInfo, error)

type STUNSrv

type STUNSrv string
const STUN_Google STUNSrv = "stun:stun.l.google.com:19302"
const STUN_Google1 STUNSrv = "stun:stun1.l.google.com:19302"
const STUN_VoipGATE STUNSrv = "stun:stun.voipgate.com:3478"

Jump to

Keyboard shortcuts

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