hole

package
v0.0.0-...-3df9379 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNet

func CheckNet() error

CheckNet search for a gateway

func DelPortMapping

func DelPortMapping(localPort, remotePort int)

DelPortMapping delete port mapping in the gateway

func ExternalIPAddr

func ExternalIPAddr() (net.IP, error)

ExternalIPAddr return the WAN ip

Types

type Creater

Creater function

type ExternalConnection

type ExternalConnection struct {
	PeerID      string
	MyProfile   profile.Profile
	PeerProfile profile.PeerProfile

	WgConn        *net.UDPConn
	LocalPeerConn *net.UDPConn
	Device        *device.Device
	Logger        *device.Logger

	MyAddr   *net.UDPAddr
	PeerAddr *net.UDPAddr

	Started       bool
	Connected     bool
	LastKeepalive time.Time

	TriedPrivate bool
	Ctx          context.Context
	// contains filtered or unexported fields
}

ExternalConnection struct

func (*ExternalConnection) BuildNetworkEndpointEvent

func (ext *ExternalConnection) BuildNetworkEndpointEvent(method Method) api.Event

func (*ExternalConnection) BuildP2PKey

func (ext *ExternalConnection) BuildP2PKey() string

func (*ExternalConnection) GetPeerAddr

func (ext *ExternalConnection) GetPeerAddr() <-chan string

func (*ExternalConnection) Listen

func (ext *ExternalConnection) Listen(conn *net.UDPConn, messages chan *pkt)

func (*ExternalConnection) ShouldTryPrivate

func (ext *ExternalConnection) ShouldTryPrivate() bool

type Method

type Method interface {
	Start() error
	GetPrivateAddr() string
}

Method interface

func Create

func Create(ctx context.Context, method string, d *device.Device, logger *device.Logger, myProfile profile.Profile, peerProfile profile.PeerProfile) (Method, error)

Create function

func NewSTUN

func NewSTUN(ctx context.Context, d *device.Device, logger *device.Logger, myProfile profile.Profile, peerProfile profile.PeerProfile) (Method, error)

NewSTUN init

func NewUPnPIGD

func NewUPnPIGD(ctx context.Context, d *device.Device, logger *device.Logger, myProfile profile.Profile, peerProfile profile.PeerProfile) (Method, error)

NewUPnPIGD Init

type STUN

type STUN struct {
	ConnectionPeer *ExternalConnection
}

STUN struct

func (*STUN) GetPrivateAddr

func (hole *STUN) GetPrivateAddr() string

func (*STUN) Run

func (hole *STUN) Run() error

Run function

func (*STUN) Start

func (hole *STUN) Start() error

type UPnPIGD

type UPnPIGD struct {
	ConnectionPeer *ExternalConnection
}

UPnPIGD struct

func (*UPnPIGD) AddPortMapping

func (hole *UPnPIGD) AddPortMapping(localPort, remotePort int) error

AddPortMapping insert port mapping in the gateway

func (*UPnPIGD) GetExternalInfo

func (hole *UPnPIGD) GetExternalInfo() error

GetExternalInfo fetch wan information

func (*UPnPIGD) GetPrivateAddr

func (hole *UPnPIGD) GetPrivateAddr() string

func (*UPnPIGD) Start

func (hole *UPnPIGD) Start() error

Run execute the Method

Jump to

Keyboard shortcuts

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