Documentation ¶
Index ¶
- Constants
- Variables
- func FixHash(b []byte) []byte
- func GenerateRandomBytes(n int) ([]byte, error)
- func Info(format string, v ...interface{})
- func MsgPoolInit()
- func SetLevel(l int)
- func UnpackUdp(msg *Msg, uBuf []byte) error
- func UnpackUdpMsg(block cipher.Block, iv []byte, msg *Msg, rBuf []byte) error
- func Warn(format string, v ...interface{})
- func WriteTcpMsg(c net.Conn, m *Msg) error
- func WriteTcpReal(seq uint16, typ uint8, from uint8, lport uint16, o interface{}, c net.Conn) error
- func WriteUdpConnOnly(block cipher.Block, iv []byte, data []byte, dest *net.UDPAddr, ...) error
- func WriteUdpMsg(block cipher.Block, iv []byte, m *Msg, dest *net.UDPAddr, udpConn *net.UDPConn) error
- func WriteUdpMsgServer(m *Msg, addr *net.UDPAddr, udpConn *net.UDPConn) error
- type Future
- type FutureCallback
- type FutureChainFunction
- type FutureResp
- type Msg
- type MsgAssistReg
- type MsgBuf
- type MsgClientQuit
- type MsgHandshake
- type MsgHdr
- type MsgHook
- type MsgHooker
- type MsgP2pPing
- type MsgP2pPong
- type MsgPool
- type MsgReg
- type MsgRegResp
- type MsgReqAddr
- type MsgTcpPong
- type MsgUdpPong
- type Promise
- type PromiseTask
- type TunnelItem
Constants ¶
View Source
const ( MsgTypeReq = 1 MsgTypeUdpPing = 2 MsgTypeUdpPong = 3 MsgTypeAddrReq = 4 MsgTypeAddrResp = 5 MsgTypeHandshake = 6 MsgTypeP2pPing = 7 MsgTypeP2pPong = 8 MsgTypeRegResp = 9 MsgTypeP2pTest = 10 MsgTypeIPChange = 11 MsgTypeUdpValid = 12 MsgTypeDoShake = 13 MsgTypeTcpPing = 14 MsgTypeTcpPong = 15 MsgTypeAssistReg = 16 MsgTypeAssistResp = 17 MsgTypeAssPing = 18 MsgTypeAssPong = 19 MsgTypeClientQuit = 20 MsgTypeIkcp = 100 MsgTypeSyn = 101 MsgTypeSynOk = 102 MsgTypeSynErr = 103 MsgTypeFin = 104 MsgTypeData = 105 MsgHdrSize = 8 KindListen = "listen" MessageSeqSize = 128 MsgSizeSmall = 1024 MsgSizeBig = 2600 EncryptSize = 16 MsgCtlSize = 16 MsgXor = 0x9C UdpPongTypeTwoServer = 0 UdpPongTypeFromAss = 1 UdpPongTypeOneServer = 3 TcpTickCount = 20 TcpTimeoutSecCount = 3 * TcpTickCount TcpTimeoutSec = time.Second * TcpTimeoutSecCount TcpAssPingSec = time.Second * TcpTickCount TcpAssReadLoopSec = TcpTimeoutSec TcpAssWriteLoopSec = time.Second * TcpTickCount TcpClientPingSec = time.Second * TcpTickCount TcpClientReadLoopSec = TcpTimeoutSec TcpClientWriteLoopSec = time.Second * TcpTickCount UdpP2pPingTick = 5 UdpP2pPingSec = time.Second * UdpP2pPingTick UdpP2pPingTimeout = time.Second * UdpP2pPingTick * 2 UdpP2pPingClose = UdpP2pPingTimeout * 3 AssPass = "" )
Variables ¶
View Source
var ( ErrFinished = errors.New("killable: finished") ErrTargetDying = errors.New("killable: targetDying") ErrPromiseEmpty = errors.New("promise: emptyFuture") ErrPromiseNotResolve = errors.New("promise: notResolve") ErrPromiseResolving = errors.New("promise: resolving") ErrPromisePDying = errors.New("promise: parentDying") )
View Source
var ( ErrMsgRegExists = errors.New("message: registNameExists") ErrMsgRegNotFound = errors.New("message: registNameNotFound") ErrMsgWrite = errors.New("message: writeMessageError") ErrMsgRead = errors.New("message: readMessageError") ErrMsgSpaceExit = errors.New("message: spaceExit") ErrMsgKilled = errors.New("message: killedByOther") ErrMsgRealEmpty = errors.New("message: empty real") ErrMsgNotSupport = errors.New("message: notSupport") ErrMsgNone = errors.New("message: none") ErrMsgShakeTimeout = errors.New("message: shakeTimeout") ErrMsgPanic = errors.New("message: Panic") )
Functions ¶
func GenerateRandomBytes ¶
func MsgPoolInit ¶
func MsgPoolInit()
func UnpackUdpMsg ¶
https://golang.org/src/crypto/cipher/example_test.go http://studygolang.com/articles/1829
func WriteTcpReal ¶
func WriteUdpConnOnly ¶
func WriteUdpConnOnly(block cipher.Block, iv []byte, data []byte, dest *net.UDPAddr, udpConn *net.UDPConn) error
write ikcp data
func WriteUdpMsg ¶
Types ¶
type Future ¶
type Future struct { Resp chan *FutureResp Task PromiseTask Arg interface{} F FutureCallback }
type FutureCallback ¶
type FutureCallback func(in *Future, arg interface{}) *FutureResp
func WrapFuture ¶
func WrapFuture(f FutureChainFunction) FutureCallback
type FutureChainFunction ¶
type FutureChainFunction func(pt PromiseTask, arg interface{}) (PromiseTask, interface{}, error)
type FutureResp ¶
type FutureResp struct {
// contains filtered or unexported fields
}
type Msg ¶
type Msg struct { Hdr MsgHdr Real interface{} V interface{} // contains filtered or unexported fields }
FIXME: origin CANOT makeSlice
func (*Msg) ResetBuffer ¶
Ignore the prefix buffer and request a new. Caution for this func, should only use one time at first !!!
type MsgAssistReg ¶
type MsgClientQuit ¶
type MsgClientQuit struct {
ClientId int
}
type MsgHandshake ¶
type MsgHook ¶
func NewMsgHook ¶
type MsgP2pPing ¶
type MsgP2pPing struct {
From int
}
type MsgP2pPong ¶
type MsgP2pPong struct {
From int
}
type MsgReg ¶
type MsgReg struct { Name string Pass string Kind string Items []TunnelItem Iv string }
type MsgRegResp ¶
type MsgRegResp struct { ClientId int IP string Items []TunnelItem Iv string Status string }
type MsgReqAddr ¶
type MsgReqAddr struct { From int To int FromPub string FromPub2 string FromAddrs []string ToPub string ToPub2 string Addrs []string }
NewHandshake, send from tcp channel
type MsgTcpPong ¶
type MsgTcpPong struct { }
type MsgUdpPong ¶
type Promise ¶
Not real promise but like promise
func NewPromise ¶
func (*Promise) Resolve ¶
func (p *Promise) Resolve(pt PromiseTask, v interface{}) *Promise
func (*Promise) Then ¶
func (p *Promise) Then(f FutureChainFunction) *Promise
type PromiseTask ¶
type TunnelItem ¶
Click to show internal directories.
Click to hide internal directories.