Documentation ¶
Index ¶
- Constants
- func DialRemoteLoop(n Net, dstPort uint16, pairs <-chan *ConnPair, dialed chan<- *ConnPair)
- func ListenLoop(ln net.Listener, conns chan<- net.Conn)
- func PrepareConnPairLoop(ctx context.Context, logger *slog.Logger, conns <-chan net.Conn, ...)
- func StartCopyLoop(pairs <-chan *ConnPair, ...)
- func StubListener(_ context.Context, _, addr string, _ net.ListenConfig) (any, error)
- func TcpCopy(done func(), dst io.Writer, src io.Reader, logger *slog.Logger)
- type ConnPair
- type Dialer
- type DynamicDialer
- type DynamicNet
- type Forward
- type ForwardProto
- type ForwardTCP
- type Listener
- type MergeWrapper
- type Net
- type NetLookup
- type NetOp
- type NetOpApp
- type Network
- type Pointc
- func (*Pointc) CaddyModule() caddy.ModuleInfo
- func (pc *Pointc) Cleanup() error
- func (pc *Pointc) Lookup(name string) (Net, bool)
- func (pc *Pointc) Provision(ctx caddy.Context) error
- func (pc *Pointc) Register(key string, n Net) error
- func (pc *Pointc) Start() error
- func (pc *Pointc) Stop() error
- func (pc *Pointc) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type RegisterFunc
Constants ¶
const (
CaddyfilePointCName = "point-c"
)
const NetworkStubName = "stub"
Variables ¶
This section is empty.
Functions ¶
func DialRemoteLoop ¶ added in v0.0.3
func PrepareConnPairLoop ¶ added in v0.0.3
func StartCopyLoop ¶ added in v0.0.3
func StubListener ¶ added in v0.0.3
StubListener creates a stub network listener. This listener does not accept actual network connections but instead blocks on Accept calls until Close is called. It can be used as a base listener when only tunnel listeners are required.
Types ¶
type ConnPair ¶ added in v0.0.3
type DynamicDialer ¶ added in v0.0.10
type DynamicDialer struct { DialFn func(ctx context.Context, addr *net.TCPAddr) (net.Conn, error) DialPacketFn func(addr *net.UDPAddr) (net.PacketConn, error) }
func (*DynamicDialer) DialPacket ¶ added in v0.0.10
func (d *DynamicDialer) DialPacket(a *net.UDPAddr) (net.PacketConn, error)
type DynamicNet ¶ added in v0.0.10
type DynamicNet struct { ListenFn func(*net.TCPAddr) (net.Listener, error) ListenPacketFn func(*net.UDPAddr) (net.PacketConn, error) DialerFn func(laddr net.IP, port uint16) Dialer LocalAddrFn func() net.IP }
func (*DynamicNet) ListenPacket ¶ added in v0.0.10
func (d *DynamicNet) ListenPacket(a *net.UDPAddr) (net.PacketConn, error)
func (*DynamicNet) LocalAddr ¶ added in v0.0.10
func (d *DynamicNet) LocalAddr() net.IP
type Forward ¶ added in v0.0.3
type Forward struct { ForwardsRaw []json.RawMessage `json:"forwards,omitempty" caddy:"namespace=point-c.op.forward inline_key=forward"` Host configvalues.Hostname `json:"host"` // contains filtered or unexported fields }
func (*Forward) CaddyModule ¶ added in v0.0.3
func (f *Forward) CaddyModule() caddy.ModuleInfo
type ForwardProto ¶ added in v0.0.3
type ForwardProto = lifecycler.LifeCyclable[Net]
type ForwardTCP ¶ added in v0.0.3
type ForwardTCP struct { Ports configvalues.PortPair `json:"ports"` // contains filtered or unexported fields }
func (*ForwardTCP) CaddyModule ¶ added in v0.0.3
func (f *ForwardTCP) CaddyModule() caddy.ModuleInfo
func (*ForwardTCP) Cleanup ¶ added in v0.0.3
func (f *ForwardTCP) Cleanup() error
func (*ForwardTCP) Provision ¶ added in v0.0.3
func (f *ForwardTCP) Provision(ctx caddy.Context) error
func (*ForwardTCP) Start ¶ added in v0.0.3
func (f *ForwardTCP) Start(n Net) error
func (*ForwardTCP) Stop ¶ added in v0.0.3
func (f *ForwardTCP) Stop() error
func (*ForwardTCP) UnmarshalCaddyfile ¶ added in v0.0.3
func (f *ForwardTCP) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
type Listener ¶
type Listener struct { Name configvalues.Hostname `json:"name"` Port configvalues.Port `json:"port"` // contains filtered or unexported fields }
Listener allows a caddy server to listen on a point-c network.
func (*Listener) CaddyModule ¶
func (*Listener) CaddyModule() caddy.ModuleInfo
func (*Listener) UnmarshalCaddyfile ¶
UnmarshalCaddyfile unmarshals the caddyfile.
{ servers :443 { listener_wrappers { merge { # this is the actual listener definition point-c <network name> <port to expose> } # make sure tls goes after otherwise encryption will be dropped tls } } }
type MergeWrapper ¶ added in v0.0.3
type MergeWrapper struct { // ListenerRaw is a slice of JSON-encoded data representing listener configurations. // These configurations are used to create the actual net.Listener instances. // Listeners should implement [net.Listener] and be in the 'caddy.listeners.merge.listeners' namespace. ListenerRaw []json.RawMessage `json:"listeners" caddy:"namespace=caddy.listeners.merge inline_key=listener"` // contains filtered or unexported fields }
MergeWrapper loads multiple [net.Listener]s and aggregates their [net.Conn]s into a single net.Listener. It allows caddy to accept connections from multiple sources.
func (*MergeWrapper) CaddyModule ¶ added in v0.0.3
func (p *MergeWrapper) CaddyModule() caddy.ModuleInfo
CaddyModule implements caddy.Module.
func (*MergeWrapper) Cleanup ¶ added in v0.0.3
func (p *MergeWrapper) Cleanup() (err error)
Cleanup implements caddy.CleanerUpper. All wrapped listeners are closed and the struct is cleared.
func (*MergeWrapper) Provision ¶ added in v0.0.3
func (p *MergeWrapper) Provision(ctx caddy.Context) error
Provision implements caddy.Provisioner. It loads the listeners from their configs and asserts them to net.Listener. Any failed assertions will cause a panic.
func (*MergeWrapper) UnmarshalCaddyfile ¶ added in v0.0.3
func (p *MergeWrapper) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile implements caddyfile.Unmarshaler. Must have at least one listener to aggregate with the wrapped listener. `tls` should come specifically after any `merge` directives.
http caddyfile: { servers :443 { listener_wrappers { merge { <submodule name> <submodule config> } tls } } }
func (*MergeWrapper) WrapListener ¶ added in v0.0.3
func (p *MergeWrapper) WrapListener(ls net.Listener) net.Listener
WrapListener implements caddy.ListenerWrapper. The listener passed in is closed by MergeWrapper during cleanup.
type Net ¶
type Net interface { // Listen listens on the given address with the TCP protocol. Listen(addr *net.TCPAddr) (net.Listener, error) // ListenPacket listens on the given address with the UDP protocol. ListenPacket(addr *net.UDPAddr) (net.PacketConn, error) // Dialer returns a [Dialer] with a given local address. If the network does not support arbitrary remote addresses this value can be ignored. Dialer(laddr net.IP, port uint16) Dialer // LocalAddr is the local address of the net interface. If it does not have one, return nil. LocalAddr() net.IP }
Net is a peer in the networking stack. If it has a local address [Net.LocalAddress] should return a non-nil value.
func NewSystemNet ¶ added in v0.0.10
func NewSystemNet() Net
type NetOp ¶
type NetOp = lifecycler.LifeCyclable[NetLookup]
type Network ¶
type Network = lifecycler.LifeCyclable[RegisterFunc]
type Pointc ¶
type Pointc struct { NetworksRaw []json.RawMessage `json:"networks,omitempty" caddy:"namespace=point-c.net inline_key=type"` NetOps []json.RawMessage `json:"net-ops,omitempty" caddy:"namespace=point-c.op inline_key=op"` // contains filtered or unexported fields }
Pointc allows usage of networks through a net-ish interface.
func (*Pointc) CaddyModule ¶
func (*Pointc) CaddyModule() caddy.ModuleInfo
type RegisterFunc ¶
RegisterFunc registers a unique name to a Net tunnel. Since ip addresses may be arbitrary depending on what the application is doing in the tunnel, names are used as lookup. This allows helps with configuration, so that users don't need to remember ip addresses.