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 MustWriteCMsgNotKeyJson(cMsg ConnMsg) (b []byte)
- func NewId(n int) (str string)
- func Println(conn net.Conn, i ...any)
- func ReRun(rt string, fn func() bool) error
- func UnmarshalV2(inBody interface{}, outBody interface{}) error
- func WriteCMsgNotKeyJson(cMsg ConnMsg) (b []byte, err error)
- type CloseWaiter
- type ConnMsg
- type CtxCloser
- 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 LinkBox
- type LinkBoxRWFn
- type MashBytes
- type NetworkSpeedTicker
- type NetworkSpeedView
- type OdjClientInfo
- type OdjErrMsg
- type OdjIdList
- type OdjMsg
- type OdjPing
- type OdjSubOpenReq
- type OdjSubOpenResp
- type OdjSubReq
- type OdjUP2PKId
- type OdjUP2PKName
- type OdjUP2PReq
- type OdjUP2PResp
- type OdjVPNLinkAddr
- 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
- type VpnInfo
Constants ¶
View Source
const ( P2PTcpReset = "P2PTcpReset" P2PTcpStart = "P2PTcpStart" P2PTCpSucceed = "P2PTCpSucceed" P2PTCpFailed = "P2PTCpSucceed" )
View Source
const ( SubOpenTypeDefault = "SubOpenTypeDefault" SubOpenTypeTCPP2P = "SubOpenTypeTCPP2P" )
View Source
const ( LinkConnTypeTCP = "LinkConnTypeTCP" LinkConnTypeUDP = "LinkConnTypeUDP" CopyConnTypeTCP = "CopyConnTypeTCP" CopyConnTypeUDP = "LinkConnTypeUDP" )
View Source
const (
BufferSize = 4096
)
bytes size = 4096 data len 4004=4096-8-60-8-16
View Source
const ConnVPNA1 = "ConnVPNA1"
View Source
const ConnVPNA2 = "ConnVPNA2"
View Source
const ConnVPNQ1 = "ConnVPNQ1"
View Source
const ConnVPNQ2 = "ConnVPNQ2"
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 HttpVPNFA1 = "HttpVPNFA1"
View Source
const HttpVPNFA2 = "HttpVPNFA2"
View Source
const HttpVPNFQ1 = "HttpVPNFQ1"
View Source
const HttpVPNFQ2 = "HttpVPNFQ2"
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 P2PUdpA1 = "P2PUdpA1"
View Source
const P2PUdpO = "P2PUdpO"
View Source
const P2PUdpQ1 = "P2PUdpQ1"
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 ErrCheckBadAny = func(a ...any) error { return fmt.Errorf("check err: %v", a) }
View Source
var ErrCheckUnexpectedHeader = errors.New("check err: unexpected header")
View Source
var ErrConnIsNil = errors.New("conn is nil")
View Source
var ErrDataException = errors.New("data exception")
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 ErrHandshakeIsBad = 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 ErrLinkClientIsClosed = errors.New("link client is closed")
View Source
var ErrMethodIsRefused = errors.New("the method is refused")
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 ErrProxyClientIsClosed = errors.New("the proxy client is closed")
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 LinkConn")
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 ErrSubDstKeyIsNil = errors.New("sub dst key is nil")
View Source
var ErrSubIsDisable = errors.New("sub box is disable")
View Source
var ErrSubLocalAddrIsNil = errors.New("sub local addr is nil")
View Source
var ErrSubTypeInvalid = errors.New("sub type invalid")
View Source
var ErrSubTypeToMixGetSubBoxFailed = errors.New("sub type to mix get sub box failed")
View Source
var ErrTimeout = errors.New("timeout")
View Source
var ErrUnexpectedLinkConnType = errors.New("unexpected link conn type")
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 MustWriteCMsgNotKeyJson ¶ added in v1.3.8
func UnmarshalV2 ¶
func UnmarshalV2(inBody interface{}, outBody interface{}) error
func WriteCMsgNotKeyJson ¶ added in v1.3.8
Types ¶
type CloseWaiter ¶ added in v1.3.5
type CloseWaiter struct {
// contains filtered or unexported fields
}
func NewCloseWaiter ¶ added in v1.3.5
func NewCloseWaiter() *CloseWaiter
func (*CloseWaiter) AddCloseFn ¶ added in v1.3.5
func (cw *CloseWaiter) AddCloseFn(fn func())
func (*CloseWaiter) Close ¶ added in v1.3.5
func (cw *CloseWaiter) Close(err error)
func (*CloseWaiter) Wait ¶ added in v1.3.5
func (cw *CloseWaiter) Wait() error
type ConnMsg ¶
func MustReadCMsgNotKeyJson ¶ added in v1.3.8
func MustReadCMsgNotKeyJson2 ¶ added in v1.3.8
func ReadCMsgNotKeyJson ¶ added in v1.3.8
func ReadCMsgNotKeyJson2 ¶ added in v1.3.8
func (*ConnMsg) CheckConnMsgHeaderAndCode ¶ added in v1.3.1
func (*ConnMsg) MustUnmarshal ¶ added in v1.3.3
type CtxCloser ¶ added in v1.3.7
type CtxCloser struct {
// contains filtered or unexported fields
}
func NewCtxCloser ¶ added in v1.3.7
func (*CtxCloser) AddCloseFn ¶ added in v1.3.7
func (cc *CtxCloser) AddCloseFn(fn func())
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
func (*Key) ReadCPacket ¶ added in v1.3.0
type LinkBox ¶ added in v1.3.5
type LinkBox struct {
// contains filtered or unexported fields
}
func NewLinkBox ¶ added in v1.3.5
func NewLinkBox(rw io.ReadWriter, readrSize int, readFn LinkBoxRWFn, writeFn LinkBoxRWFn) *LinkBox
func (*LinkBox) ReadLinkBoxToWriter ¶ added in v1.3.5
ReadLinkBoxToWriter link -> other
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 OdjSubOpenReq ¶ added in v1.3.3
type OdjSubOpenResp ¶ added in v1.3.3
type OdjUP2PKId ¶ added in v1.3.6
type OdjUP2PKId struct {
Id string
}
type OdjUP2PKName ¶ added in v1.3.6
type OdjUP2PKName struct {
Name string
}
type OdjUP2PReq ¶ added in v1.3.6
type OdjUP2PResp ¶ added in v1.3.6
type OdjVPNLinkAddr ¶ added in v1.3.5
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 SubInfo ¶ added in v1.3.3
type SubInfo struct { LocalName string RemoteName string LocalIntranetAddr *net.TCPAddr RemoteIntranetAddr *net.TCPAddr ULocalIntranetAddr *net.UDPAddr URemoteIntranetAddr *net.UDPAddr LocalPublicAddr *net.TCPAddr RemotePublicAddr *net.TCPAddr ULocalPublicAddr *net.UDPAddr URemotePublicAddr *net.UDPAddr }
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)
type VpnInfo ¶ added in v1.3.5
type VpnInfo struct { LinkConnType string LinkRemoteAddrTcp *net.TCPAddr LinkLocalAddrTcp *net.TCPAddr LinkRemoteAddrUdp *net.UDPAddr LinkLocalAddrUdp *net.UDPAddr CopyConnType string CopyRemoteAddrTcp *net.TCPAddr CopyLocalAddrTcp *net.TCPAddr CopyRemoteAddrUdp *net.UDPAddr CopyLocalAddrUdp *net.UDPAddr }
Click to show internal directories.
Click to hide internal directories.