Documentation
¶
Overview ¶
Package pipe2socks implements a pipe to route IP packets stream from io.ReadWriteCloser to socks proxy and back. You need a configured socks5 proxy address for the Copy function.
Basically it is a broad implementation of tun2socks. And yes, io.ReadWriteCloser could be a TUN device.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOpts = &Opts{ MTU: 1500, UDP: true, UDPTimeout: 30 * time.Second, }
DefaultOpts represent the default connection settings suitable for most cases.
Functions ¶
Types ¶
type Opts ¶
type Opts struct { MTU int // MTU should be set according to your configuration to prevent data losses. UDP bool // UDP enables UDP support. Recommended to be turned on. UDPTimeout time.Duration }
Opts contain options for the established connection between pipe and Socks server. DefaultOpts should be used for most cases.
type Pipe ¶
type Pipe struct {
// contains filtered or unexported fields
}
Pipe represents a pipe that connects io.ReadWriteCloser and sock5 proxy.
func (*Pipe) Copy ¶
Copy connects io.ReadWriteCloser to socks5 server.
It reads IP packets from pipe and routes them to socks5 and back. This function blocks for the duration of the whole transmission, and it is recommended to gracefully unlock it (ending the established connection) by cancelling the ctx.