Documentation
¶
Index ¶
- Variables
- func DumpConn(conn net.Conn, recv io.Writer, send io.Writer) net.Conn
- func IPv4ToInt(ip net.IP) uint32
- func LimitListener(l net.Listener, n int) net.Listener
- func ParseCIDR(cidr string) (net.IP, *net.IPNet, error)
- func ParseCIDRs(cidrs []string) ([]*net.IPNet, error)
- func ParseIP(ip string) net.IP
- type ConnDebugger
- type ConnDumper
- type DumpListener
- type LimitedListener
Constants ¶
This section is empty.
Variables ¶
var ( AnywhereCIDRs = []string{"0.0.0.0/0", "::/0"} IntranetCIDRs = []string{"127.0.0.0/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/32"} )
Functions ¶
func LimitListener ¶
LimitListener create a listener that accepts at most n simultaneous connections.
func ParseCIDR ¶
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 ¶
ParseCIDRs 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.
type ConnDumper ¶
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.
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 payload dump listener
func NewDumpListener ¶
func NewDumpListener(listener net.Listener, path string) *DumpListener
NewDumpListener wrap a net.conn for dump payload
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 LimitedListener ¶ added in v1.2.4
type LimitedListener struct {
net.Listener
Semaphore chan struct{}
// contains filtered or unexported fields
}
LimitedListener a Listener that accepts at most n simultaneous connections from the provided Listener.
func NewLimitedListener ¶ added in v1.2.4
func NewLimitedListener(l net.Listener, n int) *LimitedListener
NewLimitedListener create a Listener that accepts at most cap(sema) simultaneous connections from the provided Listener. n must greater or equal 0. n = 0 means unlimit.
func (*LimitedListener) Accept ¶ added in v1.2.4
func (ll *LimitedListener) Accept() (net.Conn, error)
func (*LimitedListener) Close ¶ added in v1.2.4
func (ll *LimitedListener) Close() (err error)