tunneler

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrListenerClosed = errors.New("tunneler: Listener closed")

ErrListenerClosed is returned by Accept after Close has been called.

Functions

func NewTunneler

func NewTunneler() *tunneler

func SyncerTunnelURL

func SyncerTunnelURL(host, ws, target string) (string, error)

syncerTunnelURL builds the destination url with the Dialer expected format of the URL.

Types

type Dialer

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

The Dialer can create new connections back to the origin. A Dialer can have multiple clients.

func NewDialer

func NewDialer(conn net.Conn) *Dialer

NewDialer returns the side of the connection which will initiate new connections over the already established reverse connections.

func (*Dialer) Close

func (d *Dialer) Close() error

Close closes the Dialer.

func (*Dialer) Dial

func (d *Dialer) Dial(ctx context.Context, network string, address string) (net.Conn, error)

Dial creates a new connection back to the Listener.

func (*Dialer) Done

func (d *Dialer) Done() <-chan struct{}

Done returns a channel which is closed when d is closed (either by this process on purpose, by a local error, or close or error from the peer).

type Listener

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

Listener is a net.Listener, returning new connections which arrive from a corresponding Dialer.

func NewListener

func NewListener(client *http.Client, url string) (*Listener, error)

NewListener returns a new Listener, it dials to the Dialer creating "reverse connection" that are accepted by this Listener. - client: http client, required for TLS - url: a URL to the base of the reverse handler on the Dialer.

func (*Listener) Accept

func (ln *Listener) Accept() (net.Conn, error)

Accept blocks and returns a new connection, or an error.

func (*Listener) Addr

func (ln *Listener) Addr() net.Addr

Addr returns a dummy address. This exists only to conform to the net.Listener interface.

func (*Listener) Close

func (ln *Listener) Close() error

Close closes the Listener, making future Accept calls return an error.

Jump to

Keyboard shortcuts

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