Documentation
¶
Overview ¶
Package transport provides network transport abstractions This file defines the Channel interface which represents a network communication channel
Package transport SChannel is a struct that represents a secure channel for communication It implements the conn interface from net package
Index ¶
- type Channel
- type CloseEvent
- type SChannel
- func (c *SChannel) ActiveTime() time.Time
- func (c *SChannel) AddAttr(key lang.KeyType, value interface{})
- func (c *SChannel) Close() error
- func (c *SChannel) Ctx() context.Context
- func (c *SChannel) Done() <-chan struct{}
- func (c *SChannel) GetAttr(key lang.KeyType) (interface{}, bool)
- func (c *SChannel) GetConn() net.Conn
- func (c *SChannel) GetId() string
- func (c *SChannel) GetReader() io.Reader
- func (c *SChannel) GetWriter() io.Writer
- func (c *SChannel) IsClose() bool
- func (c *SChannel) IsHealthy() bool
- func (c *SChannel) LastTime() time.Time
- func (c *SChannel) LocalAddr() net.Addr
- func (c *SChannel) OnClose(event CloseEvent)
- func (c *SChannel) Read(p []byte) (n int, err error)
- func (c *SChannel) RemoteAddr() net.Addr
- func (c *SChannel) SendTo([]byte, net.Addr) (int, error)
- func (c *SChannel) SetDeadline(t time.Time) error
- func (c *SChannel) SetReadDeadline(t time.Time) error
- func (c *SChannel) SetWriteDeadline(t time.Time) error
- func (c *SChannel) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel interface {
io.Reader
io.Writer
// conn net.Conn provides basic network connection functionality
net.Conn
// GetReader returns the reader part of the channel
// This can be used to get a specific reader implementation
GetReader() io.Reader
// GetWriter returns the writer part of the channel
// This can be used to get a specific writer implementation
GetWriter() io.Writer
// RemoteAddr returns the remote network address
// This overrides the method from net.Conn to provide
// a more specific implementation for this transport
RemoteAddr() net.Addr
// LocalAddr returns the local network address
// This overrides the method from net.Conn to provide
// a more specific implementation for this transport
LocalAddr() net.Addr
// GetConn returns the underlying network connection
// This provides access to the raw network connection
// for cases where direct access is needed
GetConn() net.Conn
// GetId returns the unique identifier for the channel
GetId() string
// Done returns a channel that is closed when the channel is closed
// This can be used to wait for the channel to be closed
//Close
Done() <-chan struct{}
// IsClose isClose.
IsClose() bool
SendTo(by []byte, addr net.Addr) (int, error)
//
// GetAttr
// @Description: getKey.
// @param key
//
GetAttr(key lang.KeyType) (interface{}, bool)
// OnClose CloseEvent The Channel Setter CloseEvent
OnClose(event CloseEvent)
LastTime() time.Time
ActiveTime() time.Time
}
Channel interface represents a network communication channel It combines io.Reader and io.Writer with net.Conn to provide a comprehensive interface for network operations. This interface is designed to be implemented by different transport protocols while providing a consistent API for upper layers.
type CloseEvent ¶
type CloseEvent func(channel Channel)
type SChannel ¶
type SChannel struct {
IsOpenTunnel bool
// contains filtered or unexported fields
}
SChannel struct holds the secure channel information r and w are the reader and writer for the channel stream is the underlying smux stream buf is a buffer for storing data temporarily isBindTunnel indicates if the channel is bound to a tunnel
func NewSChannel ¶
NewSChannel creates a new SChannel with the given smux stream It initializes a pipe for reading and writing
func (*SChannel) ActiveTime ¶
func (*SChannel) OnClose ¶
func (c *SChannel) OnClose(event CloseEvent)
func (*SChannel) RemoteAddr ¶
RemoteAddr returns the remote network address
func (*SChannel) SetDeadline ¶
SetDeadline sets the deadline for both read and write operations
func (*SChannel) SetReadDeadline ¶
SetReadDeadline sets the deadline for read operations
func (*SChannel) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for write operations