Documentation ¶
Index ¶
- Constants
- Variables
- func Decrypt(ciphertext []byte, key []byte) ([]byte, error)
- func Encrypt(plaintext []byte, key []byte) ([]byte, error)
- func ErrAppend(err error, errs ...error) error
- func MustBase64ToBytes(str string) []byte
- func MustMarshal(body interface{}) []byte
- func MustResolveTCPAddr(addr net.Addr) *net.TCPAddr
- func MustUnmarshal(b []byte, body interface{})
- func MustUnmarshalV2(inBody interface{}, outBody interface{})
- func NewId(n int) (str string)
- func Println(conn net.Conn, i ...any)
- func UnmarshalV2(inBody interface{}, outBody interface{}) error
- type ConnMsg
- type Key
- func (k *Key) Decode(i interface{}, data []byte) error
- func (k *Key) Encode(i interface{}) (b [][]byte)
- func (k *Key) GetRawKey() string
- func (k *Key) ReadCMsg(reader *bufio.Reader, skip *atomic.Bool, speed *SpeedTicker) (cMsg ConnMsg, err error)
- func (k *Key) ReadCPacket(reader *bufio.Reader, skip *atomic.Bool) (b []byte, err error)
- func (k *Key) SetMsg(header, id string, code int, data interface{}) [][]byte
- type MashBytes
- type NetworkSpeedTicker
- type NetworkSpeedView
- type OdjClientInfo
- type OdjIdList
- type OdjMsg
- type OdjPing
- type OdjSubOpenReq
- type OdjSubOpenResp
- type OdjSubReq
- type Ping
- type SpeedTicker
- type SubInfo
- type TaskCb
- func (task *TaskCb) KeepWaitCb(timeout time.Duration, cb func(cMsg ConnMsg) error) (err error)
- func (task *TaskCb) NowaitCb(cb func(cMsg ConnMsg) error) error
- func (task *TaskCb) OverTask(err error)
- func (task *TaskCb) SetKeep(keep bool) *TaskCb
- func (task *TaskCb) WaitCb(timeout time.Duration, cb func(cMsg ConnMsg) error) (err error)
- type TaskCbContext
- func (tc *TaskCbContext) Close()
- func (tc *TaskCbContext) NewTaskCb(id string, fn func() error) *TaskCb
- func (tc *TaskCbContext) NewTaskCbCMsg(header string, code int, data interface{}) *TaskCb
- func (tc *TaskCbContext) NewTaskCbCMsgNeedId(header string, id string, code int, data interface{}) *TaskCb
- func (tc *TaskCbContext) ReadCMsg() error
- func (tc *TaskCbContext) SetNoCb(fn func(cMsg ConnMsg))
- func (tc *TaskCbContext) SetWriteLock(lock *sync.Mutex)
- func (tc *TaskCbContext) WriteCMsg(header string, id string, code int, data interface{}) error
Constants ¶
View Source
const ( P2PTcpReset = "P2PTcpReset" P2PTcpStart = "P2PTcpStart" P2PTCpSucceed = "P2PTCpSucceed" P2PTCpFailed = "P2PTCpSucceed" )
View Source
const ( SubOpenTypeDefault = "SubOpenTypeDefault" SubOpenTypeTCPP2P = "SubOpenTypeTCPP2P" )
View Source
const (
BufferSize = 4096
)
bytes size = 4096 data len 4004=4096-8-60-8-16
View Source
const DelayA = "DelayA"
View Source
const DelayQ = "DelayQ"
View Source
const HandshakeCheckStepA1 = "Hi! What's your Info?"
View Source
const HandshakeCheckStepA2 = "OK! Happy handshake"
View Source
const HandshakeCheckStepQ1 = "Hello! I want to shake hands."
View Source
const HandshakeCheckStepQ2 = "Here it is"
View Source
const P2PTcpA1 = "P2PTcpA1"
View Source
const P2PTcpA2 = "P2PTcpA2"
View Source
const P2PTcpA3 = "P2PTcpA3"
View Source
const P2PTcpQ1 = "P2PTcpQ1"
View Source
const P2PTcpQ2 = "P2PTcpQ2"
View Source
const P2PTcpQ3 = "P2PTcpQ3"
View Source
const PingMsg = "Ping"
View Source
const PongMsg = "Pong"
View Source
const SOpenA = "sOpenA"
View Source
const SOpenQ = "sOpenQ"
View Source
const SpeedA0 = "SpeedA0"
View Source
const SpeedA1 = "SpeedA1"
View Source
const SpeedA2 = "SpeedA2"
View Source
const SpeedA3 = "SpeedA3"
View Source
const SpeedQ0 = "SpeedQ0" //server all network speed
View Source
const SpeedQ1 = "SpeedQ1" //some client network speed
View Source
const SpeedQ2 = "SpeedQ2" //one client and sub client network speed
View Source
const SpeedQ3 = "SpeedQ3" //only one client network speed
View Source
const TaskA = "TaskA"
View Source
const TaskQ = "TaskQ"
Variables ¶
View Source
var ErrBoxComplexListen = errors.New("box complex listen")
View Source
var ErrBoxIsClosed = errors.New("box is closed")
View Source
var ErrBoxIsNil = errors.New("box is nil")
View Source
var ErrBoxStopListen = errors.New("box stop listen")
View Source
var ErrConnIsNil = errors.New("conn is nil")
View Source
var ErrHandleCMsgMissProxyClient = errors.New("not Not found proxy client ")
View Source
var ErrHandleCMsgMissProxyTaskRoom = errors.New("not Not found proxy task room ")
View Source
var ErrHandleCMsgProxyClientNameIsNil = errors.New("need one proxy client name to register")
View Source
var ErrHandshakeIsDad = errors.New("handshake is bad")
View Source
var ErrIsDisable = errors.New("is disable")
View Source
var ErrKeyIsNot32Bytes = errors.New("key is not 32bytes")
View Source
var ErrNameIsNil = errors.New("name is nil")
View Source
var ErrOpenSubBoxBadAny = func(a ...any) error { return fmt.Errorf("open sub box bad : %v", a) }
View Source
var ErrOpenSubUnexpectedOdj = errors.New("unexpected resp Odj")
View Source
var ErrReadCMsgHashCheckFailed = errors.New("hash check failed")
View Source
var ErrReadCMsgLensTooLong = fmt.Errorf("lens: too long to %v bytes", BufferSize)
View Source
var ErrReadCMsgLensTooShort = fmt.Errorf("lens: too small to %v bytes", getHeaderSize())
View Source
var ErrReadCProtocolIsNotGoCFC = errors.New("the protocol is not go-CFC : is not " + version)
View Source
var ErrReadCSkipToFastConn = errors.New("skip to fastConn")
View Source
var ErrReqBadAny = func(a ...any) error { return fmt.Errorf("req bad : %v", a) }
View Source
var ErrReqUnexpectedHeader = errors.New("unexpected resp header")
View Source
var ErrSubIsDisable = errors.New("sub box is disable")
View Source
var ErrSubLocalAddrIsNil = errors.New("sub local addr is nil")
View Source
var ErrTimeout = errors.New("timeout")
View Source
var ErrUnexpectedSubOpenType = errors.New("unexpected sub open type")
View Source
var TaskCbIdIsNeed = errors.New("task cb id is nil")
View Source
var TaskSkipErr = errors.New("task skip err")
Functions ¶
func MustBase64ToBytes ¶ added in v1.2.1
func MustMarshal ¶
func MustMarshal(body interface{}) []byte
func MustUnmarshal ¶
func MustUnmarshal(b []byte, body interface{})
func MustUnmarshalV2 ¶
func MustUnmarshalV2(inBody interface{}, outBody interface{})
func UnmarshalV2 ¶
func UnmarshalV2(inBody interface{}, outBody interface{}) error
Types ¶
type ConnMsg ¶
func (*ConnMsg) CheckConnMsgHeaderAndCode ¶ added in v1.3.1
func (*ConnMsg) MustUnmarshal ¶ added in v1.3.3
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func (*Key) ReadCPacket ¶ added in v1.3.0
type MashBytes ¶ added in v1.2.1
type MashBytes struct {
Data string `json:"go-CFC-Data"`
}
func MustBytesToBase64 ¶ added in v1.2.1
type NetworkSpeedTicker ¶ added in v1.3.0
type NetworkSpeedTicker struct { Upload *SpeedTicker Download *SpeedTicker }
func NewNetworkSpeedTicker ¶ added in v1.3.0
func NewNetworkSpeedTicker() NetworkSpeedTicker
func (*NetworkSpeedTicker) ToView ¶ added in v1.3.0
func (n *NetworkSpeedTicker) ToView() NetworkSpeedView
type NetworkSpeedView ¶ added in v1.3.0
type NetworkSpeedView struct { UploadSpeed int DownloadSpeed int UploadSpeedShow string DownloadSpeedShow string }
func CountAllNetworkSpeedView ¶ added in v1.3.0
func CountAllNetworkSpeedView(list ...NetworkSpeedView) NetworkSpeedView
type OdjClientInfo ¶
type OdjClientInfo struct {
Name string
}
type OdjSubOpenReq ¶ added in v1.3.3
type OdjSubOpenResp ¶ added in v1.3.3
type SpeedTicker ¶ added in v1.3.0
type SpeedTicker struct {
// contains filtered or unexported fields
}
func (*SpeedTicker) Get ¶ added in v1.3.0
func (st *SpeedTicker) Get() int
func (*SpeedTicker) Set ¶ added in v1.3.0
func (st *SpeedTicker) Set(i int)
type TaskCb ¶ added in v1.3.1
type TaskCb struct {
// contains filtered or unexported fields
}
func (*TaskCb) KeepWaitCb ¶ added in v1.3.1
type TaskCbContext ¶ added in v1.3.1
type TaskCbContext struct {
// contains filtered or unexported fields
}
func NewTaskContext ¶ added in v1.3.1
func NewTaskContext(rw io.ReadWriter, key Key) *TaskCbContext
func (*TaskCbContext) Close ¶ added in v1.3.3
func (tc *TaskCbContext) Close()
func (*TaskCbContext) NewTaskCb ¶ added in v1.3.1
func (tc *TaskCbContext) NewTaskCb(id string, fn func() error) *TaskCb
func (*TaskCbContext) NewTaskCbCMsg ¶ added in v1.3.1
func (tc *TaskCbContext) NewTaskCbCMsg(header string, code int, data interface{}) *TaskCb
func (*TaskCbContext) NewTaskCbCMsgNeedId ¶ added in v1.3.1
func (tc *TaskCbContext) NewTaskCbCMsgNeedId(header string, id string, code int, data interface{}) *TaskCb
func (*TaskCbContext) ReadCMsg ¶ added in v1.3.1
func (tc *TaskCbContext) ReadCMsg() error
func (*TaskCbContext) SetNoCb ¶ added in v1.3.1
func (tc *TaskCbContext) SetNoCb(fn func(cMsg ConnMsg))
func (*TaskCbContext) SetWriteLock ¶ added in v1.3.1
func (tc *TaskCbContext) SetWriteLock(lock *sync.Mutex)
Click to show internal directories.
Click to hide internal directories.