tunnel

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZeroTime = time.Time{}

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint represents the record of discovering peerinfo via message.PacketType_Discovery.

func (*Endpoint) Write

func (c *Endpoint) Write(data []byte)

type FragmentCallback

type FragmentCallback interface {
	// OnFragment will be called if there are fragments received from the
	// low-level mesh network.
	OnFragment(data []byte)
}

FragmentCallback represents the callback of receiving fragment data.

type RelayClientGetter

type RelayClientGetter func() *relay.Client

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields
}

Tunnel represents the remote conn and maintain the conn state.

func New

func New(rcGetter RelayClientGetter, dialer *net.Dialer, localPeer types.LocalPeer, peerID protocol.PeerID, callback FragmentCallback, cipher noise.Cipher) *Tunnel

func (*Tunnel) Cipher

func (t *Tunnel) Cipher() noise.Cipher

Cipher returns the noise.Cipher.

func (*Tunnel) Close

func (t *Tunnel) Close()

Close closes the current conn and clear status.

func (*Tunnel) IsDisco

func (t *Tunnel) IsDisco() bool

func (*Tunnel) OnUDPPacket

func (t *Tunnel) OnUDPPacket(udpConn *net.UDPConn, data []byte)

OnUDPPacket implements the UDPPacketCallback interface. Which handles all UDP packets received from all tunnels.

func (*Tunnel) ReachableEndpoint

func (t *Tunnel) ReachableEndpoint() *Endpoint

func (*Tunnel) SetLocalEndpoints

func (t *Tunnel) SetLocalEndpoints(endpoints []string)

func (*Tunnel) SetRemoteEndpoints

func (t *Tunnel) SetRemoteEndpoints(endpoints []string)

func (*Tunnel) Write

func (t *Tunnel) Write(data []byte)

type UDPPacketCallback

type UDPPacketCallback interface {
	// OnUDPPacket will be called if there are UDP packets received from
	// the low-level UDPConn connections.
	OnUDPPacket(udpConn *net.UDPConn, data []byte)
}

UDPPacketCallback represents the callback of UDP packets. There are two ways to read UDP packets: 1. UDP packets from relay server (PacketConnect/PacketFragment/Other system packets). 2. UDP packets from peers (PacketKeepalive/PacketFragment).

Jump to

Keyboard shortcuts

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