Documentation
¶
Overview ¶
Package hole : A hole to pass through the gateway.
Index ¶
- Variables
- func DecodePacket(payload []byte) (sessionID, data []byte)
- func EncodePacket(sessionID, data []byte) []byte
- func MakeHeader(data []byte) ([]byte, error)
- func ParseHeader(header []byte) uint32
- func PipeThenClose(src io.Reader, dst io.WriteCloser)
- type Client
- type Conn
- type ReadStream
- type Server
- type Session
- type WriteStream
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMagicNotMatch raise when the magic is no match. ErrMagicNotMatch = errors.New("Magic not match.") // MagicRequest a request magic. MagicRequest = []byte("\x00REQ") // MagicResponse a response magic. MagicResponse = []byte("\x00RES") )
var NullChar = []byte("\x00\x01")
Split the message payload
Functions ¶
func DecodePacket ¶
DecodePacket decode the data and sessionID from a packet.
func EncodePacket ¶
EncodePacket encode the data with sessionID.
func MakeHeader ¶
MakeHeader make a very simple 4 bytes header.
func ParseHeader ¶
ParseHeader parse a very simple 4 bytes header and extract the data length.
func PipeThenClose ¶
func PipeThenClose(src io.Reader, dst io.WriteCloser)
PipeThenClose copies data from src to dst, closes dst when done.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client define a client.
func (*Client) NewSession ¶
NewSession create a session.
type Conn ¶
type Conn struct { net.Conn RequestMagic []byte ResponseMagic []byte // contains filtered or unexported fields }
Conn a custom connect
func NewClientConn ¶
NewClientConn create a client connection
func NewServerConn ¶
NewServerConn create a server connection
type ReadStream ¶
type ReadStream struct {
// contains filtered or unexported fields
}
ReadStream define the base read stream.
func (*ReadStream) FeedData ¶
func (r *ReadStream) FeedData(buf []byte)
FeedData feed buffer from a socket or other.
func (*ReadStream) FeedEOF ¶
func (r *ReadStream) FeedEOF()
FeedEOF feed eof when the stream is closed.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server define a server type.
func (*Server) AssignClient ¶
AssignClient assign a client connection.
type Session ¶
type Session struct { ID []byte // contains filtered or unexported fields }
Session define session.
func NewSession ¶
NewSession create a new session with sessionID and conn.
type WriteStream ¶
type WriteStream struct {
// contains filtered or unexported fields
}
WriteStream define the base write stream.