network

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Running Status = "running"
	Stopped Status = "stopped"

	DefaultTickInterval = 5 * time.Second
	DefaultPoolSize     = 10
	MinimumPoolSize     = 2
	DefaultBufferSize   = 4096
)
View Source
const (
	DefaultSeed = 1000
)

Variables

This section is empty.

Functions

func GetID

func GetID(network, address string, seed int, logger zerolog.Logger) string

func GetRLimit

func GetRLimit(logger zerolog.Logger) syscall.Rlimit

func Resolve added in v0.0.2

func Resolve(network, address string, logger zerolog.Logger) (string, error)

Types

type Client

type Client struct {
	net.Conn

	ID                string
	ReceiveBufferSize int
	Network           string // tcp/udp/unix
	Address           string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(network, address string, receiveBufferSize int, logger zerolog.Logger) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Receive

func (c *Client) Receive() (int, []byte, error)

func (*Client) Send

func (c *Client) Send(data []byte) error

type Proxy

type Proxy interface {
	Connect(gconn gnet.Conn) error
	Disconnect(gconn gnet.Conn) error
	PassThrough(gconn gnet.Conn) error
	Reconnect(cl *Client) *Client
	Shutdown()
}

type ProxyImpl

type ProxyImpl struct {
	Elastic             bool
	ReuseElasticClients bool

	// ClientConfig is used for elastic proxy and reconnection
	ClientConfig *Client
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(
	p pool.Pool, hookConfig *plugin.HookConfig,
	elastic, reuseElasticClients bool,
	clientConfig *Client, logger zerolog.Logger,
) *ProxyImpl

func (*ProxyImpl) Connect

func (pr *ProxyImpl) Connect(gconn gnet.Conn) error

func (*ProxyImpl) Disconnect

func (pr *ProxyImpl) Disconnect(gconn gnet.Conn) error

func (*ProxyImpl) PassThrough

func (pr *ProxyImpl) PassThrough(gconn gnet.Conn) error

func (*ProxyImpl) Reconnect

func (pr *ProxyImpl) Reconnect(cl *Client) *Client

func (*ProxyImpl) Shutdown

func (pr *ProxyImpl) Shutdown()

type Server

type Server struct {
	gnet.BuiltinEventEngine

	Network      string // tcp/udp/unix
	Address      string
	Options      []gnet.Option
	SoftLimit    uint64
	HardLimit    uint64
	Status       Status
	TickInterval time.Duration
	// contains filtered or unexported fields
}

func NewServer added in v0.0.2

func NewServer(
	network, address string,
	softLimit, hardLimit uint64,
	tickInterval time.Duration,
	options []gnet.Option,
	proxy Proxy,
	logger zerolog.Logger,
	hooksConfig *plugin.HookConfig,
) *Server

func (*Server) IsRunning added in v0.0.2

func (s *Server) IsRunning() bool

func (*Server) OnBoot

func (s *Server) OnBoot(engine gnet.Engine) gnet.Action

func (*Server) OnClose

func (s *Server) OnClose(gconn gnet.Conn, err error) gnet.Action

func (*Server) OnOpen

func (s *Server) OnOpen(gconn gnet.Conn) ([]byte, gnet.Action)

func (*Server) OnShutdown

func (s *Server) OnShutdown(engine gnet.Engine)

func (*Server) OnTick

func (s *Server) OnTick() (time.Duration, gnet.Action)

func (*Server) OnTraffic

func (s *Server) OnTraffic(gconn gnet.Conn) gnet.Action

func (*Server) Run

func (s *Server) Run() error

func (*Server) Shutdown

func (s *Server) Shutdown()

type Status added in v0.0.2

type Status string

Jump to

Keyboard shortcuts

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