diff --git a/servlet/data-servlet.go b/servlet/data-servlet.go index 2066ea6..90c7290 100644 --- a/servlet/data-servlet.go +++ b/servlet/data-servlet.go @@ -3,7 +3,6 @@ package servlet import ( "context" "crypto/rsa" - "encoding/json" "fmt" "sync" @@ -12,7 +11,6 @@ import ( "git.loafle.net/commons/server-go" "git.loafle.net/commons/server-go/socket" ocpc "git.loafle.net/overflow/commons-go/probe/constants" - ocpm "git.loafle.net/overflow/commons-go/probe/model" og "git.loafle.net/overflow/gateway" "git.loafle.net/overflow/gateway/external/grpc" ogrs "git.loafle.net/overflow/gateway_rpc/servlet" @@ -80,25 +78,16 @@ func (s *DataServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req probeKey := string(bProbeKey) grpcCTX := context.Background() - r, err := grpc.Exec(grpcCTX, "ProbeService.readByProbeKey", probeKey) + _, err := grpc.Exec(grpcCTX, "ProbeService.readByProbeKey", probeKey) if nil != err { return nil, fmt.Errorf("grpc call Error: %s", err.Error()) } - probe := ocpm.Probe{} - err = json.Unmarshal([]byte(r), probe) - if nil != err { - return nil, fmt.Errorf("grpc result unMarshal Error: %s", err.Error()) - } - - extHeader := &fasthttp.ResponseHeader{} - extHeader.Add(ocpc.HTTPResponseHeaderKey_Probe_SetEncryptionKey, probe.EncryptionKey) - - servletCtx.SetAttribute(og.SessionIDKey, probe.ProbeKey) + servletCtx.SetAttribute(og.SessionIDKey, probeKey) servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE) - servletCtx.SetAttribute(og.SessionTargetIDKey, probe.ProbeKey) + servletCtx.SetAttribute(og.SessionTargetIDKey, probeKey) - return extHeader, nil + return nil, nil } func (s *DataServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) { diff --git a/servlet/probe-servlet.go b/servlet/probe-servlet.go index 05b4c76..5f6a15c 100644 --- a/servlet/probe-servlet.go +++ b/servlet/probe-servlet.go @@ -89,7 +89,7 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re return nil, fmt.Errorf("grpc call Error: %s", err.Error()) } - probe := ocpm.Probe{} + probe := &ocpm.Probe{} err = json.Unmarshal([]byte(r), probe) if nil != err { return nil, fmt.Errorf("grpc result unMarshal Error: %s", err.Error()) @@ -98,9 +98,9 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re extHeader := &fasthttp.ResponseHeader{} extHeader.Add(ocpc.HTTPResponseHeaderKey_Probe_SetEncryptionKey, probe.EncryptionKey) - servletCtx.SetAttribute(og.SessionIDKey, probe.ProbeKey) + servletCtx.SetAttribute(og.SessionIDKey, probeKey) servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE) - servletCtx.SetAttribute(og.SessionTargetIDKey, probe.ProbeKey) + servletCtx.SetAttribute(og.SessionTargetIDKey, probeKey) return extHeader, nil }