Documentation
¶
Index ¶
- Constants
- Variables
- func ConstructFileDescriptorSet(set *StringSet, fdSet *descriptorpb.FileDescriptorSet, fd *desc.FileDescriptor)
- func GetDirection(d Dir) string
- func GetFrameType(t uint8) string
- func IsConnPreface(payload []byte) bool
- type ConnSet
- func (set *ConnSet) Add(c DirectConn)
- func (set *ConnSet) AddAll(cons []DirectConn)
- func (set *ConnSet) Clone() *ConnSet
- func (set *ConnSet) Has(c DirectConn) bool
- func (set *ConnSet) Intersection(set2 *ConnSet) *ConnSet
- func (set *ConnSet) Remove(c DirectConn)
- func (set *ConnSet) RemoveAll(other *ConnSet)
- func (set *ConnSet) Size() int
- func (set *ConnSet) String() string
- func (set *ConnSet) ToArray() []DirectConn
- type Dir
- type DirectConn
- type FrameBase
- type FrameContinuation
- type FrameData
- type FrameHeader
- type FrameSetting
- type GRPCMessage
- type Http2Conn
- type NetPkg
- type PBMessageFinder
- type Processor
- type Stream
- type StringSet
- type TCPBuffer
Constants ¶
View Source
const ( CodecProtobuf = iota CodecOther )
View Source
const ( HeaderSize = 9 LengthSize = 3 ConnectionPrefaceSize = 24 StreamArraySize = 10000 SettingFormatItemSize = 48 )
View Source
const ( DirUnknown = iota DirIncoming DirOutcoming )
View Source
const ( PrefaceEarly = "FOO * HTTP/2.0\r\n\r\nBA\r\n\r\n" PrefaceSTD = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" )
View Source
const ( FrameTypeData = 0x0 FrameTypeHeader = 0x1 FrameTypePriority = 0x2 FrameTypeRSTStream = 0x3 FrameTypeSetting = 0x4 FrameTypePushPromise = 0x5 FrameTypePing = 0x6 FrameTypeGoAway = 0x7 FrameTypeWindowUpdate = 0x8 FrameTypeContinuation = 0x9 )
View Source
const MaxWindowSize = 65536
View Source
const (
PseudoHeaderPath = ":path"
)
View Source
const (
ReadBufferSize = 100 * 1024
)
Variables ¶
View Source
var DirStr map[Dir]string
View Source
var FrameTypeStr map[uint8]string
Functions ¶
func ConstructFileDescriptorSet ¶ added in v0.0.8
func ConstructFileDescriptorSet(set *StringSet, fdSet *descriptorpb.FileDescriptorSet, fd *desc.FileDescriptor)
func GetDirection ¶
func GetFrameType ¶
func IsConnPreface ¶
Types ¶
type ConnSet ¶
type ConnSet struct {
// contains filtered or unexported fields
}
func NewConnSet ¶
func NewConnSet() *ConnSet
func (*ConnSet) Add ¶
func (set *ConnSet) Add(c DirectConn)
func (*ConnSet) AddAll ¶
func (set *ConnSet) AddAll(cons []DirectConn)
func (*ConnSet) Has ¶
func (set *ConnSet) Has(c DirectConn) bool
func (*ConnSet) Intersection ¶
func (*ConnSet) Remove ¶
func (set *ConnSet) Remove(c DirectConn)
func (*ConnSet) ToArray ¶
func (set *ConnSet) ToArray() []DirectConn
type DirectConn ¶
func (*DirectConn) String ¶
func (d *DirectConn) String() string
type FrameBase ¶
type FrameBase struct {
DirectConn *DirectConn
StreamID uint32
Type uint8
Flags uint8
Length uint32
Payload []byte
}
Frame Header
func ParseFrameBase ¶
type FrameContinuation ¶
type FrameContinuation struct {
EndHeader bool
HeaderBlockFragment []byte
// contains filtered or unexported fields
}
func ParseFrameContinuation ¶
func ParseFrameContinuation(f *FrameBase) (*FrameContinuation, error)
type FrameData ¶
type FrameData struct {
EndStream bool
Padded bool
// Frame Payload
PadLength uint8
Data []byte
// contains filtered or unexported fields
}
func ParseFrameData ¶
func (*FrameData) ParseGRPCMessage ¶
func (fd *FrameData) ParseGRPCMessage() (*GRPCMessage, error)
type FrameHeader ¶
type FrameHeader struct {
EndStream bool
EndHeader bool
Padded bool
// I don't care
Priority bool
// Frame Payload
PadLength uint8
HeaderBlockFragment []byte
// contains filtered or unexported fields
}
func ParseFrameHeader ¶
func ParseFrameHeader(f *FrameBase) (*FrameHeader, error)
type FrameSetting ¶
type FrameSetting struct {
Ack bool
// contains filtered or unexported fields
}
func ParseFrameSetting ¶
func ParseFrameSetting(f *FrameBase) (*FrameSetting, error)
type GRPCMessage ¶
type GRPCMessage struct {
// ------ complete gRPC Message------
// https://github.com/grpc/grpc-go/blob/master/Documentation/encoding.md
// gRPC lets you use encoders other than Protobuf.
// gRPC is compatible with JSON, Thrift, Avro, Flatbuffers, Cap’n Proto, and even raw bytes!
/*
+--------------------+
| payloadFormat(8) |
+--------------------+------------------------------------------+
| length(32) |
+---------------------------------------------------------------+
| encodedMessage(*) ... |
+---------------------------------------------------------------+
payloadFormat: compressed or not?
encodedMessage: Protobuf,JSON,Thrift,etc.
*/
PayloadFormat payloadFormat
Length uint32
EncodedMessage []byte
}
type Http2Conn ¶
type Http2Conn struct {
DirectConn DirectConn
MaxDynamicTableSize uint32
MaxHeaderStringLen uint32
HeaderDecoder *hpack.Decoder
Streams [StreamArraySize]*Stream
TCPBuffer *TCPBuffer
Reader *bufio.Reader
Processor *Processor
}
http2 connection context
func NewHttp2Conn ¶
func NewHttp2Conn(conn DirectConn, maxDynamicTableSize uint32, p *Processor) *Http2Conn
func (*Http2Conn) ProcessFrame ¶ added in v0.2.1
type NetPkg ¶
type NetPkg struct {
SrcIP string
DstIP string
Ethernet *layers.Ethernet
IPv4 *layers.IPv4
IPv6 *layers.IPv6
TCP *layers.TCP
Direction Dir
}
func ProcessPacket ¶
func (*NetPkg) DirectConn ¶
func (p *NetPkg) DirectConn() DirectConn
type PBMessageFinder ¶
type PBMessageFinder struct {
// contains filtered or unexported fields
}
func NewPBMessageFinder ¶
func NewPBMessageFinder(addr string) *PBMessageFinder
func (*PBMessageFinder) FindMethodInput ¶
func (f *PBMessageFinder) FindMethodInput(svcAndMethod string) (proto.Message, error)
func (*PBMessageFinder) FindMethodInputWithCache ¶ added in v0.0.7
func (f *PBMessageFinder) FindMethodInputWithCache(svcAndMethod string) (proto.Message, error)
func (*PBMessageFinder) HandleRequestToJson ¶ added in v0.2.1
func (f *PBMessageFinder) HandleRequestToJson(svcAndMethod string, data []byte) ([]byte, error)
type Processor ¶
type Processor struct {
ConnRepository map[DirectConn]*Http2Conn
InputChan chan *NetPkg
OutputChan chan *protocol.Message
Finder *PBMessageFinder
}
func NewProcessor ¶
func (*Processor) ProcessTCPPkg ¶
func (p *Processor) ProcessTCPPkg()
type Stream ¶
type StringSet ¶ added in v0.0.9
type StringSet struct {
// contains filtered or unexported fields
}
func NewStringSet ¶ added in v0.0.9
func NewStringSet() *StringSet
type TCPBuffer ¶ added in v0.2.1
func NewTCPBuffer ¶ added in v0.2.1
func NewTCPBuffer() *TCPBuffer
Click to show internal directories.
Click to hide internal directories.