Documentation ¶
Overview ¶
Provides leaky buffer, based on the example in Effective Go.
Index ¶
- Constants
- Variables
- func AddListen(l Listen)
- func AddRate(r Listen)
- func CheckCipherMethod(method string) error
- func ClearPortRate(port string)
- func ConvertRate(rate int) string
- func CreatePasswd() string
- func CreateUser(u *User)
- func EnoughOptions(config *Config) bool
- func GetListen() []string
- func HandleConnection(conn *Conn, auth bool, lr *Listen)
- func HandleListen()
- func HandleRate()
- func HmacSha1(key []byte, data []byte) []byte
- func IsAboveRate()
- func IsExists(port string) bool
- func IsExpiry()
- func IsFileExists(path string) (bool, error)
- func KillListen(port string) error
- func KillUserPass(port string)
- func ParseBackConfig(config *Config) error
- func Persistence()
- func PersistencePasswd()
- func PipeThenClose(src, dst net.Conn, lr *Listen)
- func PipeThenCloseLocal(src, dst net.Conn)
- func PipeThenCloseOta(src *Conn, dst net.Conn, lr *Listen)
- func PipeThenCloseOtaLocal(src *Conn, dst net.Conn)
- func PrintVersion()
- func RawAddr(addr string) (buf []byte, err error)
- func Run(port, password, method string, auth bool)
- func RunNew(u *User)
- func SendEmail(content string, addr string) error
- func SetDebug(d DebugLog)
- func SetExpiry(port string, d string) error
- func SetRate(port, rate string) error
- func SetReadTimeout(c net.Conn)
- func Sort(arr []uint64, comparison func(uint64, uint64) int64) []uint64
- func UnifyPortPassword(config *Config) (err error)
- func UpdateConfig(old, new *Config)
- func UpdatePasswd(configFile string, config *Config)
- type Cipher
- type ClosedFlag
- type Config
- type Conn
- type DebugLog
- type DecOrEnc
- type Dialer
- type Email
- type LeakyBuf
- type Listen
- type ListenBak
- type PasswdManager
- type PortListener
- type ProxyAddr
- type ProxyConn
- type Rate
- type User
- type UserPass
- type UserPassBack
Constants ¶
const ( OneTimeAuthMask byte = 0x10 AddrMask byte = 0xf )
const (
// TIMEFORMATE 默认时间格式
TIMEFORMATE = "2006-01-02"
)
Variables ¶
var ( // Minport 默认最低端口从10001开始 Minport = 10001 // Maxport 默认最低端口从19999开始 Maxport = 19999 // Currport 当前端口 Currport = Minport )
var ConnChan = make(chan error)
ConnChan 用于定制网络链接信息
var ErrNilCipher = errors.New("cipher can't be nil.")
var GlobaIP string
GlobaIP 全局监听IP
var PassMap map[string]UserPass
var PasswdChan = make(chan *UserPass)
PasswdChan 用于保存网络链接及其口令
var UserChan = make(chan *User)
UserChan 传递新建用户信息
Functions ¶
func CheckCipherMethod ¶
func ConvertRate ¶ added in v0.1.2
ConvertRate 流量转换。 Btye --> KB --> MB --> GB
func HandleConnection ¶
HandleConnection 处理具体链接数据
func IsFileExists ¶
func ParseBackConfig ¶ added in v0.1.3
ParseBackConfig 解析备份配置文件数据
func PipeThenClose ¶
PipeThenClose copies data from src to dst, closes dst when done.
func PipeThenCloseLocal ¶ added in v0.1.3
PipeThenCloseLocal For Local use. copies data from src to dst, closes dst when done.
func PipeThenCloseOta ¶
PipeThenCloseOta copies data from src to dst, closes dst when done, with ota verification.
func PipeThenCloseOtaLocal ¶ added in v0.1.3
PipeThenCloseOtaLocal For Local use. copies data from src to dst, closes dst when done, with ota verification.
func PrintVersion ¶
func PrintVersion()
func SetReadTimeout ¶
func UnifyPortPassword ¶
UnifyPortPassword 确认链接密钥
func UpdateConfig ¶
func UpdateConfig(old, new *Config)
UpdateConfig 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
}
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 Minport int `json:"minport"` Maxport int `json:"maxport"` // 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"` }
Config 网络链接配置信息
func (*Config) GetServerArray ¶
GetServerArray 获取当前所有服务参数
type Conn ¶
func DialWithRawAddr ¶
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 (*Conn) GetAndIncrChunkId ¶
type LeakyBuf ¶
type LeakyBuf struct {
// contains filtered or unexported fields
}
func NewLeakyBuf ¶
NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.
type Listen ¶
type Listen struct { Port string `json:"port"` Rate int `json:"rate"` ExpiryDate string `json:"expiry_date"` RateLimit int `json:"rate_limit"` Email string `json:"email"` //16-12-14 新增Email属性 // contains filtered or unexported fields }
Listen 网络监听对象
type PasswdManager ¶
type PasswdManager struct { sync.Mutex PortListener map[string]*PortListener }
func (*PasswdManager) Add ¶
func (pm *PasswdManager) Add(port, password string, listener net.Listener)
func (*PasswdManager) Del ¶
func (pm *PasswdManager) Del(port string)
func (*PasswdManager) Get ¶
func (pm *PasswdManager) Get(port string) (pl *PortListener, ok bool)
func (*PasswdManager) UpdatePortPasswd ¶
func (pm *PasswdManager) UpdatePortPasswd(port, password string, auth bool)
type PortListener ¶
type PortListener struct {
// contains filtered or unexported fields
}
type ProxyConn ¶
type ProxyConn struct { *Conn // contains filtered or unexported fields }
func (*ProxyConn) RemoteAddr ¶
type User ¶ added in v0.1.3
type User struct { Port string Expriy string `json:"expriy"` Rate int `json:"rate"` RateLimit int `json:"ratelimit"` Email string `json:"email"` //16-12-14 新增email属性 Password string `json:"password"` ID string `json:"port"` }
User 网络链接结构体. Conn对应网络链接,所以这里使用User替代Conn
type UserPassBack ¶ added in v0.1.3
type UserPassBack struct {
Upb []UserPass `json:"upb"`
}
UserPassBack 用于格式化输出UserPass