Documentation ¶
Index ¶
- Constants
- func CheckMAC(message, messageMAC, key []byte) bool
- func GenerateRSAKey(bits int, path string) (*rsa.PrivateKey, error)
- func LoadRSAPrivateKey(path string) (*rsa.PrivateKey, error)
- func LoadRSAPublicKey(path string) (*rsa.PublicKey, error)
- func LoadYamlConfig(path string, obj interface{}) error
- func MakeCryptoKeyIV(password []byte, key_size, iv_size int) ([]byte, []byte)
- func ReadN2(bs []byte, offset int) uint16
- func ReadN4(bs []byte, offset int) uint32
- func WriteN2(bs []byte, offset int, n uint16)
- func WriteN4(bs []byte, offset int, n uint32)
- type AESCipherMaker
- type CipherConfig
- type CipherContext
- func (ctx *CipherContext) CalcKey(ef *big.Int)
- func (ctx *CipherContext) MakeCryptoKeyIV(key_size, iv_size int) ([]byte, []byte)
- func (ctx *CipherContext) MakeE() (*big.Int, error)
- func (ctx *CipherContext) MakeEF(minval int64) (*big.Int, error)
- func (ctx *CipherContext) MakeF() (*big.Int, error)
- func (ctx *CipherContext) MakeSessionId() (SessionId, error)
- type CipherExchangeInit
- type Client
- type ClientConfig
- type ClientProxy
- type ClientTunnel
- type ConnManager
- type DESCipherMaker
- type GlobalCipherConfig
- type LoginRequest
- type LoginResponse
- type RC4CipherMaker
- type ReuseSession
- type Server
- type ServerConfig
- type Session
- type SessionId
- type SessionManager
- type SockChan
- type StreamPipe
- type UserConfig
- type UserConfigs
Constants ¶
View Source
const ( B_TRUE byte = 1 B_FALSE byte = 0 PROTO_MAGIC = 'P' PROTO_VERSION = 1 PACKET_NEW_CONN = 1 PACKET_PROXY = 2 PACKET_CLOSE_CONN = 3 PROTO_ADDR_IP byte = 1 PROTO_ADDR_DOMAIN byte = 2 REUSE_SUCCESS = 0 REUSE_FAIL_HMAC_FAIL = 1 REUSE_FAIL_SYS_ERR = 2 REUSE_FAIL_START_CIPHER_EXCHANGE = 0x10 )
Variables ¶
This section is empty.
Functions ¶
func GenerateRSAKey ¶
func GenerateRSAKey(bits int, path string) (*rsa.PrivateKey, error)
func LoadRSAPrivateKey ¶
func LoadRSAPrivateKey(path string) (*rsa.PrivateKey, error)
func LoadYamlConfig ¶
func MakeCryptoKeyIV ¶
Types ¶
type CipherConfig ¶
type CipherConfig struct { Name string KeySize int IVSize int // contains filtered or unexported fields }
func GetCipherConfig ¶
func GetCipherConfig(name string) *CipherConfig
type CipherContext ¶
type CipherContext struct { P *big.Int G int XY *big.Int EF *big.Int Key *big.Int CryptoKey []byte // fixed size key, for cipher IV []byte }
func MakeCipherContext ¶
func MakeCipherContext(p *big.Int, g int) *CipherContext
func NewCipherContext ¶
func NewCipherContext(group int) (*CipherContext, error)
func (*CipherContext) CalcKey ¶
func (ctx *CipherContext) CalcKey(ef *big.Int)
func (*CipherContext) MakeCryptoKeyIV ¶
func (ctx *CipherContext) MakeCryptoKeyIV(key_size, iv_size int) ([]byte, []byte)
func (*CipherContext) MakeSessionId ¶
func (ctx *CipherContext) MakeSessionId() (SessionId, error)
type CipherExchangeInit ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
func (*Client) DoDomainProxy ¶
func (cli *Client) DoDomainProxy(domain string, port int, rw io.ReadWriteCloser)
type ClientConfig ¶
type ClientConfig struct { ServerAddr string SocksListenAddr string RedirListenAddr string DNSListenAddr string DNSListenOnTCP bool DNSRemoteAddr string GlobalEncryptMethod string GlobalEncryptPassword string LinkEncryptMethods []string ServerPublicKeyPath string Username string Password string }
func LoadClientConfig ¶
func LoadClientConfig(path string) (*ClientConfig, error)
type ClientProxy ¶
type ClientProxy struct {
// contains filtered or unexported fields
}
func NewClientProxy ¶
func NewClientProxy(session *Session, pipe *StreamPipe) *ClientProxy
func (*ClientProxy) DoProxy ¶
func (cp *ClientProxy) DoProxy()
type ClientTunnel ¶
type ClientTunnel struct {
// contains filtered or unexported fields
}
func NewClientTunnel ¶
func NewClientTunnel(cli *Client) *ClientTunnel
func (*ClientTunnel) Init ¶
func (ct *ClientTunnel) Init() error
type ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
func NewConnManager ¶
func NewConnManager(write_ch chan []byte) *ConnManager
func (*ConnManager) CloseAllConns ¶
func (cm *ConnManager) CloseAllConns()
func (*ConnManager) CloseConn ¶
func (cm *ConnManager) CloseConn(conn_id uint32)
func (*ConnManager) DoProxy ¶
func (cm *ConnManager) DoProxy(conn_type byte, addr []byte, port int, rw io.ReadWriteCloser)
func (*ConnManager) WriteToLocalConn ¶
func (cm *ConnManager) WriteToLocalConn(conn_id uint32, data []byte)
type DESCipherMaker ¶
type DESCipherMaker struct {
// contains filtered or unexported fields
}
func (*DESCipherMaker) NewStreamCipher ¶
type GlobalCipherConfig ¶
type GlobalCipherConfig struct { Config *CipherConfig Key []byte IV []byte }
func LoadGlobalCipherConfig ¶
func LoadGlobalCipherConfig(name string, passwd []byte) (*GlobalCipherConfig, error)
type LoginRequest ¶
type LoginResponse ¶
type ReuseSession ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config *ServerConfig) (*Server, error)
type ServerConfig ¶
type ServerConfig struct { ListenAddr string GlobalEncryptMethod string GlobalEncryptPassword string LinkEncryptMethods []string UserConfigPath string KeyPath string }
func LoadServerConfig ¶
func LoadServerConfig(path string) (*ServerConfig, error)
type Session ¶
type Session struct { Id SessionId Username string CipherCtx *CipherContext CipherConfig *CipherConfig }
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (*SessionManager) DelSession ¶
func (mgr *SessionManager) DelSession(sid SessionId)
func (*SessionManager) GetSession ¶
func (mgr *SessionManager) GetSession(sid SessionId) *Session
func (*SessionManager) NewSession ¶
func (mgr *SessionManager) NewSession(ctx *CipherContext) (*Session, error)
type StreamPipe ¶
type StreamPipe struct {
// contains filtered or unexported fields
}
func NewStreamPipe ¶
func NewStreamPipe(rw io.ReadWriteCloser) *StreamPipe
func (*StreamPipe) Close ¶
func (pipe *StreamPipe) Close() error
func (*StreamPipe) SwitchCipher ¶
func (pipe *StreamPipe) SwitchCipher(enc, dec cipher.Stream)
type UserConfig ¶
type UserConfig struct {
Password string
}
type UserConfigs ¶
type UserConfigs struct {
// contains filtered or unexported fields
}
func GetUserConfigs ¶
func GetUserConfigs(path string) (*UserConfigs, error)
func (*UserConfigs) Get ¶
func (cfgs *UserConfigs) Get(user string) *UserConfig
func (*UserConfigs) Reload ¶
func (cfgs *UserConfigs) Reload() error
Click to show internal directories.
Click to hide internal directories.