From cdad527930ab12338fad62622bf3b3f036e19e65 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Thu, 9 Nov 2023 11:04:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=81=E4=B9=A6=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/plugins/extra-params_v2/config.go | 2 +- entries/http-entry/reader.go | 9 ++++++++- go.mod | 2 +- node/fasthttp-client/client.go | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/plugins/extra-params_v2/config.go b/drivers/plugins/extra-params_v2/config.go index 96acae9d..f2d3cee0 100644 --- a/drivers/plugins/extra-params_v2/config.go +++ b/drivers/plugins/extra-params_v2/config.go @@ -39,7 +39,7 @@ func (c *Config) doCheck() error { } } c.RequestBodyType = strings.ToLower(c.RequestBodyType) - if contentTypeMap[c.RequestBodyType] == "" { + if contentTypeMap[c.RequestBodyType] == "" && c.RequestBodyType != "" { return fmt.Errorf("error body type: %s", c.RequestBodyType) } return nil diff --git a/entries/http-entry/reader.go b/entries/http-entry/reader.go index baf10c13..771e956e 100644 --- a/entries/http-entry/reader.go +++ b/entries/http-entry/reader.go @@ -92,12 +92,19 @@ var ( return ctx.Request().RealIp(), true }), "src_port": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { - return ctx.Request().RemotePort(), true + port, err := strconv.Atoi(ctx.Request().RemotePort()) + if err != nil { + return nil, false + } + return port, true }), "uri": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { //不带请求参数的uri return ctx.Request().URI().Path(), true }), + "url": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { + return ctx.Request().URI().RawURL(), true + }), "content_length": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { return ctx.Request().Header().GetHeader("content-length"), true }), diff --git a/go.mod b/go.mod index 45bafae7..6f474309 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/clbanning/mxj v1.8.4 github.com/coocood/freecache v1.2.2 github.com/dubbogo/gost v1.13.1 - github.com/eolinker/eosc v0.15.1 + github.com/eolinker/eosc v0.15.2 github.com/fasthttp/websocket v1.5.0 github.com/fullstorydev/grpcurl v1.8.7 github.com/go-redis/redis/v8 v8.11.5 diff --git a/node/fasthttp-client/client.go b/node/fasthttp-client/client.go index 24ab9d6f..487177a4 100644 --- a/node/fasthttp-client/client.go +++ b/node/fasthttp-client/client.go @@ -42,7 +42,7 @@ func ProxyTimeout(scheme string, node eocontext.INode, req *fasthttp.Request, re if err != nil { return nil, err } - addr := fmt.Sprintf("%s://%s:%d", scheme, tcpAddr.IP.String(), tcpAddr.Port) + addr := fmt.Sprintf("%s://%s", scheme, node.Addr()) err = defaultClient.ProxyTimeout(addr, req, resp, timeout) if err != nil { node.Down()