util

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close[T any](ch chan T) (ok bool)

Close closes channel ch if ch != nil. It recovers from panic if the channel is already closed. It returns ok=true if the channel was closed successfully.

func ConnBGP added in v0.15.1

func ConnBGP(s *core.StageBase, conn net.Conn, in *pipe.Input) error

ConnBGP handles an opened BGP connection conn for stage s

func ConnPublish

func ConnPublish(s *core.StageBase, conn net.Conn)

ConnPublish publishes connection information to stage s's pipe KV store, for the benefit of other stages. It sets L_LOCAL_ADDR, L_LOCAL_PORT, L_REMOTE_ADDR, L_REMOTE_PORT for the first stage, and R_LOCAL_ADDR, R_LOCAL_PORT, R_REMOTE_ADDR, R_REMOTE_PORT for the last stage.

func DialRetry

func DialRetry(s *core.StageBase, dialer *net.Dialer, network, address string) (net.Conn, error)

DialRetry is a dialer.DialContext wrapper that adds connection timeout and retry with exponential backoff and jitter. Stage s can have many konfig options to tune the dialing.

func Send

func Send[T any](ch chan T, v T) (ok bool)

Send sends value v to channel ch, if ch != nil. It recovers from panic if the channel is closed. It returns ok=true if the value was sent successfully.

Types

type ControlFunc added in v0.21.0

type ControlFunc = func(network, address string, c syscall.RawConn) error

ControlFunc is a net.Dialer / net.ListenConfig socket control callback.

func Chain added in v0.21.0

func Chain(fns ...ControlFunc) ControlFunc

Chain composes control funcs into one, skipping nils and stopping on the first error.

func TcpMd5

func TcpMd5(md5pass string) ControlFunc

TcpMd5 returns a control func installing the TCP-MD5 signature password.

func Transparent added in v0.21.0

func Transparent() ControlFunc

Transparent returns a control func enabling IP_TRANSPARENT (Linux TPROXY): it lets a listener accept connections destined to a foreign address, and a dialer bind to (spoof) a non-local source address.

func Ttl added in v0.21.0

func Ttl(ttl int) ControlFunc

Ttl returns a control func setting the outgoing IP TTL / hop limit (0 leaves the kernel default; 255 satisfies GTSM / RFC 5082).

type Stdlog

type Stdlog struct {
	zerolog.Logger
}

Stdlog adapts zerolog to standard log interface

func (*Stdlog) Debugf

func (l *Stdlog) Debugf(format string, args ...any)

func (*Stdlog) Errorf

func (l *Stdlog) Errorf(format string, args ...any)

func (*Stdlog) Infof

func (l *Stdlog) Infof(format string, args ...any)

func (*Stdlog) Printf

func (l *Stdlog) Printf(format string, args ...any)

func (*Stdlog) Warnf

func (l *Stdlog) Warnf(format string, args ...any)

Jump to

Keyboard shortcuts

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