Documentation
¶
Index ¶
- Constants
- Variables
- func GetDirection(d Dir) string
- func GetFrameType(t uint8) string
- func InitTCPFSM(processor fsm.EventProcessor) *fsm.StateMachine
- func IsConnPreface(payload []byte) bool
- func WaitTimeout(ch chan struct{}, duration time.Duration)
- 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 HTTPItem
- type Http2Conn
- type MessageParser
- type MethodInputOutput
- type NetPkg
- type PBFinder
- type PBFinderDelegate
- type Processor
- type Stream
- type TCPBuffer
- type TCPConnectionState
- type TCPEventProcessor
- func (p *TCPEventProcessor) Action(action string, fromState string, toState string, args []interface{}) error
- func (p *TCPEventProcessor) OnActionFailure(action string, fromState string, toState string, args []interface{}, err error)
- func (p *TCPEventProcessor) OnEnter(toState string, args []interface{})
- func (p *TCPEventProcessor) OnExit(fromState string, args []interface{})
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 ( StateListen = "LISTEN" // receive SYN StateSynReceived1 = "SYN-RECEIVED-1" // receive SYN and send SYN+ACK StateSynReceived2 = "SYN-RECEIVED-2" // receive ACK StateEstablished = "ESTABLISHED" //#################### Close Connection #################### // receive FIN StateCloseWait = "CLOSE_WAIT" // send ACk,FIN StateLastAck = "LAST_ACK" // send FIN StateClosed = "CLOSED" )
View Source
const ( EventReceiveSYN = "RECEIVE_SYN" EventReceiveACK = "RECEIVE_ACK" EventSendSYNACK = "SEND_SYN_ACK" EventReceiveFIN = "RECEIVE_FIN" EventSendACK = "SEND_ACK" EventSendFIN = "SEND_FIN" EventReceiveRST = "RECEIVE_RST" )
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
View Source
var (
WaitDefaultDuration = 1 * time.Second
)
Functions ¶
func GetDirection ¶
func GetFrameType ¶
func InitTCPFSM ¶ added in v0.2.10
func InitTCPFSM(processor fsm.EventProcessor) *fsm.StateMachine
func IsConnPreface ¶
func WaitTimeout ¶ added in v0.2.10
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 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 atomic.Bool
EndStream atomic.Bool
Headers *sync.Map `json:"headers"`
DataBuf *util.GoroutineSafeBuffer `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) FinishStream ¶ added in v0.2.10
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
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
}
func NewFilePBFinder ¶ added in v0.2.8
func NewReflectionPBFinder ¶ added in v0.2.6
type PBFinderDelegate ¶ added in v0.2.10
type PBFinderDelegate struct {
// contains filtered or unexported fields
}
func NewPBFinderDelegate ¶ added in v0.2.10
func NewPBFinderDelegate(ds grpcurl.DescriptorSource) *PBFinderDelegate
func (*PBFinderDelegate) Find ¶ added in v0.2.10
func (f *PBFinderDelegate) Find(svcAndMethod string) (*MethodInputOutput, error)
func (*PBFinderDelegate) Get ¶ added in v0.2.10
func (f *PBFinderDelegate) Get(svcAndMethod string) (*MethodInputOutput, error)
func (*PBFinderDelegate) GetDescriptorSource ¶ added in v0.2.10
func (f *PBFinderDelegate) GetDescriptorSource() grpcurl.DescriptorSource
type Processor ¶
type Processor struct {
ConnStates map[DirectConn]*TCPConnectionState
ConnRepository map[DirectConn]*Http2Conn
InputChan chan *NetPkg
OutputChan chan *protocol.Message
Finder PBFinder
RecordResponse bool
TCPStateMachine *fsm.StateMachine
}
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 Stream ¶
type TCPBuffer ¶ added in v0.2.1
func NewTCPBuffer ¶ added in v0.2.1
func NewTCPBuffer() *TCPBuffer
func (*TCPBuffer) SetExpectedSeq ¶ added in v0.2.10
type TCPConnectionState ¶ added in v0.2.10
type TCPConnectionState struct {
State string
States []string
// contains filtered or unexported fields
}
func NewTCPConnection ¶ added in v0.2.10
func NewTCPConnection(dc DirectConn) *TCPConnectionState
type TCPEventProcessor ¶ added in v0.2.10
type TCPEventProcessor struct{}
func (*TCPEventProcessor) Action ¶ added in v0.2.10
func (p *TCPEventProcessor) Action(action string, fromState string, toState string, args []interface{}) error
func (*TCPEventProcessor) OnActionFailure ¶ added in v0.2.10
func (p *TCPEventProcessor) OnActionFailure(action string, fromState string, toState string, args []interface{}, err error)
func (*TCPEventProcessor) OnEnter ¶ added in v0.2.10
func (p *TCPEventProcessor) OnEnter(toState string, args []interface{})
func (*TCPEventProcessor) OnExit ¶ added in v0.2.10
func (p *TCPEventProcessor) OnExit(fromState string, args []interface{})
Click to show internal directories.
Click to hide internal directories.