cf

package
v0.11.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_MODULE_START      = "start: "
	LOG_MODULE_WRITELOOP  = "writeLoop: "
	LOG_MODULE_READLOOP   = "readLoop: "
	LOG_MODULE_HANDLELOOP = "handleLoop: "
	LOG_MODULE_CLOSE      = "close: "
)

Variables

This section is empty.

Functions

func Mylog

func Mylog(b bool, module string, v ...interface{})

func SetMaxDownloadRate added in v0.10.0

func SetMaxDownloadRate(rate uint64)

func SetMaxUploadRate added in v0.10.0

func SetMaxUploadRate(rate uint64)

Types

type ClientConn

type ClientConn struct {
	// contains filtered or unexported fields
}

func CreateClientConn

func CreateClientConn(netid int64, addr string, opt ...ClientOption) *ClientConn

func (*ClientConn) ClientClose

func (cc *ClientConn) ClientClose(closeLowLayerConn bool)

ClientClose Actively closes the client connection

func (*ClientConn) Close

func (cc *ClientConn) Close()

func (*ClientConn) ContextValue

func (cc *ClientConn) ContextValue(k interface{}) interface{}

func (*ClientConn) GetIP

func (cc *ClientConn) GetIP() string

GetIP get connection ip

func (*ClientConn) GetInboundAndReset added in v0.5.0

func (cc *ClientConn) GetInboundAndReset() int64

func (*ClientConn) GetIsActive added in v0.9.0

func (cc *ClientConn) GetIsActive() bool

func (*ClientConn) GetLocalAddr added in v0.5.0

func (cc *ClientConn) GetLocalAddr() string

func (*ClientConn) GetLocalP2pAddress added in v0.8.0

func (cc *ClientConn) GetLocalP2pAddress() string

func (*ClientConn) GetName

func (cc *ClientConn) GetName() string

func (*ClientConn) GetNetID

func (cc *ClientConn) GetNetID() int64

func (*ClientConn) GetOutboundAndReset added in v0.5.0

func (cc *ClientConn) GetOutboundAndReset() int64

func (*ClientConn) GetPort

func (cc *ClientConn) GetPort() string

func (*ClientConn) GetRemoteAddr added in v0.5.0

func (cc *ClientConn) GetRemoteAddr() string

func (*ClientConn) GetRemoteP2pAddress added in v0.8.0

func (cc *ClientConn) GetRemoteP2pAddress() string

func (*ClientConn) GetSecondReadFlow

func (cc *ClientConn) GetSecondReadFlow() int64

func (*ClientConn) GetSecondWriteFlow

func (cc *ClientConn) GetSecondWriteFlow() int64

func (*ClientConn) SetConnName

func (cc *ClientConn) SetConnName(name string)

func (*ClientConn) SetContextValue

func (cc *ClientConn) SetContextValue(k, v interface{})

func (*ClientConn) SetWriteHook added in v0.9.0

func (cc *ClientConn) SetWriteHook(h []WriteHook)

func (*ClientConn) Start

func (cc *ClientConn) Start()

Start client starts readLoop, writeLoop, handleLoop

func (*ClientConn) Write

func (cc *ClientConn) Write(message *msg.RelayMsgBuf, ctx context.Context) error

type ClientOption

type ClientOption func(*options)

ClientOption client configuration

func BufferSizeOption

func BufferSizeOption(indicator int) ClientOption

func ContextKVOption added in v0.9.0

func ContextKVOption(kv []ContextKV) ClientOption

func HeartCloseOption

func HeartCloseOption(b bool) ClientOption

func LogOpenOption

func LogOpenOption(b bool) ClientOption

func MinAppVersionOption added in v0.7.0

func MinAppVersionOption(b uint16) ClientOption

func OnCloseOption

func OnCloseOption(cb func(core.WriteCloser)) ClientOption

func OnConnectOption

func OnConnectOption(cb func(core.WriteCloser) bool) ClientOption

func OnErrorOption

func OnErrorOption(cb func(core.WriteCloser)) ClientOption

func OnMessageOption

func OnMessageOption(cb func(msg.RelayMsgBuf, core.WriteCloser)) ClientOption

func P2pAddressOption added in v0.8.0

func P2pAddressOption(p2pAddress string) ClientOption

P2pAddressOption sets the local P2P address for this conn

func ReconnectOption

func ReconnectOption(rec bool) ClientOption

func ServerIpOption added in v0.11.0

func ServerIpOption(serverIp net.IP) ClientOption

ServerIpOption sets the IP used by the server conn when establishing the handshake

func ServerPortOption added in v0.8.0

func ServerPortOption(serverPort uint16) ClientOption

ServerPortOption sets the port used by the local p2p server

type ContextKV added in v0.9.0

type ContextKV struct {
	Key   interface{}
	Value interface{}
}

type MsgHandler

type MsgHandler struct {
	// contains filtered or unexported fields
}

type WriteHook added in v0.9.0

type WriteHook struct {
	MessageId uint8
	Fn        core.WriteHookFunc
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL