p2pforwarder

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const Protocol = "/p2ptunnel/0.1"

Variables

View Source
var (
	// ErrMaxConnections = error "Max connections reached"
	ErrMaxConnections = errors.New("Max connections reached")
	// ErrPortAlreadyOpened = error "Port already opened"
	ErrPortAlreadyOpened = errors.New("Port already opened")
	// ErrUnknownNetworkType = error "Unknown network type, it must be \"tcp\" or \"udp\""
	ErrUnknownNetworkType = errors.New("Unknown network type, it must be \"tcp\" or \"udp\"")
	// ErrConnectionExists = error "You are already connected to specified host"
	ErrConnectionExists = errors.New("You are already connected to specified host")
)
View Source
var ErrConnReset = errors.New("Connection reset")

ErrConnReset = error Connection reset

Functions

func OnError

func OnError(fn func(error))

OnError sets function which be called on error inside this package

func OnInfo

func OnInfo(fn func(string))

OnInfo sets function which be called on information inside this package

Types

type Forwarder

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

Forwarder - instance of P2P Forwarder

func NewForwarder

func NewForwarder(p2p_port int) (*Forwarder, context.CancelFunc, error)

NewForwarder - instances Forwarder and connects it to libp2p network

func (*Forwarder) Connect

func (f *Forwarder) Connect(id string, ip string) (listenip string, cancel context.CancelFunc, err error)

Connect starts forwarding connections to `listenip`:`PORT` to passed id`:`PORT`

func (*Forwarder) ID

func (f *Forwarder) ID() string

ID returns id of Forwarder

func (*Forwarder) OpenPort

func (f *Forwarder) OpenPort(networkType string, port uint16) (cancel func(), err error)

OpenPort opens port in specified networkType - "tcp" or "udp"

Jump to

Keyboard shortcuts

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