p2pforwarder

package module
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: MIT Imports: 31 Imported by: 1

README

P2P Forwarder

Go Report Card

A tool for farwarding ports. Made using libp2p.

screenshot

How it works

  • A: opens desired ports ports inside P2P Forwarder
  • A: shares it's id from P2P Forwarder with B
  • B: connects to A's id inside P2P Forwarder
  • B: connect to opened ports on A's machine using address like 127.0.89.N:PORT_ON_A's_MACHINE

P.S. every edit field handles Ctrl+C and Ctrl+V. To exit the program, press Ctrl+Q

Project status

Project is on early beta stage. I recommend you to use it only for personal purposes like playing Minecraft with friends.

Current uis are cli and tui (clui).

Feel free to contribute to this project by opening an issue (it may be a question) or creating a pull request
Star this project if you liked it or found it useful for you :3

Documentation

Index

Constants

This section is empty.

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() (*Forwarder, context.CancelFunc, error)

NewForwarder - instances Forwarder and connects it to libp2p network

func (*Forwarder) Connect added in v0.1.1

func (f *Forwarder) Connect(id 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"

Directories

Path Synopsis
cmd
cli
tui

Jump to

Keyboard shortcuts

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