internal

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionStore added in v1.0.8

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

func NewConnectionStore added in v1.0.8

func NewConnectionStore() *ConnectionStore

func (*ConnectionStore) ConnCacheGet added in v1.0.8

func (cs *ConnectionStore) ConnCacheGet(addr net.Addr) (*WsConnAdapter, bool, error)

ConnCacheGet get connection from cache.

func (*ConnectionStore) ConnCacheRemove added in v1.0.8

func (cs *ConnectionStore) ConnCacheRemove(addr net.Addr) bool

ConnCacheRemove remove connection from cache.

func (*ConnectionStore) ConnCacheSet added in v1.0.8

func (cs *ConnectionStore) ConnCacheSet(addr net.Addr, conn *WsConnAdapter) error

ConnCacheSet store connection in cache.

type MultiplexConn

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

func NewMuxConn

func NewMuxConn(laddr transport.SockAddr, logger smudge.Logger) (*MultiplexConn, chan net.Addr)

func (*MultiplexConn) Close

func (mc *MultiplexConn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*MultiplexConn) HandleNewConn

func (mc *MultiplexConn) HandleNewConn(conn *WsConnAdapter)

func (*MultiplexConn) LocalAddr

func (mc *MultiplexConn) LocalAddr() net.Addr

LocalAddr returns the local network address, if known.

func (*MultiplexConn) Read

func (mc *MultiplexConn) Read(b []byte) (n int, err error)

Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*MultiplexConn) ReadFrom

func (mc *MultiplexConn) ReadFrom(b []byte) (n int, addr transport.SockAddr, error error)

func (*MultiplexConn) RemoteAddr

func (mc *MultiplexConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address, if known.

func (*MultiplexConn) SetDeadline

func (mc *MultiplexConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.

If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

func (*MultiplexConn) SetReadDeadline

func (mc *MultiplexConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.

func (*MultiplexConn) SetWriteDeadline

func (mc *MultiplexConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*MultiplexConn) Write

func (mc *MultiplexConn) Write(b []byte) (n int, err error)

Write writes data to the connection. Write can be made to time out and return an error after a fixed time limit; see SetDeadline and SetWriteDeadline.

type WsAddr

type WsAddr struct {
	WsAddrTCP net.TCPAddr
}

func (*WsAddr) GetIPAddr

func (ws *WsAddr) GetIPAddr() net.IP

func (*WsAddr) GetPort

func (ws *WsAddr) GetPort() int

func (*WsAddr) GetZone

func (ws *WsAddr) GetZone() string

func (*WsAddr) Network

func (ws *WsAddr) Network() string

func (*WsAddr) String

func (ws *WsAddr) String() string

type WsConnAdapter

type WsConnAdapter struct {
	SocketConn *websocket.Conn
	// contains filtered or unexported fields
}

WsConnAdapter adapter (wrapper) around web socket connection for correspond net.Conn interface.

func NewWsConn

func NewWsConn(conn *websocket.Conn, realRemoteAddr net.Addr) *WsConnAdapter

func NewWsConnAdapter added in v1.0.7

func NewWsConnAdapter(r *http.Request, wsconn *websocket.Conn) (*WsConnAdapter, error)

NewWsConnAdapter create new websocket conn adapter. If req is nil -> return remote socket addr as is. If requst not nil and contains X-Real-IP, return adapter with replaced remote address.

func (*WsConnAdapter) ActuallyClose

func (wsc *WsConnAdapter) ActuallyClose() error

ActuallyClose actyally close websocket connection.

func (*WsConnAdapter) Close

func (wsc *WsConnAdapter) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors. **NOTICE** this function do nothing, because we don't want the connection to be closed after every data transfer.

func (*WsConnAdapter) LocalAddr

func (wsc *WsConnAdapter) LocalAddr() net.Addr

LocalAddr returns the local network address, if known.

func (*WsConnAdapter) Read

func (wsc *WsConnAdapter) Read(b []byte) (n int, err error)

Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*WsConnAdapter) ReadFrom

func (wsc *WsConnAdapter) ReadFrom(b []byte) (n int, addr transport.SockAddr, err error)

func (*WsConnAdapter) RemoteAddr

func (wsc *WsConnAdapter) RemoteAddr() net.Addr

RemoteAddr returns the remote network address, if known.

func (*WsConnAdapter) SetDeadline

func (wsc *WsConnAdapter) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.

If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

func (*WsConnAdapter) SetReadDeadline

func (wsc *WsConnAdapter) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.

func (*WsConnAdapter) SetWriteDeadline

func (wsc *WsConnAdapter) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*WsConnAdapter) Write

func (wsc *WsConnAdapter) Write(b []byte) (n int, err error)

Write writes data to the connection. Write can be made to time out and return an error after a fixed time limit; see SetDeadline and SetWriteDeadline.

Jump to

Keyboard shortcuts

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