tools

package
v0.0.0-...-38ae272 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonPrefixLen

func CommonPrefixLen(a, b string) int

CommonPrefixLen returns the length of common prefix

func DecodeCompactIPPortInfo

func DecodeCompactIPPortInfo(info string) (ip net.IP, port int, err error)

DecodeCompactIPPortInfo decodes compactIP-address/port info in BitTorrent DHT Protocol. It returns the ip and port number.

func EncodeCompactIPPortInfo

func EncodeCompactIPPortInfo(ip net.IP, port int) (info string, err error)

EncodeCompactIPPortInfo encodes an ip and a port number to compactIP-address/port info.

func RandomString

func RandomString(size uint) string

RandomString generates a size-length string randomly.

Types

type StreamReader

type StreamReader struct {
	// contains filtered or unexported fields
}

StreamReader implements buffering for an io.StreamReader object.

func NewStreamReader

func NewStreamReader(conn net.Conn, timeout time.Duration) *StreamReader

NewStreamReader returns a new Reader.

func (*StreamReader) Read

func (r *StreamReader) Read(b []byte) (int, error)

type StreamWriter

type StreamWriter struct {
	// contains filtered or unexported fields
}

StreamWriter is stream writer

func NewStreamWriter

func NewStreamWriter(conn net.Conn, timeout time.Duration) *StreamWriter

NewStreamWriter returns a new Writer.

func (*StreamWriter) Write

func (w *StreamWriter) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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