forward_tcp

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package forward_tcp forwards TCP traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialRemoteLoop

func DialRemoteLoop(n point_c.Net, dstPort uint16, pairs <-chan *ConnPair, dialed chan<- *ConnPair)

DialRemoteLoop is responsible for dialing the receiver.

func ListenLoop

func ListenLoop(ln net.Listener, conns chan<- net.Conn)

ListenLoop accepts connections and sends them to the next operation.

func PrepareConnPairLoop

func PrepareConnPairLoop(ctx context.Context, logger *slog.Logger, conns <-chan net.Conn, pairs chan<- *ConnPair)

PrepareConnPairLoop initializes the forwarding session.

func StartCopyLoop

func StartCopyLoop(pairs <-chan *ConnPair, copyFn func(done func(), logger *slog.Logger, dst io.Writer, src io.Reader))

StartCopyLoop manages starting the copy for both TCP stream directions.

func TcpCopy

func TcpCopy(done func(), logger *slog.Logger, dst io.Writer, src io.Reader, buf []byte)

TcpCopy is the low level function that does the actual copying of TCP traffic. It only copies the stream in one direction e.g. src->dst or dst->src.

Types

type ConnPair

type ConnPair struct {
	Ctx    context.Context
	Cancel context.CancelFunc
	Remote net.Conn
	Tunnel net.Conn
	Logger *slog.Logger
}

ConnPair helps manage the state of a forwarding session.

func (*ConnPair) DialTunnel

func (cp *ConnPair) DialTunnel(n point_c.Net, dstPort uint16) bool

DialTunnel does the actual remote dialing.

type ForwardTCP

type ForwardTCP struct {
	Ports   configvalues.PortPair `json:"ports"`
	BufSize BufSize               `json:"buf"`
	// contains filtered or unexported fields
}

ForwardTCP is able to forward TCP traffic through networks.

func (*ForwardTCP) CaddyModule

func (f *ForwardTCP) CaddyModule() caddy.ModuleInfo

CaddyModule implements caddy.Module.

func (*ForwardTCP) Cleanup

func (f *ForwardTCP) Cleanup() error

Cleanup implements caddy.CleanerUpper.

func (*ForwardTCP) Provision

func (f *ForwardTCP) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner.

func (*ForwardTCP) Start

func (f *ForwardTCP) Start(n *forward.ForwardNetworks) error

Start implements [ForwardProto]. It is responsible for starting the forwarding of network traffic.

func (*ForwardTCP) UnmarshalCaddyfile

func (f *ForwardTCP) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile unmarshals the caddyfile. Buffer size is the size of the buffer to use per stream direction. Buffer size will be double the specified amount per connection. ```

point-c netops {
    forward <src network name>:<dst network name> {
		    tcp <src port>:<dst port> [buffer size]
    }
}

```

Jump to

Keyboard shortcuts

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