proxy

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package proxy implements a simple network proxy for tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link interface {
	fmt.Stringer
	// Listen returns a listener to the local side of the link
	Listen() (net.Listener, error)
	// Dials dials to the remote side of the link
	Dial() (net.Conn, error)
	// Close closes the local link
	Close() error
}

Link allows to build a proxying link between two endpoints.

type NetLink struct {
	// Local specifies the local side of the connection
	Local net.Listener
	// Upstream specifies the remote side of the connection
	Upstream string
}

NetLink links two network endpoints. Implements Link

func (NetLink) Close

func (r NetLink) Close() error

Close closes the local link

func (NetLink) Dial

func (r NetLink) Dial() (net.Conn, error)

Dial dials the remote endpoint. Implements Link

func (NetLink) Listen

func (r NetLink) Listen() (net.Listener, error)

Listen returns a new listener for the local side of the connection Implements Link

func (NetLink) String

func (r NetLink) String() string

Strings provides a textual representation of this link

type Proxy

type Proxy struct {
	log.FieldLogger
	// NotifyCh signals new connections
	NotifyCh chan<- struct{}
	// StartedCh signals when proxy starts servicing
	StartedCh chan<- struct{}
	// contains filtered or unexported fields
}

Proxy defines a link between two endpoints

func New

func New(link Link, log log.FieldLogger) *Proxy

New returns a new proxy for the given link

func (*Proxy) Start

func (r *Proxy) Start() error

Start starts the proxy

func (*Proxy) Stop

func (r *Proxy) Stop()

Stop stops the proxy and drops all active connections

Jump to

Keyboard shortcuts

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