Documentation
¶
Index ¶
- Constants
- Variables
- func CreateClientCredential(file string, d5s *D5ServConf, user string) (e error)
- func DetectFile(isServ bool) (string, bool)
- func DetectRunAsServ() bool
- func Generate_d5sFile(file string, d5sConf *D5ServConf) (e error)
- func GetConnIdentifier(con net.Conn) string
- func IsNotExist(file string) bool
- func Pipe(dst, src net.Conn, sid int32, ctl *CtlThread)
- func RSADecrypt(src []byte, priv *rsa.PrivateKey) (plain []byte, err error)
- func RSAEncrypt(src []byte, pub *rsa.PublicKey) (enc []byte, err error)
- func ReadFullByLen(len_inByte int, reader io.Reader) (buf []byte, err error)
- func SafeClose(conn net.Conn)
- func ThrowErr(e interface{})
- func ThrowIf(condition bool, e interface{})
- type Cipher
- type CipherFactory
- type Client
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) CloseRead()
- func (c *Conn) CloseWrite()
- func (c *Conn) FreeHash()
- func (c *Conn) RHashSum() []byte
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) SetSockOpt(disableDeadline, keepAlive, noDelay int8)
- func (c *Conn) WHashSum() []byte
- func (c *Conn) Write(b []byte) (int, error)
- type CtlCommandHandler
- type CtlExitHandler
- type CtlThread
- type D5ClientConf
- type D5Params
- type D5ServConf
- type DHKeyPair
- type FieldDescriptor
- type ImportableFieldDesc
- type RSAKeyPair
- type S5Step1
- type S5Target
- type Server
- type Session
- type SessionCtType
- type SessionMgr
Constants ¶
View Source
const ( D5 = 0xd5 IPV4 = byte(1) DOMAIN = byte(3) IPV6 = byte(4) SOCKS5_VER = byte(5) NULL = "" DMLEN = 384 TT_TOKEN_OFFSET = SzTk + 2 GENERAL_SO_TIMEOUT = 10 * time.Second TUN_PARAMS_LEN = 32 TP_INTERVAL_OFS = 4 )
View Source
const ( GENERATE_TOKEN_NUM = 64 SzTk = sha1.Size CMD_HEADER_LEN = 16 CTL_PING = byte(1) CTL_PONG = byte(2) TOKEN_REQUEST = byte(5) TOKEN_REPLY = byte(6) CTL_PING_INTERVAL = uint16(60) // time.Second )
View Source
const ( Bye = syscall.Signal(0xfffb8e) SER_KEY_TYPE = "deblocus/SERVER-PRIVATEKEY" USER_CREDENTIAL_TYPE = "deblocus/CLIENT-CREDENTIAL" WORD_d5p = "D5P" WORD_provider = "Provider" SIZE_UNIT = "BKMG" )
Variables ¶
View Source
var ( VERSION uint32 // 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") // 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") TRANS_SESSION = exception.NewW("TT") HASH_INCONSISTENCE = exception.NewW("Hash inconsistence") INCOMPATIBLE_VERSION = exception.NewW("Incompatible version") )
View Source
var ( ZERO_TIME = time.Time{} 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 (
UNSUPPORTED_CIPHER = exception.NewW("Unsupported cipher method")
)
Functions ¶
func CreateClientCredential ¶
func CreateClientCredential(file string, d5s *D5ServConf, user string) (e error)
public for external
func DetectFile ¶
func DetectRunAsServ ¶
func DetectRunAsServ() bool
func Generate_d5sFile ¶
func Generate_d5sFile(file string, d5sConf *D5ServConf) (e error)
func GetConnIdentifier ¶
func IsNotExist ¶
func RSADecrypt ¶
func RSADecrypt(src []byte, priv *rsa.PrivateKey) (plain []byte, err error)
single block decrypt
func RSAEncrypt ¶
single block encrypt OAEP: must be less than 86byte base on RSA1024-OAEP_sha1
func ReadFullByLen ¶
read by the first segment indicated the following segment length len_inByte: first segment length in byte
Types ¶
type CipherFactory ¶
type CipherFactory struct {
// contains filtered or unexported fields
}
func NewCipherFactory ¶
func NewCipherFactory(id int, secret []byte) *CipherFactory
func (*CipherFactory) NewCipher ¶
func (c *CipherFactory) NewCipher(iv []byte) *Cipher
type Client ¶
type Client struct { State int32 // -1:aborted 0:working 1:token requesting // contains filtered or unexported fields }
func NewClient ¶
func NewClient(d5p *D5Params, dhKeys *DHKeyPair, exitHandler CtlExitHandler) *Client
func (*Client) ClientServe ¶
type Conn ¶
func NewConnWithHash ¶
func (*Conn) CloseWrite ¶
func (c *Conn) CloseWrite()
func (*Conn) SetSockOpt ¶
type CtlCommandHandler ¶
type CtlExitHandler ¶
type CtlExitHandler func()
type CtlThread ¶
type CtlThread struct {
// contains filtered or unexported fields
}
func NewCtlThread ¶
type D5ClientConf ¶
type D5ClientConf struct { Listen string `importable:":9009"` Verbose int `importable:"2"` ListenAddr *net.TCPAddr D5PList []*D5Params }
client
type D5Params ¶
type D5Params struct {
// contains filtered or unexported fields
}
d5p
func (*D5Params) RemoteIdFull ¶
type D5ServConf ¶
type D5ServConf struct { Listen string `importable:":9008"` AuthTable string `importable:"file:///PATH/YOUR_AUTH_FILE_PATH"` Algo string `importable:"AES128CFB"` ServerName string `importable:"SERVER_INDENTIFIER"` Verbose int `importable:"2"` AlgoId int AuthSys auth.AuthSys RSAKeys *RSAKeyPair ListenAddr *net.TCPAddr }
Server
type DHKeyPair ¶
type DHKeyPair struct {
// contains filtered or unexported fields
}
func GenerateDHKeyPairs ¶
func GenerateDHKeyPairs() *DHKeyPair
type FieldDescriptor ¶
type FieldDescriptor struct {
// contains filtered or unexported fields
}
type ImportableFieldDesc ¶
type ImportableFieldDesc map[string]*FieldDescriptor
type RSAKeyPair ¶
type RSAKeyPair struct {
// contains filtered or unexported fields
}
func GenerateRSAKeyPair ¶
func GenerateRSAKeyPair() *RSAKeyPair
type S5Step1 ¶
type S5Step1 struct {
// contains filtered or unexported fields
}
socks5 protocol step1 on client side
func (*S5Step1) HandshakeAck ¶
type Server ¶
type Server struct { *D5ServConf // contains filtered or unexported fields }
func NewServer ¶
func NewServer(d5s *D5ServConf, dhKeys *DHKeyPair) *Server
func (*Server) TransServe ¶
func (*Server) TunnelServe ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession(tun *Conn, cf *CipherFactory, identity string) *Session
type SessionCtType ¶
type SessionMgr ¶
type SessionMgr struct {
// contains filtered or unexported fields
}
func NewSessionMgr ¶
func NewSessionMgr() *SessionMgr
Click to show internal directories.
Click to hide internal directories.