snet

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(c net.Conn) (net.Conn, error)

Compress returns a CompressConn.

func CustomConnCloser

func CustomConnCloser(c net.Conn, close func() error) net.Conn

CustomConnCloser returns a net.Conn from c and the close policy handler.

func Dial

func Dial(netaddr string) (net.Conn, error)

Dial connects to the address on the named network.

func Dumper

func Dumper(c net.Conn, hexdump ...bool) net.Conn

Dumper dumps the given connection to stdout in raw or hexdump formats.

func EnableKeepAlive

func EnableKeepAlive(c net.Conn)

EnableKeepAlive enables keep alive if the connection allows it.

func IsTimeout

func IsTimeout(err error) bool

func Listen

func Listen(netaddr string) (net.Listener, error)

Listen announces on the local network address.

func NopConnCloser

func NopConnCloser(c net.Conn) net.Conn

NopConnCloser returns a Conn with a no-op Close method wrapping the provided Conn c.

func Relay

func Relay(local, remote net.Conn) error

Relay copies between local and remote bidirectionally. Returns number of bytes copied from remote to local, from local to remote, and any error occurred. Borrowed from: https://github.com/shadowsocks/go-shadowsocks2

Types

type CompressConn

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

A CompressConn is able to compress/decompress a net Conn by using zstandard codec. It does not close its given net.Conn.

func (*CompressConn) Close

func (c *CompressConn) Close() error

Close implements io.Close.

func (*CompressConn) Read

func (c *CompressConn) Read(p []byte) (n int, err error)

func (*CompressConn) Write

func (c *CompressConn) Write(p []byte) (n int, err error)

type Pipe

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

A Pipe pipes two net.Conn.

func NewPipe

func NewPipe(c, rc net.Conn) (*Pipe, error)

NewPipe returns a new Pipe between the given connections.

func NewPipeTCP

func NewPipeTCP(c net.Conn, remote string) (*Pipe, error)

NewPipeTCP returns a new Pipe by opening a new TCP connection on remote.

func (*Pipe) Close

func (s *Pipe) Close()

Close closes both local and remote connections.

func (*Pipe) LocalConn

func (s *Pipe) LocalConn() net.Conn

LocalConn returns the local connection.

func (*Pipe) Relay

func (s *Pipe) Relay() error

Relay runs the pipeline.

func (*Pipe) RemoteConn

func (s *Pipe) RemoteConn() net.Conn

RemoteConn returns the remote connection.

Jump to

Keyboard shortcuts

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