tcpfront

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tcpfront is a loopback TCP listener that forwards every connection to a target resolved per connection, so the address clients use survives the target changing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Front

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

Front accepts connections on a loopback port and pipes them to the current target.

func New

func New(ctx context.Context, target Target) (*Front, error)

New listens on a free loopback port. ctx scopes the logger of the connection handlers.

func (*Front) Addr

func (f *Front) Addr() (string, int)

Addr is the host and port clients connect to.

func (*Front) Close

func (f *Front) Close()

Close stops accepting, drops every open connection and waits for the copiers to finish.

type Target

type Target func() (host string, port int)

Target resolves where the next connection goes; a zero port refuses it.

Jump to

Keyboard shortcuts

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