tunnel

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxReadSize = 4096

	DailRetryTime = 3
	DailSleepTime = 500 * time.Microsecond

	RetryTime     = 3
	RetryInterval = 2 * time.Second
)
View Source
const (
	UDP       = "udp"
	TCP       = "tcp"
	Websocket = "ws"
	Quic      = "quic"
)

Variables

This section is empty.

Functions

func AddCircuitAddrsToPeer

func AddCircuitAddrsToPeer(peer *peer.AddrInfo, relayPeers RelayMap) error

func AppendMultiaddrs

func AppendMultiaddrs(maddrs []ma.Multiaddr, dest ma.Multiaddr) []ma.Multiaddr

AppendMultiaddrs append a maddr into maddrs, do nothing if contains

func BootstrapConnect

func BootstrapConnect(ctx context.Context, ph p2phost.Host, bootstrapPeers RelayMap) error

func CreateLimitOpt added in v1.13.0

func CreateLimitOpt(config *v1alpha1.TunnelLimitConfig) (libp2p.Option, error)

func FilterCircuitMaddr

func FilterCircuitMaddr(maddrs []ma.Multiaddr) []ma.Multiaddr

func FilterPrivateMaddr

func FilterPrivateMaddr(maddrs []ma.Multiaddr) []ma.Multiaddr

func GenerateKeyPairWithString

func GenerateKeyPairWithString(s string) (crypto.PrivKey, error)

func GenerateMultiAddrString

func GenerateMultiAddrString(protocol, ip string, port int) string

GenerateMultiAddrString generate an IPv4 multi-address string by protocol, ip and port supported protocols: ["tcp", "ws", "quic"]

func GeneratePSKReader

func GeneratePSKReader(path string) (io.Reader, error)

func GeneratePeerInfo

func GeneratePeerInfo(hostname string, addrs []string) (*peer.AddrInfo, error)

func GenerateTransportOption

func GenerateTransportOption(protocol string) libp2p.Option

GenerateTransportOption generate Transport option from protocol supported protocols: ["tcp", "ws", "quic"]

func IsNoFindPeerError

func IsNoFindPeerError(err error) bool

func PeerIDFromString

func PeerIDFromString(s string) (peer.ID, error)

func Register

func Register(c *v1alpha1.EdgeTunnelConfig) error

Register register EdgeTunnel to beehive modules

func StringsToMaddrs

func StringsToMaddrs(addrStrings []string) (mas []ma.Multiaddr, err error)

StringsToMaddrs convert multi-address strings to Maddrs

Types

type EdgeTunnel

type EdgeTunnel struct {
	Config *v1alpha1.EdgeTunnelConfig
	// contains filtered or unexported fields
}

EdgeTunnel is used for solving cross subset communication

var Agent *EdgeTunnel

Agent expose the tunnel ability. TODO convert var to func

func (*EdgeTunnel) Enable

func (t *EdgeTunnel) Enable() bool

Enable indicates whether enable this module

func (*EdgeTunnel) GetProxyStream

func (t *EdgeTunnel) GetProxyStream(opts ProxyOptions) (*StreamConn, error)

func (*EdgeTunnel) Group

func (t *EdgeTunnel) Group() string

Group of EdgeTunnel

func (*EdgeTunnel) Name

func (t *EdgeTunnel) Name() string

Name of EdgeTunnel

func (*EdgeTunnel) Run

func (t *EdgeTunnel) Run()

func (*EdgeTunnel) Start

func (t *EdgeTunnel) Start()

Start EdgeTunnel

type ProxyOptions

type ProxyOptions struct {
	Protocol string
	NodeName string
	IP       string
	Port     int32
}

type RelayMap

type RelayMap map[string]*peer.AddrInfo

func GenerateRelayMap

func GenerateRelayMap(relayNodes []*v1alpha1.RelayNode, protocol string, listenPort int) RelayMap

type StreamAddr

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

StreamAddr implements the net.Addr interface

func (*StreamAddr) Network

func (sa *StreamAddr) Network() string

func (*StreamAddr) String

func (sa *StreamAddr) String() string

type StreamConn

type StreamConn struct {
	network.Stream
	// contains filtered or unexported fields
}

StreamConn is libp2p network.Stream wrapper, which implements the Golang net.Conn interface

func NewStreamConn

func NewStreamConn(s network.Stream) *StreamConn

func (*StreamConn) LocalAddr

func (ns *StreamConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*StreamConn) RemoteAddr

func (ns *StreamConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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