Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToUint16(bs []byte) uint16
- func BytesToUint64(bs []byte) uint64
- func DecryptAesCfb256(encrypted []byte, aesCipher cipher.Block) (decrypted []byte)
- func DecryptRsa(ciphertext []byte, priKey []byte) ([]byte, error)
- func EncryptAesCfb256(origData []byte, aesCipher cipher.Block) (encrypted []byte)
- func EncryptRsa(origData []byte, pubKey []byte) ([]byte, error)
- func GenerateAes256Key() [32]byte
- func MapperAhriAddrName(atyp byte, byteAddr []byte, mapper map[string]string) string
- func NetAddrString(ip, port string) string
- func NewByteArrPool(sizeLimit int) *byteArrPool
- func ParseAddrCtxMapper(lines []string, ahriHostsPath string) map[string]string
- func Uint16ToBytes(n uint16) []byte
- func Uint64ToBytes(n uint64) []byte
- func ValidIp(ip string) bool
- func ValidPort(port string) bool
- type AhriAddr
- type AhriClient
- type AhriConn
- func (conn *AhriConn) Close() error
- func (conn *AhriConn) Id() string
- func (conn *AhriConn) LocalAddr() net.Addr
- func (conn *AhriConn) Read(b []byte) (n int, err error)
- func (conn *AhriConn) RemoteAddr() net.Addr
- func (conn *AhriConn) SetDeadline(t time.Time) error
- func (conn *AhriConn) SetLinger(sec int) error
- func (conn *AhriConn) SetReadDeadline(t time.Time) error
- func (conn *AhriConn) SetWriteDeadline(t time.Time) error
- func (conn *AhriConn) Write(b []byte) (n int, err error)
- type AhriFrame
- type AhriServer
- type AhriSocks5Server
- type Alog
- func (a *Alog) Crash(log string)
- func (a *Alog) Crashf(format string, args ...interface{})
- func (a *Alog) Debug(log string)
- func (a *Alog) Debugf(format string, args ...interface{})
- func (a *Alog) Deny(level LogLevel) bool
- func (a *Alog) Error(log string)
- func (a *Alog) Errorf(format string, args ...interface{})
- func (a *Alog) Info(log string)
- func (a *Alog) Infof(format string, args ...interface{})
- func (a *Alog) NoLevel(log string)
- func (a *Alog) NoLevelf(format string, args ...interface{})
- func (a *Alog) Warn(log string)
- func (a *Alog) Warnf(format string, args ...interface{})
- type LogLevel
- type Logger
Constants ¶
const ( // the timeout of a socks5 requester shake with an AhriSocks5Server. Socks5ShakeTimeoutMillisec = 400 // the timeout of an AhriClient registers itself with an AhriServer. AhriShakeTimeoutSec = 3 // the maximum number of proxy frames that an AhriClientPartner can save in a special golang channel. AhriClientPartnerProxyFrameMaxSize = 10240 // the maximum number of proxy frames that an AhriServer can save in a special golang channel. AhriServerProxyFrameMaxSize = AhriClientPartnerProxyFrameMaxSize * 20 // Addr Type Socks5AddrTypeIPv4 = 0x01 Socks5AddrTypeDomain = 0x03 Socks5AddrTypeIPv6 = 0x04 // Client Mode: 'Take': Serviced, 'Give': Service provider, 'Trader': Both AhriClientModeTake = 0 AhriClientModeGive = 1 AhriClientModeTrade = 2 // Special Addr Name AhriAddrNameLocal = "L" AhriAddrNameAhriServer = "S" AhriAddrNameForbidden = "-" AhriAddrNameIntercept = "|" // ARP ACK ArpAckOk = 0x00 ArpAckWrongPassword = 0x01 ArpAckClientNameIsAlreadyRegistered = 0x02 ArpAckUnknownMode = 0x03 ArpAckIllegalAesPassword = 0x04 // AFP AfpFlag = 0x24 AfpHeaderLen = 16 AfpFrameMaxLen = 4096 AfpPayloadMaxLen = AfpFrameMaxLen - AfpHeaderLen // AFP Frame type AfpFrameTypeHeartbeat = 0x00 AfpFrameTypeDirect = 0x01 AfpFrameTypeProxy = 0x02 AfpFrameTypeDial = 0x03 AfpFrameTypeDialAck = 0x04 AfpFrameTypeDialProxy = 0x05 AfpFrameTypeDialProxyAck = 0x06 // AFP ACK AfpAckOk = 0x00 AfpAckErr = 0x01 // ignore errors IgnoreErrorSendOnClosedChannel = "send on closed channel" IgnoreErrorInvalidMemoryAddress = "runtime error: invalid memory address or nil pointer dereference" )
const Version = "0.9.3"
Variables ¶
var ( Log Logger Debug Logger ByteArrPool = NewByteArrPool(AfpFrameMaxLen) // the timeout of one-way communication time interval between an AhriClient and an AhriServer; // AhriClient.Dial().timeout = 3 * AhriTimeoutSec // heartbeat timeout = 2 * AhriTimeoutSec AhriTimeoutSec int NoDeadline = time.Time{} // Socks5 ACK Socks5NoAcceptableMethods []byte Socks5SecretFree []byte Socks5ConnectionNotAllowedByRuleset []byte Socks5UnsupportedCommand []byte Socks5UnsupportedAddressType []byte Socks5Success []byte )
Functions ¶
func BytesToUint16 ¶
func BytesToUint64 ¶
func DecryptAesCfb256 ¶
=================== AES-256-CFB Decrypt ====================== quote from this url(https://blog.csdn.net/u012978258/article/details/87868999)
func DecryptRsa ¶
=================== RSA Encrypt ====================== quote from this url(http://www.361way.com/golang-rsa-aes/5828.html)
func EncryptAesCfb256 ¶
=================== AES-256-CFB Encrypt ====================== quote from this url(https://blog.csdn.net/u012978258/article/details/87868999)
func EncryptRsa ¶
=================== RSA Encrypt ====================== quote from this url(http://www.361way.com/golang-rsa-aes/5828.html)
func GenerateAes256Key ¶
func GenerateAes256Key() [32]byte
func MapperAhriAddrName ¶
return a ahriAddrName.
func NetAddrString ¶
ip + port ==> format like 127.0.0.1:80, [xx:xx::xx:xx::xx]:80
func NewByteArrPool ¶
func NewByteArrPool(sizeLimit int) *byteArrPool
func ParseAddrCtxMapper ¶
lines: lines of the hosts config file. ahriHostsPath: path of the hosts config file.
func Uint16ToBytes ¶
func Uint64ToBytes ¶
Types ¶
type AhriAddr ¶
type AhriAddr struct {
// contains filtered or unexported fields
}
func (*AhriAddr) ParseDstAddrIP ¶
type AhriClient ¶
type AhriClient struct {
// contains filtered or unexported fields
}
func NewAhriClient ¶
func NewAhriClient(serverIp, serverPort, serverPassword, clientName string, mode int) *AhriClient
func (*AhriClient) Dial ¶
func (client *AhriClient) Dial(addr *AhriAddr, connId uint64) (conn *AhriConn, e error)
func (*AhriClient) Stop ¶
func (client *AhriClient) Stop()
type AhriConn ¶
type AhriConn struct {
// contains filtered or unexported fields
}
当 targetAddr == AhriAddrNameLocal, AhriConn 的行为与 *net.TCPConn 基本一致 当 targetAddr == AhriAddrNameAhriServer 或者目标名, AhriConn 就是一个虚拟连接
func (*AhriConn) RemoteAddr ¶
type AhriServer ¶
type AhriServer struct {
// contains filtered or unexported fields
}
func NewAhriServer ¶
func NewAhriServer(ip, port, password, rsaPriKeyPath, rsaPubKeyPath string) *AhriServer
func (*AhriServer) Stop ¶
func (server *AhriServer) Stop()
type AhriSocks5Server ¶
type AhriSocks5Server struct {
// contains filtered or unexported fields
}
func NewAhriSocks5Server ¶
func NewAhriSocks5Server(socks5IP, socks5Port, ahriHostsPath string, ahriClient *AhriClient) *AhriSocks5Server
func (*AhriSocks5Server) Stop ¶
func (ahriSocks5Server *AhriSocks5Server) Stop()
type Logger ¶
type Logger interface { Deny(LogLevel) bool NoLevel(log string) NoLevelf(format string, args ...interface{}) Debug(log string) Info(log string) Warn(log string) Error(log string) Crash(log string) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Crashf(format string, args ...interface{}) }