shadowsocks

package
v0.0.0-...-df93b5d Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2016 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

*

  • 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.

Index

Constants

View Source
const (
	OneTimeAuthMask byte = 0x10
	AddrMask        byte = 0xf
)

Variables

This section is empty.

Functions

func CheckCipherMethod

func CheckCipherMethod(method string) error

func HmacSha1

func HmacSha1(key []byte, data []byte) []byte

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 PipeThenCloseOta

func PipeThenCloseOta(src *Conn, dst net.Conn)

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

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.

Types

type Cipher

type Cipher struct {
	// 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.

type ClosedFlag

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

func (*ClosedFlag) IsClosed

func (flag *ClosedFlag) IsClosed() bool

func (*ClosedFlag) SetClosed

func (flag *ClosedFlag) SetClosed()

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
	Auth       bool        `json:"auth"`   // one time auth

	// 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 {
	net.Conn
	*Cipher
	// 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) GetAndIncrChunkId

func (c *Conn) GetAndIncrChunkId() (chunkId uint32)

func (*Conn) GetIv

func (c *Conn) GetIv() (iv []byte)

func (*Conn) GetKey

func (c *Conn) GetKey() (key []byte)

func (*Conn) IsOta

func (c *Conn) IsOta() bool

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
	Encrypt
)

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