Version: v0.1.22 Latest Latest

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 24 Imported by: 0




* Created with IntelliJ IDEA.
* User: clowwindy
* Date: 12-11-2
* Time: 上午10:31
* To change this template use File | Settings | File Templates.

Provides leaky buffer, based on the example in Effective Go.



This section is empty.


This section is empty.


func CheckCipherMethod

func CheckCipherMethod(method string) error

func IsFileExists

func IsFileExists(path string) (bool, error)

func PipeThenClose

func PipeThenClose(src, dst net.Conn)

PipeThenClose copies data from src to dst, closes dst when done.

func PrintVersion

func PrintVersion()

func RawAddr

func RawAddr(addr string) (buf []byte, err error)

func SetDebug

func SetDebug(d DebugLog)

func SetReadTimeout

func SetReadTimeout(c net.Conn)

func Sort

func Sort(arr []uint64, comparison func(uint64, uint64) int64) []uint64

func UpdateConfig

func UpdateConfig(old, new *Config)

Useful for command line to override options specified in config file Debug is not updated.


type Cipher

type Cipher struct {
	AC *aead.Cipher
	// contains filtered or unexported fields

func NewCipher

func NewCipher(method, password string) (c *Cipher, err error)

NewCipher creates a cipher that can be used in Dial() etc. Use cipher.Copy() to create a new cipher with the same method and password to avoid the cost of repeated cipher initialization.

func (*Cipher) Copy

func (c *Cipher) Copy() *Cipher

Copy creates a new cipher at it's initial state.

func (*Cipher) Init

func (c *Cipher) Init(conn net.Conn)

type Config

type Config struct {
	Server     interface{} `json:"server"`
	ServerPort int         `json:"server_port"`
	LocalPort  int         `json:"local_port"`
	Password   string      `json:"password"`
	Method     string      `json:"method"` // encryption method

	// following options are only used by server
	PortPassword map[string]string `json:"port_password"`
	Timeout      int               `json:"timeout"`

	// The order of servers in the client config is significant, so use array
	// instead of map to preserve the order.
	ServerPassword [][]string `json:"server_password"`

func ParseConfig

func ParseConfig(path string) (config *Config, err error)

func (*Config) GetServerArray

func (config *Config) GetServerArray() []string

type Conn

type Conn struct {
	// contains filtered or unexported fields

func Dial

func Dial(addr, server string, cipher *Cipher) (c *Conn, err error)

addr should be in the form of host:port

func DialWithRawAddr

func DialWithRawAddr(rawaddr []byte, server string, cipher *Cipher) (c *Conn, err error)

This is intended for use by users implementing a local socks proxy. rawaddr shoud contain part of the data in socks request, starting from the ATYP field. (Refer to rfc1928 for more information.)

func NewConn

func NewConn(c net.Conn, cipher *Cipher) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

type DebugLog

type DebugLog bool
var Debug DebugLog

func (DebugLog) Printf

func (d DebugLog) Printf(format string, args ...interface{})

func (DebugLog) Println

func (d DebugLog) Println(args ...interface{})

type DecOrEnc

type DecOrEnc int
const (
	Decrypt DecOrEnc = iota

type LeakyBuf

type LeakyBuf struct {
	// contains filtered or unexported fields

func NewLeakyBuf

func NewLeakyBuf(n, bufSize int) *LeakyBuf

NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.

func (*LeakyBuf) Get

func (lb *LeakyBuf) Get() (b []byte)

Get returns a buffer from the leaky buffer or create a new buffer.

func (*LeakyBuf) Put

func (lb *LeakyBuf) Put(b []byte)

Put add the buffer into the free buffer pool for reuse. Panic if the buffer size is not the same with the leaky buffer's. This is intended to expose error usage of leaky buffer.

Jump to

Keyboard shortcuts

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