reverseconnection

package
v0.0.0-...-63c3a42 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

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

func NewDialer

func NewDialer(rawDialer *net.Dialer, serveMux *http.ServeMux,
	minimumInterval, maximumInterval time.Duration,
	logger log.DebugLogger) *Dialer

NewDialer creates a dialer that may be used to make connections. It also registers a HTTP handler for receiving connections from remote systems which have requested connections. When the Dial method is called, if a new connection has been received it is used instead of dialing out the normal way. If rawDialer is nil, the default dialer is used to dial out when needed. If serveMux is nil then the default http.ServeMux is used. NewDialer may be called only once per serveMux. The minimumInterval and maximumInterval parameters are passed back to remote systems which are making connections, overriding their default configuration.

func (*Dialer) Dial

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

Dial makes a connection to a remote address, possibly consuming a connection that was initiated by the remote address.

type Listener

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

func Listen

func Listen(network string, portNumber uint, logger log.DebugLogger) (
	*Listener, error)

Listen creates a listener which may be used to accept incoming connections. It listens on all available IP addresses on the local system.

func (*Listener) Accept

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

func (*Listener) Addr

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

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) RequestConnections

func (l *Listener) RequestConnections(serviceName string) error

RequestConnections starts a goroutine which will periodically attempt to establish a connection with a remote server if there is no incoming connection from the remote server. The connection that is established will be returned by the Accept method. The configuration information for the remote server is read from the JSON-encoded file with filename: "/etc/reverse-listeners/"+serviceName with the format ReverseListenerConfig.

type ReverseListenerConfig

type ReverseListenerConfig struct {
	Network         string        // May be empty or "tcp".
	ServerAddress   string        // Address of the remote server.
	MinimumInterval time.Duration // Minimum interval to request connections.
	MaximumInterval time.Duration // Maximum interval to request connections.
}

ReverseListenerConfig describes the configuration for a remote server for which connections are requested.

Jump to

Keyboard shortcuts

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