cf

package
v0.0.0-...-bf71a7b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 18 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

func SetMaxDownloadRate(rate uint64)

func SetMaxUploadRate

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

func (cc *ClientConn) GetInboundAndReset() int64

func (*ClientConn) GetIsActive

func (cc *ClientConn) GetIsActive() bool

func (*ClientConn) GetLocalAddr

func (cc *ClientConn) GetLocalAddr() string

func (*ClientConn) GetLocalP2pAddress

func (cc *ClientConn) GetLocalP2pAddress() string

func (*ClientConn) GetName

func (cc *ClientConn) GetName() string

func (*ClientConn) GetNetID

func (cc *ClientConn) GetNetID() int64

func (*ClientConn) GetOutboundAndReset

func (cc *ClientConn) GetOutboundAndReset() int64

func (*ClientConn) GetPort

func (cc *ClientConn) GetPort() string

func (*ClientConn) GetRemoteAddr

func (cc *ClientConn) GetRemoteAddr() string

func (*ClientConn) GetRemoteP2pAddress

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

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

func ContextKVOption(kv []ContextKV) ClientOption

func HeartCloseOption

func HeartCloseOption(b bool) ClientOption

func LogOpenOption

func LogOpenOption(b bool) ClientOption

func MinAppVersionOption

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 OnHandleOption

func OnHandleOption(cb func(context.Context, *msg.RelayMsgBuf)) ClientOption

func OnReadOption

func OnReadOption(cb func(*msg.RelayMsgBuf)) ClientOption

func OnWriteOption

func OnWriteOption(cb func(context.Context, *msg.RelayMsgBuf)) ClientOption

func P2pAddressOption

func P2pAddressOption(p2pAddress string) ClientOption

P2pAddressOption sets the local P2P address for this conn

func ReadDeadlineOption

func ReadDeadlineOption(timeout int64) ClientOption

func ReconnectOption

func ReconnectOption(rec bool) ClientOption

func ServerIpOption

func ServerIpOption(serverIp net.IP) ClientOption

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

func ServerPortOption

func ServerPortOption(serverPort uint16) ClientOption

ServerPortOption sets the port used by the local p2p server

type ContextKV

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

type MsgHandler

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

type WriteHook

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