netx

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpConn

func DumpConn(conn net.Conn, recv io.Writer, send io.Writer) net.Conn

DumpConn wrap a net.conn for dump

func IPv4ToInt

func IPv4ToInt(ip net.IP) uint32

IPv4ToInt converts IP address of version 4 from net.IP to uint32 representation.

func ParseCIDR

func ParseCIDR(cidr string) (net.IP, *net.IPNet, error)

ParseCIDR parses s as a CIDR notation IP address and prefix length, like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291. If no mask supplyed, the default "/32" or "/128" will be appended. It returns the IP address and the network implied by the IP and prefix length. For example, ParseCIDR("192.0.2.1/24") returns the IP address 192.0.2.1 and the network 192.0.2.0/24.

func ParseCIDRs

func ParseCIDRs(cidrs []string) ([]*net.IPNet, error)

ParseCIDRs parse a string representation of an IP and returns a net.IP with the minimum byte representation or nil if input is invalid.

func ParseIP

func ParseIP(ip string) net.IP

ParseIP parse a string representation of an IP and returns a net.IP with the minimum byte representation or nil if input is invalid.

Types

type ConnDebugger

type ConnDebugger struct {
	net.Conn

	Writer     io.Writer
	RecvPrefix string
	RecvSuffix string
	SendPrefix string
	SendSuffix string
	Timestamp  bool
	// contains filtered or unexported fields
}

ConnDebugger a connection debug utility

func (*ConnDebugger) Close

func (cd *ConnDebugger) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*ConnDebugger) Read

func (cd *ConnDebugger) Read(b []byte) (int, error)

Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*ConnDebugger) Write

func (cd *ConnDebugger) Write(b []byte) (int, error)

Write writes data to the connection. Write can be made to time out and return an error after a fixed time limit; see SetDeadline and SetWriteDeadline.

type ConnDumper

type ConnDumper struct {
	net.Conn
	Recv io.Writer
	Send io.Writer
}

ConnDumper a connection dump utility

func (*ConnDumper) Close

func (cd *ConnDumper) Close() (err error)

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*ConnDumper) Read

func (cd *ConnDumper) Read(b []byte) (int, error)

Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*ConnDumper) Write

func (cd *ConnDumper) Write(b []byte) (int, error)

Write writes data to the connection. Write can be made to time out and return an error after a fixed time limit; see SetDeadline and SetWriteDeadline.

type DumpListener

type DumpListener struct {
	net.Listener
	Path       string // dump path
	RecvPrefix string
	RecvSuffix string
	SendPrefix string
	SendSuffix string
	Timestamp  bool
	// contains filtered or unexported fields
}

DumpListener a listener dump utility

func NewDumpListener

func NewDumpListener(listener net.Listener, path string) *DumpListener

NewDumpListener wrap a net.conn for dump

func (*DumpListener) Accept

func (dl *DumpListener) Accept() (conn net.Conn, err error)

Accept waits for and returns the next connection to the listener.

func (*DumpListener) Disable

func (dl *DumpListener) Disable(disabled bool)

Disable disable the dumper or not

type LimitListener

type LimitListener struct {
	net.Listener
	// contains filtered or unexported fields
}

LimitListener a Listener that accepts at most n simultaneous connections from the provided Listener.

func NewLimitListener

func NewLimitListener(l net.Listener, sema chan struct{}) *LimitListener

NewLimitListener create a Listener that accepts at most cap(sema) simultaneous connections from the provided Listener.

func (*LimitListener) Accept

func (ll *LimitListener) Accept() (net.Conn, error)

func (*LimitListener) Close

func (ll *LimitListener) Close() error

Jump to

Keyboard shortcuts

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