conn

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TCPBufSize is the size of tcp buffer.
	TCPBufSize = 16 << 10

	// UDPBufSize is the size of udp buffer.
	UDPBufSize = 64 << 10
)

Variables

This section is empty.

Functions

func Copy added in v0.10.3

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Copy copies from src to dst. it will try to avoid memory allocating by using WriteTo or ReadFrom method, if both failed, then it'll fallback to call CopyBuffer method.

func CopyBuffer added in v0.10.3

func CopyBuffer(dst io.Writer, src io.Reader) (written int64, err error)

CopyBuffer copies from src to dst with a userspace buffer.

func OutboundIP

func OutboundIP() string

OutboundIP returns preferred outbound ip of this machine.

func Relay

func Relay(left, right net.Conn) error

Relay relays between left and right.

func RelayUDP added in v0.7.0

func RelayUDP(dst net.PacketConn, target net.Addr, src net.PacketConn, timeout time.Duration) error

RelayUDP copys from src to dst at target with read timeout.

Types

type Conn

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

Conn is a connection with buffered reader.

func NewConn

func NewConn(c net.Conn) *Conn

NewConn returns a new conn.

func (*Conn) Peek

func (c *Conn) Peek(n int) ([]byte, error)

Peek returns the next n bytes without advancing the reader.

func (*Conn) Read

func (c *Conn) Read(p []byte) (int, error)

func (*Conn) Reader added in v0.6.10

func (c *Conn) Reader() *bufio.Reader

Reader returns the internal bufio.Reader.

Jump to

Keyboard shortcuts

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