Documentation ¶
Index ¶
- Constants
- func AllIPAddr() string
- func BidiCopy(conn1, conn2 io.ReadWriteCloser) error
- func FillBytes(b []byte, value byte)
- func GetAllStackTrace() string
- func GetHeapProfile(filePath string) error
- func GetMemoryStats() string
- func GetStackTrace() string
- func IsBitsAllOne(b []byte) bool
- func IsBitsAllZero(b []byte) bool
- func IsIPDualStack() bool
- func IsNilNetAddr(addr net.Addr) bool
- func LocalIPAddr() string
- func MarshalJSON(m protoreflect.ProtoMessage) ([]byte, error)
- func MaxConsecutivePrintableLength(b []byte) int
- func MaybeDecorateIPv6(addr string) string
- func NilNetAddr() net.Addr
- func ReadAllAndDiscard(r io.Reader)
- func RoundTrip(ctx context.Context, rw io.ReadWriter, req []byte, maxRespSize int) (resp []byte, err error)
- func SetReadTimeout(conn SetReadDeadlineInterface, timeout time.Duration)
- func StartCPUProfile(filePath string) error
- func StopCPUProfile()
- func TCPCongestionControlAlgorithm() string
- func ToCommon64Set(b []byte, beginIdx, endIdx int)
- func ToPrintableChar(b []byte, beginIdx, endIdx int)
- func UnmarshalJSON(b []byte, m protoreflect.ProtoMessage) error
- func UnusedTCPPort() (int, error)
- func UnusedUDPPort() (int, error)
- type BitDistribution
- type HierarchyConn
- type SetReadDeadlineInterface
- type TransportProtocol
Constants ¶
const ( PrintableCharSub = 0x20 // 0x20, i.e. ' ', is the first printable ASCII character PrintableCharSup = 0x7E // 0x7E, i.e. '~', is the last printable ASCII character // Common64Set contains 64 selected common characters. // This value can change in different software releases. Common64Set = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-" )
const DefaultMTU = 1400
DefaultMTU is the default MTU of L2 packets in the network.
Variables ¶
This section is empty.
Functions ¶
func AllIPAddr ¶
func AllIPAddr() string
AllIPAddr returns a catch-all IP address to bind. If the machine supports IP dual stack, "::" is returned. Otherwise "0.0.0.0" is returned.
func BidiCopy ¶
func BidiCopy(conn1, conn2 io.ReadWriteCloser) error
BidiCopy does bi-directional data copy.
func GetAllStackTrace ¶ added in v3.8.1
func GetAllStackTrace() string
GetAllStackTrace returns the stack trace of all goroutines.
func GetHeapProfile ¶ added in v3.8.1
GetHeapProfile generates a heap profile file.
func GetMemoryStats ¶ added in v3.8.1
func GetMemoryStats() string
GetMemoryStats returns JSON formatted memory statistics.
func GetStackTrace ¶ added in v3.8.1
func GetStackTrace() string
GetStackTrace returns the stack trace of this goroutine.
func IsBitsAllOne ¶
IsBitsAllOne returns true if all bits in the slice are one.
func IsBitsAllZero ¶
IsBitsAllZero returns true if all bits in the slice are zero.
func IsIPDualStack ¶
func IsIPDualStack() bool
IsIPDualStack returns true if an IPv6 socket is able to send and receive both IPv4 and IPv6 packets.
This function only supports Linux. It always returns false if running other operating systems.
func IsNilNetAddr ¶
IsNilNetAddr returns true if the net.Addr is nil / empty.
func MarshalJSON ¶
func MarshalJSON(m protoreflect.ProtoMessage) ([]byte, error)
Marshal returns a JSON representation of protobuf.
func MaxConsecutivePrintableLength ¶
MaxConsecutivePrintableLength returns the length of the maximum consecutive bytes that are printable.
func MaybeDecorateIPv6 ¶
MaybeDecorateIPv6 adds [ and ] before and after an IPv6 address. If the input string is a IPv4 address or not a valid IP address (e.g. is a domain name), the same string is returned.
func ReadAllAndDiscard ¶
ReadAllAndDiscard reads from r until an error or EOF. All the data are discarded.
func RoundTrip ¶
func RoundTrip(ctx context.Context, rw io.ReadWriter, req []byte, maxRespSize int) (resp []byte, err error)
RoundTrip sends a request to the connection and returns the response.
func SetReadTimeout ¶
func SetReadTimeout(conn SetReadDeadlineInterface, timeout time.Duration)
SetReadTimeout set read deadline. It cancels the deadline if the timeout is 0 or negative.
func StartCPUProfile ¶ added in v3.8.1
StartCPUProfile starts CPU profile and writes result to the file.
func TCPCongestionControlAlgorithm ¶
func TCPCongestionControlAlgorithm() string
TCPCongestionControlAlgorithm returns the TCP congestion control algorithm used by the operating system.
func ToCommon64Set ¶
ToCommon64Set rewrites [beginIdx, endIdx) of the byte slice with characters from Common64Set.
func ToPrintableChar ¶
ToPrintableChar rewrites [beginIdx, endIdx) of the byte slice with printable ASCII characters.
func UnmarshalJSON ¶
func UnmarshalJSON(b []byte, m protoreflect.ProtoMessage) error
Unmarshal writes protobuf based on JSON data.
func UnusedTCPPort ¶
UnusedTCPPort returns an unused TCP port in the local network.
func UnusedUDPPort ¶
UnusedUDPPort returns an unused UDP port in the local network.
Types ¶
type BitDistribution ¶
BitDistribution describes the probability of bit 0 and bit 1 in a byte array.
func ToBitDistribution ¶
func ToBitDistribution(arr []byte) BitDistribution
ToBitDistribution returns the BitDistribution from a byte array.
func (BitDistribution) String ¶
func (bd BitDistribution) String() string
type HierarchyConn ¶
type HierarchyConn interface { net.Conn // AddSubConnection attach a child connection to this connection. // The child connection is closed when this connection close. AddSubConnection(conn net.Conn) }
HierarchyConn closes sub-connections when this connection is closed.
func WrapHierarchyConn ¶
func WrapHierarchyConn(conn net.Conn) HierarchyConn
WrapHierarchyConn wraps an existing connection with HierarchyConn.
type TransportProtocol ¶
type TransportProtocol uint8
const ( UnknownTransport TransportProtocol = iota StreamTransport PacketTransport )