Documentation
¶
Index ¶
- Constants
- Variables
- 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 FilePBFinder
- type FrameBase
- type FrameContinuation
- type FrameData
- type FrameHeader
- type FrameSetting
- type GRPCMessage
- type HTTPItem
- type Http2Conn
- type MessageParser
- type MethodInputOutput
- type NetPkg
- type PBFinder
- type Processor
- type ReflectionPBFinder
- type Stream
- 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"
)
Variables ¶
View Source
var DirStr map[Dir]string
View Source
var FrameTypeStr map[uint8]string
Functions ¶
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) Reverse ¶ added in v0.2.6
func (d *DirectConn) Reverse() DirectConn
func (*DirectConn) String ¶
func (d *DirectConn) String() string
type FilePBFinder ¶ added in v0.2.8
type FilePBFinder struct {
// contains filtered or unexported fields
}
func NewFilePBFinder ¶ added in v0.2.8
func NewFilePBFinder(protoFiles []string) *FilePBFinder
func (*FilePBFinder) Get ¶ added in v0.2.8
func (f *FilePBFinder) Get(svcAndMethod string) (*MethodInputOutput, error)
func (*FilePBFinder) GetDescriptorSource ¶ added in v0.2.8
func (f *FilePBFinder) GetDescriptorSource() grpcurl.DescriptorSource
type FrameBase ¶
type FrameBase struct {
DirectConn DirectConn
// input or output ?
InputFlag bool
StreamID uint32
Type uint8
Flags uint8
Length uint32
Payload []byte
}
Frame Header
func ParseFrameBase ¶
func ParseFrameBase(b []byte, dc DirectConn, inputFlag bool) (*FrameBase, error)
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 HTTPItem ¶ added in v0.2.6
type HTTPItem struct {
EndHeader bool
EndStream bool
Headers *sync.Map `json:"headers"`
Method string `json:"method"`
DataBuf *bytes.Buffer `json:"-"`
}
func NewHTTPItem ¶ added in v0.2.6
func NewHTTPItem() *HTTPItem
type Http2Conn ¶
type Http2Conn struct {
DirectConn DirectConn
Streams [StreamArraySize]*Stream
// ###### for input ######
Input *MessageParser
// ###### for output ######
Output *MessageParser
Processor *Processor
RecordResponse bool
MaxHeaderStringLen uint32
}
http2 connection context
func NewHttp2Conn ¶
func NewHttp2Conn(conn DirectConn, maxDynamicTableSize uint32, p *Processor) *Http2Conn
func (*Http2Conn) DealOutput ¶ added in v0.2.6
func (hc *Http2Conn) DealOutput()
func (*Http2Conn) ProcessFrame ¶ added in v0.2.1
type MessageParser ¶ added in v0.2.6
type MessageParser struct {
TCPBuffer *TCPBuffer
MaxDynamicTableSize uint32
HeaderDecoder *hpack.Decoder
}
func NewMessageParser ¶ added in v0.2.6
func NewMessageParser(maxDynamicTableSize uint32) *MessageParser
type MethodInputOutput ¶ added in v0.2.6
func Find ¶ added in v0.2.8
func Find(ds grpcurl.DescriptorSource, svcAndMethod string) (*MethodInputOutput, error)
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 PBFinder ¶ added in v0.2.6
type PBFinder interface {
// svcAndMethod looks like"/helloworld.Greeter/SayHello"
Get(svcAndMethod string) (*MethodInputOutput, error)
GetDescriptorSource() grpcurl.DescriptorSource
}
type Processor ¶
type Processor struct {
ConnRepository map[DirectConn]*Http2Conn
InputChan chan *NetPkg
OutputChan chan *protocol.Message
Finder PBFinder
RecordResponse bool
}
func NewProcessor ¶
func (*Processor) ProcessIncomingTCPPkg ¶ added in v0.2.6
func (*Processor) ProcessOutComingTCPPkg ¶ added in v0.2.6
func (*Processor) ProcessTCPPkg ¶
func (p *Processor) ProcessTCPPkg()
type ReflectionPBFinder ¶ added in v0.2.6
type ReflectionPBFinder struct {
// contains filtered or unexported fields
}
func NewReflectionPBFinder ¶ added in v0.2.6
func NewReflectionPBFinder(addr string) *ReflectionPBFinder
func (*ReflectionPBFinder) Get ¶ added in v0.2.6
func (f *ReflectionPBFinder) Get(svcAndMethod string) (*MethodInputOutput, error)
func (*ReflectionPBFinder) GetDescriptorSource ¶ added in v0.2.8
func (f *ReflectionPBFinder) GetDescriptorSource() grpcurl.DescriptorSource
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.