Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kern: http2 response packet decode failed. #225

Merged
merged 2 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/event_processor/http_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func (this *HTTPRequest) Reset() {
}

func (this *HTTPRequest) Display() []byte {
if this.request.Proto == "HTTP/2.0" {
return this.reader.Bytes()
}
b, e := httputil.DumpRequest(this.request, true)
if e != nil {
log.Println("DumpRequest error:", e)
Expand Down
16 changes: 16 additions & 0 deletions pkg/event_processor/iparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package event_processor

import (
"bytes"
"encoding/hex"
"fmt"
)

Expand All @@ -25,7 +26,9 @@ const (
const (
PARSER_TYPE_NULL PARSER_TYPE = iota
PARSER_TYPE_HTTP_REQUEST
PARSER_TYPE_HTTP2_REQUEST
PARSER_TYPE_HTTP_RESPONSE
PARSER_TYPE_HTTP2_RESPONSE
PARSER_TYPE_WEB_SOCKET
)

Expand Down Expand Up @@ -76,6 +79,12 @@ func NewParser(payload []byte) IParser {
newParser = new(HTTPRequest)
case PARSER_TYPE_HTTP_RESPONSE:
newParser = new(HTTPResponse)
case PARSER_TYPE_HTTP2_REQUEST:
// TODO support HTTP2 request
// via golang.org/x/net/http2
//hpack.NewEncoder(buf)
case PARSER_TYPE_HTTP2_RESPONSE:
// TODO support HTTP2 response
}
break
}
Expand Down Expand Up @@ -127,6 +136,13 @@ func (this *DefaultParser) Init() {
}

func (this *DefaultParser) Display() []byte {
b := this.reader.Bytes()
if len(b) <= 0 {
return []byte{}
}
if b[0] < 32 || b[0] > 126 {
return []byte(hex.Dump(b))
}
return []byte(CToGoString(this.reader.Bytes()))
}

Expand Down
1 change: 1 addition & 0 deletions pkg/event_processor/iworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (this *eventWorker) Run() {
case _ = <-this.ticker.C:
// 输出包
if this.tickerCount > MAX_TICKER_COUNT {
this.processor.GetLogger().Printf("eventWorker TickerCount > %d, event closed.", MAX_TICKER_COUNT)
this.Close()
return
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/event_processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (this *EventProcessor) Serve() {
}

func (this *EventProcessor) dispatch(e event.IEventStruct) {
//this.logger.Printf("event ID:%s", event.GetUUID())
//this.logger.Printf("event ID:%s", e.GetUUID())
var uuid string = e.GetUUID()
found, eWorker := this.getWorkerByUUID(uuid)
if !found {
Expand All @@ -58,6 +58,7 @@ func (this *EventProcessor) dispatch(e event.IEventStruct) {
err := eWorker.Write(e)
if err != nil {
//...
this.GetLogger().Fatalf("write event failed , error:%v", err)
}
}

Expand Down