Documentation ¶
Index ¶
- Constants
- Variables
- func CreateClientConfig(file string, d5s *D5ServConf, user string) (e error)
- func DetectFile(isServ bool) (string, bool)
- func DetectRunAsServ() bool
- func GenerateD5sTemplate(file string, rsaParam string) (e error)
- func GetAvailableCipher(wants string) (*cipherDecr, error)
- func IdentifierOf(con net.Conn) string
- func IsNotExist(file string) bool
- func IsTimeout(e error) bool
- func IsValidHost(hostport string) (ok bool, err error)
- func NewIdler(interval int, isClient bool) *idler
- func NewPushbackInputStream(conn net.Conn) *pushbackInputStream
- func NewSemaphore(timeoutResult bool) *semaphore
- func ReadFullByLen(len_inByte int, reader io.Reader) (buf []byte, err error)
- func SafeClose(conn net.Conn)
- func SubstringBefore(str, sep string) string
- func SubstringLastBefore(str, sep string) string
- func ThrowErr(e interface{})
- func ThrowIf(condition bool, e interface{})
- type CipherFactory
- type Client
- type Conn
- type ConnPool
- type D5ClientConf
- type D5Params
- type D5ServConf
- type FieldDescriptor
- type Filterable
- type ImportableFieldDesc
- type NullCipherKit
- type RSAKeyPair
- type Server
- type Session
- type SessionContainer
- type SessionMgr
- type TSPriority
- type XORCipherKit
Constants ¶
View Source
const ( DT_PING_INTERVAL = 90 RETRY_INTERVAL = time.Second * 5 REST_INTERVAL = RETRY_INTERVAL )
View Source
const ( CLT_CLOSED int32 = -1 CLT_WORKING int32 = 0 CLT_PENDING int32 = 1 )
View Source
const ( SER_KEY_TYPE = "deblocus/SERVER-PRIVATEKEY" USER_CREDENTIAL_TYPE = "deblocus/CLIENT-CREDENTIAL" WORD_d5p = "D5P" WORD_provider = "Provider" SIZE_UNIT = "BKMG" )
View Source
const ( IPV4 byte = 1 DOMAIN byte = 3 IPV6 byte = 4 S5_VER byte = 5 AUTH_FAILED byte = 0xff TYPE_NEW byte = 0xfb TYPE_DAT byte = 0xf1 )
View Source
const ( GENERAL_SO_TIMEOUT = 10 * time.Second TUN_PARAMS_LEN = 32 DP_LEN1 = 256 DP_P2I = 256 + 8 DP_MOD = 65536 TIME_STEP = 60 // seconds TIME_ERROR = 1 // minutes REQ_PROT_UNKNOWN = 1 REQ_PROT_SOCKS5 = 2 REQ_PROT_HTTP = 3 REQ_PROT_HTTP_T = 4 NULL = "" CRLF = "\r\n" IDENTITY_SEP = "\x00" HTTP_PROXY_VER_LINE = "HTTP/1.1 200 Connection established" HTTP_PROXY_AGENT = "Proxy-Agent: " )
View Source
const ( // frame action 8bit FRAME_ACTION_CLOSE uint8 = 0x0 FRAME_ACTION_CLOSE_R = 0x1 FRAME_ACTION_CLOSE_W = 0x2 FRAME_ACTION_OPEN = 0x10 FRAME_ACTION_OPEN_Y = 0x11 FRAME_ACTION_OPEN_N = 0x12 FRAME_ACTION_OPEN_DENIED = 0x13 FRAME_ACTION_SLOWDOWN = 0x20 FRAME_ACTION_DATA = 0x21 FRAME_ACTION_PING = 0x30 FRAME_ACTION_PONG = 0x31 FRAME_ACTION_TOKENS = 0x40 FRAME_ACTION_TOKEN_REQUEST = 0x41 FRAME_ACTION_TOKEN_REPLY = 0x42 FRAME_ACTION_DNS_REQUEST = 0x51 FRAME_ACTION_DNS_REPLY = 0x52 )
View Source
const ( FAST_OPEN = true FAST_OPEN_BUF_MAX_SIZE = 1 << 13 // 8k )
View Source
const ( WAITING_OPEN_TIMEOUT = time.Second * 30 READ_TMO_IN_FASTOPEN = time.Millisecond * 1500 FRAME_HEADER_LEN = 5 FRAME_MAX_LEN = 0xffff MUX_PENDING_CLOSE = -1 MUX_CLOSED = -2 )
View Source
const ( // idle error type ERR_PING_TIMEOUT = 0xe ERR_NEW_PING = 0xf ERR_UNKNOWN = 0x0 )
View Source
const ( TCP_CLOSE_R uint32 = 1 TCP_CLOSE_W uint32 = 1 << 1 TCP_CLOSED uint32 = TCP_CLOSE_R | TCP_CLOSE_W )
View Source
const ( // close code CLOSED_FORCE = iota CLOSED_WRITE CLOSED_BY_ERR )
View Source
const ( GENERATE_TOKEN_NUM = 4 TOKENS_FLOOR = 2 PARALLEL_TUN_QTY = 2 TKSZ = sha1.Size )
View Source
const (
Bye = syscall.Signal(0xfffb8e)
)
View Source
const (
TICKER_INTERVAL = time.Second * 15
)
Variables ¶
View Source
var ( ZERO_TIME = time.Time{} SIZEOF_INT int )
View Source
var ( FILE_NOT_FOUND = exception.NewW("File not found") FILE_EXISTS = exception.NewW("File is already exists") INVALID_D5P_FRAGMENT = exception.NewW("Invalid d5p fragment") INVALID_D5C_FILE = exception.NewW("Invalid d5c file format") INVALID_D5S_FILE = exception.NewW("Invalid d5s file format") UNRECOGNIZED_SYMBOLS = exception.NewW("Unrecognized symbols") UNRECOGNIZED_DIRECTIVES = exception.NewW("Unrecognized directives") LOCAL_BIND_ERROR = exception.NewW("Local bind error") CONF_MISS = exception.NewW("Missed config") CONF_ERROR = exception.NewW("Error config") )
View Source
var ( // for main package injection VERSION uint32 VER_STRING string DEBUG bool )
View Source
var ( // socks5 exceptions INVALID_SOCKS5_HEADER = exception.New(0xff, "Invalid socks5 header") INVALID_SOCKS5_REQUEST = exception.New(0x07, "Invalid socks5 request") GENERAL_FAILURE = exception.New(0x01, "General failure") HOST_UNREACHABLE = exception.New(0x04, "Host is unreachable") )
View Source
var ( // D5 exceptions INVALID_D5PARAMS = exception.NewW("Invalid D5Params") D5SER_UNREACHABLE = exception.NewW("D5Server is unreachable") VALIDATION_FAILED = exception.NewW("Validation failed") NEGOTIATION_FAILED = exception.NewW("Negotiation failed") DATATUN_SESSION = exception.NewW("DT") INCONSISTENT_HASH = exception.NewW("Inconsistent hash") INCOMPATIBLE_VERSION = exception.NewW("Incompatible version") UNRECOGNIZED_REQ = exception.NewW("Unrecognized Request") )
View Source
var (
UNSUPPORTED_CIPHER = exception.NewW("Unsupported cipher")
)
Functions ¶
func CreateClientConfig ¶
func CreateClientConfig(file string, d5s *D5ServConf, user string) (e error)
public for external throws
func DetectFile ¶
func DetectRunAsServ ¶
func DetectRunAsServ() bool
func GenerateD5sTemplate ¶
func GetAvailableCipher ¶
func IdentifierOf ¶
func IsNotExist ¶
func IsValidHost ¶
func NewPushbackInputStream ¶
func NewSemaphore ¶
func NewSemaphore(timeoutResult bool) *semaphore
func ReadFullByLen ¶
len_inByte: first segment length of bytes, enum: 1,2,4
func SubstringBefore ¶
func SubstringLastBefore ¶
Types ¶
type CipherFactory ¶
type CipherFactory struct {
// contains filtered or unexported fields
}
func NewCipherFactory ¶
func NewCipherFactory(name string, secret []byte) *CipherFactory
func (*CipherFactory) InitCipher ¶
func (c *CipherFactory) InitCipher(iv []byte) *XORCipherKit
type Client ¶
type Client struct { State int32 // contains filtered or unexported fields }
func (*Client) ClientServe ¶
type Conn ¶
func (*Conn) CloseWrite ¶
func (c *Conn) CloseWrite()
func (*Conn) SetSockOpt ¶
bool: disableDeadline int8: minutes of KeepAlivePeriod, zero to disable bool: noDelay
type ConnPool ¶
type ConnPool struct {
// contains filtered or unexported fields
}
func NewConnPool ¶
func NewConnPool() *ConnPool
type D5ClientConf ¶
type D5ClientConf struct { Listen string `importable:":9009"` Verbose int `importable:"1"` ListenAddr *net.TCPAddr // contains filtered or unexported fields }
client config definitions
type D5Params ¶
type D5Params struct {
// contains filtered or unexported fields
}
d5p
func (*D5Params) RemoteName ¶
type D5ServConf ¶
type D5ServConf struct { Listen string `importable:":9008"` Auth string `importable:"file://_USER_PASS_FILE_PATH_"` Cipher string `importable:"AES128CFB"` ServerName string `importable:"SERVER_NAME"` Verbose int `importable:"1"` DenyDest string `importable:"OFF"` AuthSys auth.AuthSys ListenAddr *net.TCPAddr // contains filtered or unexported fields }
Server config definitions
type FieldDescriptor ¶
type FieldDescriptor struct {
// contains filtered or unexported fields
}
type Filterable ¶
filter interface ,eg. GeoFilter
type ImportableFieldDesc ¶
type ImportableFieldDesc map[string]*FieldDescriptor
type NullCipherKit ¶
type NullCipherKit byte
type RSAKeyPair ¶
type RSAKeyPair struct {
// contains filtered or unexported fields
}
func GenerateRSAKeyPair ¶
func GenerateRSAKeyPair(keyBits int) *RSAKeyPair
func (*RSAKeyPair) Decrypt ¶
func (k *RSAKeyPair) Decrypt(src []byte) (plain []byte, err error)
single block decrypt
func (*RSAKeyPair) Encrypt ¶
func (k *RSAKeyPair) Encrypt(src []byte) (enc []byte, err error)
single block encrypt RSA1024-OAEP_sha1: msg.length <= 86byte RSA2048-OAEP_sha1: msg.length <= 214byte
func (*RSAKeyPair) SharedKey ¶
func (k *RSAKeyPair) SharedKey() []byte
type Server ¶
type Server struct { *D5ServConf // contains filtered or unexported fields }
Server
func (*Server) TunnelServe ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session
func NewSession ¶
func NewSession(tun *Conn, cf *CipherFactory, n *dbcSerNego) *Session
func (*Session) DataTunServe ¶
type SessionContainer ¶
type SessionMgr ¶
type SessionMgr struct {
// contains filtered or unexported fields
}
SessionMgr
func NewSessionMgr ¶
func NewSessionMgr() *SessionMgr
type TSPriority ¶
type TSPriority struct {
// contains filtered or unexported fields
}
type XORCipherKit ¶
type XORCipherKit struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.