This commit is contained in:
crusader 2018-04-17 23:10:13 +09:00
parent c33a743a25
commit 5e3f820eb3
2 changed files with 7 additions and 18 deletions

View File

@ -3,7 +3,6 @@ package servlet
import ( import (
"context" "context"
"crypto/rsa" "crypto/rsa"
"encoding/json"
"fmt" "fmt"
"sync" "sync"
@ -12,7 +11,6 @@ import (
"git.loafle.net/commons/server-go" "git.loafle.net/commons/server-go"
"git.loafle.net/commons/server-go/socket" "git.loafle.net/commons/server-go/socket"
ocpc "git.loafle.net/overflow/commons-go/probe/constants" ocpc "git.loafle.net/overflow/commons-go/probe/constants"
ocpm "git.loafle.net/overflow/commons-go/probe/model"
og "git.loafle.net/overflow/gateway" og "git.loafle.net/overflow/gateway"
"git.loafle.net/overflow/gateway/external/grpc" "git.loafle.net/overflow/gateway/external/grpc"
ogrs "git.loafle.net/overflow/gateway_rpc/servlet" 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) probeKey := string(bProbeKey)
grpcCTX := context.Background() grpcCTX := context.Background()
r, err := grpc.Exec(grpcCTX, "ProbeService.readByProbeKey", probeKey) _, err := grpc.Exec(grpcCTX, "ProbeService.readByProbeKey", probeKey)
if nil != err { if nil != err {
return nil, fmt.Errorf("grpc call Error: %s", err.Error()) return nil, fmt.Errorf("grpc call Error: %s", err.Error())
} }
probe := ocpm.Probe{} servletCtx.SetAttribute(og.SessionIDKey, probeKey)
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.SessionClientTypeKey, og.PROBE) 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) { func (s *DataServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) {

View File

@ -89,7 +89,7 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re
return nil, fmt.Errorf("grpc call Error: %s", err.Error()) return nil, fmt.Errorf("grpc call Error: %s", err.Error())
} }
probe := ocpm.Probe{} probe := &ocpm.Probe{}
err = json.Unmarshal([]byte(r), probe) err = json.Unmarshal([]byte(r), probe)
if nil != err { if nil != err {
return nil, fmt.Errorf("grpc result unMarshal Error: %s", err.Error()) 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 := &fasthttp.ResponseHeader{}
extHeader.Add(ocpc.HTTPResponseHeaderKey_Probe_SetEncryptionKey, probe.EncryptionKey) 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.SessionClientTypeKey, og.PROBE)
servletCtx.SetAttribute(og.SessionTargetIDKey, probe.ProbeKey) servletCtx.SetAttribute(og.SessionTargetIDKey, probeKey)
return extHeader, nil return extHeader, nil
} }