privatesocks

package
v0.0.0-...-a2d86c6 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAddrType      = errors.New("socks addr type not supported")
	ErrVer           = errors.New("socks version not supported")
	ErrMethod        = errors.New("socks only support 1 method now")
	ErrAuthExtraData = errors.New("socks authentication get extra data")
	ErrReqExtraData  = errors.New("socks request get extra data")
	ErrCmd           = errors.New("socks command not supported")
)

Functions

func InitCmdConfig

func InitCmdConfig()

func InitDb

func InitDb() error

func PipeThenClose

func PipeThenClose(src, dst net.Conn) (traffic int64)

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

func Save

func Save(sql string, args ...interface{}) error

func SetReadTimeout

func SetReadTimeout(c net.Conn)

func SetTimeout

func SetTimeout(timeout int)

func ShowVersion

func ShowVersion()

Types

type Config

type Config struct {
	Server     string
	ServerPort int
	Timeout    int               `json:"timeout"`
	UserPort   map[string]string `json:"user_port"`
	Debug      bool
}
var CmdConfig *Config
var FileConfig *Config

func ParseConfig

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

type Conn

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

func NewConn

func NewConn(c net.Conn) *Conn

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

type User

type User struct {
	Port    string `json:"port"`
	Name    string `json:"name"`
	Traffic int64  `json:"traffic"`
}

func GetAllUser

func GetAllUser() ([]User, error)

func NewUser

func NewUser(name, port string) *User

func (*User) Save

func (u *User) Save()

Jump to

Keyboard shortcuts

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