ing
This commit is contained in:
parent
5e3f820eb3
commit
3fb41cf0b3
11
config/config.go
Normal file
11
config/config.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
occe "git.loafle.net/overflow/commons-go/config/external"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ServerHandler *ogrs.ServerHandlers `json:"serverHandler"`
|
||||
External *occe.External `json:"external"`
|
||||
}
|
2
main.go
2
main.go
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
"git.loafle.net/commons/configuration-go"
|
||||
"git.loafle.net/commons/logging-go"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/server"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
cs "git.loafle.net/commons/server-go"
|
||||
oge "git.loafle.net/overflow/gateway/external"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/subscribe"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/subscribe"
|
||||
)
|
||||
|
||||
type ServerHandler interface {
|
||||
|
|
|
@ -2,7 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
cssw "git.loafle.net/commons/server-go/socket/web"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/config"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/servlet"
|
||||
)
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
"git.loafle.net/commons/logging-go"
|
||||
"git.loafle.net/commons/server-go"
|
||||
"git.loafle.net/commons/server-go/socket"
|
||||
ocnc "git.loafle.net/overflow/commons-go/noauthprobe/constants"
|
||||
ocnm "git.loafle.net/overflow/commons-go/noauthprobe/model"
|
||||
occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
|
||||
ocmn "git.loafle.net/overflow/commons-go/model/noauthprobe"
|
||||
og "git.loafle.net/overflow/gateway"
|
||||
"git.loafle.net/overflow/gateway/external/grpc"
|
||||
ogs "git.loafle.net/overflow/gateway/subscribe"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/subscribe"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/subscribe"
|
||||
)
|
||||
|
||||
type AuthServlet interface {
|
||||
|
@ -41,7 +41,7 @@ func (s *AuthServlets) OnStart(serverCtx server.ServerCtx) error {
|
|||
return err
|
||||
}
|
||||
|
||||
subscribeChan, err := subscribe.Subscriber.Subscribe(ocnc.HTTPEntry_Auth)
|
||||
subscribeChan, err := subscribe.Subscriber.Subscribe(occn.HTTPEntry_Auth)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func (s *AuthServlets) OnStart(serverCtx server.ServerCtx) error {
|
|||
}
|
||||
|
||||
func (s *AuthServlets) OnStop(serverCtx server.ServerCtx) {
|
||||
if err := subscribe.Subscriber.Unsubscribe(ocnc.HTTPEntry_Auth); nil != err {
|
||||
if err := subscribe.Subscriber.Unsubscribe(occn.HTTPEntry_Auth); nil != err {
|
||||
logging.Logger().Warn(err)
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (s *AuthServlets) Destroy(serverCtx server.ServerCtx) {
|
|||
}
|
||||
|
||||
func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
||||
bMethod := ctx.Request.Header.Peek(ocnc.HTTPRequestHeaderKey_NoAuthProbe_Method)
|
||||
bMethod := ctx.Request.Header.Peek(occn.HTTPRequestHeaderKey_NoAuthProbe_Method)
|
||||
|
||||
if nil == bMethod {
|
||||
return nil, fmt.Errorf("Unexpected noauth probe method: %v", bMethod)
|
||||
|
@ -73,8 +73,8 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
|
|||
method := string(bMethod)
|
||||
|
||||
switch method {
|
||||
case ocnc.HTTPRequestHeaderValue_NoAuthProbe_Method_Regist:
|
||||
bInfo := ctx.Request.Header.Peek(ocnc.HTTPRequestHeaderKey_NoAuthProbe_Info)
|
||||
case occn.HTTPRequestHeaderValue_NoAuthProbe_Method_Regist:
|
||||
bInfo := ctx.Request.Header.Peek(occn.HTTPRequestHeaderKey_NoAuthProbe_Info)
|
||||
if nil == bInfo {
|
||||
return nil, fmt.Errorf("Unexpected Request Header Key NoAuthProbe Info")
|
||||
}
|
||||
|
@ -89,22 +89,22 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
|
|||
if nil != err {
|
||||
return nil, fmt.Errorf("grpc call Error: %s", err.Error())
|
||||
}
|
||||
nap := &ocnm.NoAuthProbe{}
|
||||
nap := &ocmn.NoAuthProbe{}
|
||||
err = json.Unmarshal([]byte(r), nap)
|
||||
if nil != err {
|
||||
return nil, fmt.Errorf("grpc result unMarshal Error: %s", err.Error())
|
||||
}
|
||||
|
||||
extHeader := &fasthttp.ResponseHeader{}
|
||||
extHeader.Add(ocnc.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey, nap.TempProbeKey)
|
||||
extHeader.Add(occn.HTTPResponseHeaderKey_NoAuthProbe_SetTempProbeKey, nap.TempProbeKey)
|
||||
|
||||
servletCtx.SetAttribute(og.SessionIDKey, nap.TempProbeKey)
|
||||
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE)
|
||||
servletCtx.SetAttribute(og.SessionTargetIDKey, nap.TempProbeKey)
|
||||
|
||||
return extHeader, nil
|
||||
case ocnc.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect:
|
||||
bTempProbeKey := ctx.Request.Header.Peek(ocnc.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey)
|
||||
case occn.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect:
|
||||
bTempProbeKey := ctx.Request.Header.Peek(occn.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey)
|
||||
if nil == bTempProbeKey {
|
||||
return nil, fmt.Errorf("Noauth probe temp key is not an existing key")
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"git.loafle.net/commons/server-go"
|
||||
"git.loafle.net/commons/server-go/socket"
|
||||
ocpc "git.loafle.net/overflow/commons-go/probe/constants"
|
||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||
og "git.loafle.net/overflow/gateway"
|
||||
"git.loafle.net/overflow/gateway/external/grpc"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
|
||||
|
@ -57,7 +57,7 @@ func (s *DataServlets) Destroy(serverCtx server.ServerCtx) {
|
|||
|
||||
func (s *DataServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
||||
// probe key extraction
|
||||
bMethod := ctx.Request.Header.Peek(ocpc.HTTPRequestHeaderKey_Probe_Method)
|
||||
bMethod := ctx.Request.Header.Peek(occp.HTTPRequestHeaderKey_Probe_Method)
|
||||
if nil == bMethod {
|
||||
return nil, fmt.Errorf("Unexpected probe method: %v", bMethod)
|
||||
}
|
||||
|
@ -65,12 +65,12 @@ func (s *DataServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req
|
|||
method := string(bMethod)
|
||||
|
||||
switch method {
|
||||
case ocpc.HTTPRequestHeaderValue_Probe_Method_Connect:
|
||||
case occp.HTTPRequestHeaderValue_Probe_Method_Connect:
|
||||
default:
|
||||
return nil, fmt.Errorf("Unexpected probe method: %s", method)
|
||||
}
|
||||
|
||||
bProbeKey := ctx.Request.Header.Peek(ocpc.HTTPRequestHeaderKey_Probe_ProbeKey)
|
||||
bProbeKey := ctx.Request.Header.Peek(occp.HTTPRequestHeaderKey_Probe_ProbeKey)
|
||||
if nil == bProbeKey {
|
||||
return nil, fmt.Errorf("Unexpected probe key : %v", bProbeKey)
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ import (
|
|||
"git.loafle.net/commons/logging-go"
|
||||
"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"
|
||||
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||
ocmp "git.loafle.net/overflow/commons-go/model/probe"
|
||||
og "git.loafle.net/overflow/gateway"
|
||||
"git.loafle.net/overflow/gateway/external/grpc"
|
||||
ogs "git.loafle.net/overflow/gateway/subscribe"
|
||||
ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
|
||||
"git.loafle.net/overflow/member_gateway_rpc/subscribe"
|
||||
"git.loafle.net/overflow/probe_gateway_rpc/subscribe"
|
||||
)
|
||||
|
||||
type ProbeServlet interface {
|
||||
|
@ -40,7 +40,7 @@ func (s *ProbeServlets) OnStart(serverCtx server.ServerCtx) error {
|
|||
return err
|
||||
}
|
||||
|
||||
subscribeChan, err := subscribe.Subscriber.Subscribe(ocpc.HTTPEntry_Probe)
|
||||
subscribeChan, err := subscribe.Subscriber.Subscribe(occp.HTTPEntry_Probe)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func (s *ProbeServlets) OnStart(serverCtx server.ServerCtx) error {
|
|||
}
|
||||
|
||||
func (s *ProbeServlets) OnStop(serverCtx server.ServerCtx) {
|
||||
if err := subscribe.Subscriber.Unsubscribe(ocpc.HTTPEntry_Probe); nil != err {
|
||||
if err := subscribe.Subscriber.Unsubscribe(occp.HTTPEntry_Probe); nil != err {
|
||||
logging.Logger().Warn(err)
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ func (s *ProbeServlets) Destroy(serverCtx server.ServerCtx) {
|
|||
}
|
||||
|
||||
func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
||||
bMethod := ctx.Request.Header.Peek(ocpc.HTTPRequestHeaderKey_Probe_Method)
|
||||
bMethod := ctx.Request.Header.Peek(occp.HTTPRequestHeaderKey_Probe_Method)
|
||||
if nil == bMethod {
|
||||
return nil, fmt.Errorf("Unexpected probe method: %v", bMethod)
|
||||
}
|
||||
|
@ -71,12 +71,12 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re
|
|||
method := string(bMethod)
|
||||
|
||||
switch method {
|
||||
case ocpc.HTTPRequestHeaderValue_Probe_Method_Connect:
|
||||
case occp.HTTPRequestHeaderValue_Probe_Method_Connect:
|
||||
default:
|
||||
return nil, fmt.Errorf("Unexpected probe method: %s", method)
|
||||
}
|
||||
|
||||
bProbeKey := ctx.Request.Header.Peek(ocpc.HTTPRequestHeaderKey_Probe_ProbeKey)
|
||||
bProbeKey := ctx.Request.Header.Peek(occp.HTTPRequestHeaderKey_Probe_ProbeKey)
|
||||
if nil == bProbeKey {
|
||||
return nil, fmt.Errorf("Unexpected probe key : %v", bProbeKey)
|
||||
}
|
||||
|
@ -89,14 +89,14 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re
|
|||
return nil, fmt.Errorf("grpc call Error: %s", err.Error())
|
||||
}
|
||||
|
||||
probe := &ocpm.Probe{}
|
||||
probe := &ocmp.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)
|
||||
extHeader.Add(occp.HTTPResponseHeaderKey_Probe_SetEncryptionKey, probe.EncryptionKey)
|
||||
|
||||
servletCtx.SetAttribute(og.SessionIDKey, probeKey)
|
||||
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE)
|
||||
|
|
32
subscribe/subscribe.go
Normal file
32
subscribe/subscribe.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package subscribe
|
||||
|
||||
import (
|
||||
"git.loafle.net/commons/logging-go"
|
||||
oger "git.loafle.net/overflow/gateway/external/redis"
|
||||
ogsr "git.loafle.net/overflow/gateway/subscribe/redis"
|
||||
)
|
||||
|
||||
var Subscriber *ogsr.Subscribers
|
||||
|
||||
func InitPackage() {
|
||||
Subscriber = &ogsr.Subscribers{}
|
||||
Subscriber.Conn = oger.Pool.Get()
|
||||
if err := Subscriber.Start(); nil != err {
|
||||
logging.Logger().Panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func StartPackage() {
|
||||
}
|
||||
|
||||
func StopPackage() {
|
||||
}
|
||||
|
||||
func DestroyPackage() {
|
||||
if nil != Subscriber {
|
||||
if err := Subscriber.Stop(); nil != err {
|
||||
logging.Logger().Error(err)
|
||||
}
|
||||
}
|
||||
Subscriber = nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user