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/configuration-go"
|
||||||
"git.loafle.net/commons/logging-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"
|
"git.loafle.net/overflow/probe_gateway_rpc/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
cs "git.loafle.net/commons/server-go"
|
cs "git.loafle.net/commons/server-go"
|
||||||
oge "git.loafle.net/overflow/gateway/external"
|
oge "git.loafle.net/overflow/gateway/external"
|
||||||
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
||||||
"git.loafle.net/overflow/member_gateway_rpc/config"
|
"git.loafle.net/overflow/probe_gateway_rpc/config"
|
||||||
"git.loafle.net/overflow/member_gateway_rpc/subscribe"
|
"git.loafle.net/overflow/probe_gateway_rpc/subscribe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServerHandler interface {
|
type ServerHandler interface {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
cssw "git.loafle.net/commons/server-go/socket/web"
|
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"
|
"git.loafle.net/overflow/probe_gateway_rpc/servlet"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@ import (
|
||||||
"git.loafle.net/commons/logging-go"
|
"git.loafle.net/commons/logging-go"
|
||||||
"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"
|
||||||
ocnc "git.loafle.net/overflow/commons-go/noauthprobe/constants"
|
occn "git.loafle.net/overflow/commons-go/config/noauthprobe"
|
||||||
ocnm "git.loafle.net/overflow/commons-go/noauthprobe/model"
|
ocmn "git.loafle.net/overflow/commons-go/model/noauthprobe"
|
||||||
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"
|
||||||
ogs "git.loafle.net/overflow/gateway/subscribe"
|
ogs "git.loafle.net/overflow/gateway/subscribe"
|
||||||
ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
|
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 {
|
type AuthServlet interface {
|
||||||
|
@ -41,7 +41,7 @@ func (s *AuthServlets) OnStart(serverCtx server.ServerCtx) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeChan, err := subscribe.Subscriber.Subscribe(ocnc.HTTPEntry_Auth)
|
subscribeChan, err := subscribe.Subscriber.Subscribe(occn.HTTPEntry_Auth)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func (s *AuthServlets) OnStart(serverCtx server.ServerCtx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthServlets) OnStop(serverCtx server.ServerCtx) {
|
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)
|
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) {
|
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 {
|
if nil == bMethod {
|
||||||
return nil, fmt.Errorf("Unexpected noauth probe method: %v", 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)
|
method := string(bMethod)
|
||||||
|
|
||||||
switch method {
|
switch method {
|
||||||
case ocnc.HTTPRequestHeaderValue_NoAuthProbe_Method_Regist:
|
case occn.HTTPRequestHeaderValue_NoAuthProbe_Method_Regist:
|
||||||
bInfo := ctx.Request.Header.Peek(ocnc.HTTPRequestHeaderKey_NoAuthProbe_Info)
|
bInfo := ctx.Request.Header.Peek(occn.HTTPRequestHeaderKey_NoAuthProbe_Info)
|
||||||
if nil == bInfo {
|
if nil == bInfo {
|
||||||
return nil, fmt.Errorf("Unexpected Request Header Key NoAuthProbe Info")
|
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 {
|
if nil != err {
|
||||||
return nil, fmt.Errorf("grpc call Error: %s", err.Error())
|
return nil, fmt.Errorf("grpc call Error: %s", err.Error())
|
||||||
}
|
}
|
||||||
nap := &ocnm.NoAuthProbe{}
|
nap := &ocmn.NoAuthProbe{}
|
||||||
err = json.Unmarshal([]byte(r), nap)
|
err = json.Unmarshal([]byte(r), nap)
|
||||||
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())
|
||||||
}
|
}
|
||||||
|
|
||||||
extHeader := &fasthttp.ResponseHeader{}
|
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.SessionIDKey, nap.TempProbeKey)
|
||||||
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE)
|
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE)
|
||||||
servletCtx.SetAttribute(og.SessionTargetIDKey, nap.TempProbeKey)
|
servletCtx.SetAttribute(og.SessionTargetIDKey, nap.TempProbeKey)
|
||||||
|
|
||||||
return extHeader, nil
|
return extHeader, nil
|
||||||
case ocnc.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect:
|
case occn.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect:
|
||||||
bTempProbeKey := ctx.Request.Header.Peek(ocnc.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey)
|
bTempProbeKey := ctx.Request.Header.Peek(occn.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey)
|
||||||
if nil == bTempProbeKey {
|
if nil == bTempProbeKey {
|
||||||
return nil, fmt.Errorf("Noauth probe temp key is not an existing key")
|
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"
|
||||||
"git.loafle.net/commons/server-go/socket"
|
"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"
|
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"
|
||||||
|
@ -57,7 +57,7 @@ func (s *DataServlets) Destroy(serverCtx server.ServerCtx) {
|
||||||
|
|
||||||
func (s *DataServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
func (s *DataServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.RequestCtx) (*fasthttp.ResponseHeader, error) {
|
||||||
// probe key extraction
|
// probe key extraction
|
||||||
bMethod := ctx.Request.Header.Peek(ocpc.HTTPRequestHeaderKey_Probe_Method)
|
bMethod := ctx.Request.Header.Peek(occp.HTTPRequestHeaderKey_Probe_Method)
|
||||||
if nil == bMethod {
|
if nil == bMethod {
|
||||||
return nil, fmt.Errorf("Unexpected probe method: %v", 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)
|
method := string(bMethod)
|
||||||
|
|
||||||
switch method {
|
switch method {
|
||||||
case ocpc.HTTPRequestHeaderValue_Probe_Method_Connect:
|
case occp.HTTPRequestHeaderValue_Probe_Method_Connect:
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Unexpected probe method: %s", method)
|
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 {
|
if nil == bProbeKey {
|
||||||
return nil, fmt.Errorf("Unexpected probe key : %v", 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/logging-go"
|
||||||
"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"
|
occp "git.loafle.net/overflow/commons-go/config/probe"
|
||||||
ocpm "git.loafle.net/overflow/commons-go/probe/model"
|
ocmp "git.loafle.net/overflow/commons-go/model/probe"
|
||||||
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"
|
||||||
ogs "git.loafle.net/overflow/gateway/subscribe"
|
ogs "git.loafle.net/overflow/gateway/subscribe"
|
||||||
ogrs "git.loafle.net/overflow/gateway_rpc/servlet"
|
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 {
|
type ProbeServlet interface {
|
||||||
|
@ -40,7 +40,7 @@ func (s *ProbeServlets) OnStart(serverCtx server.ServerCtx) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeChan, err := subscribe.Subscriber.Subscribe(ocpc.HTTPEntry_Probe)
|
subscribeChan, err := subscribe.Subscriber.Subscribe(occp.HTTPEntry_Probe)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func (s *ProbeServlets) OnStart(serverCtx server.ServerCtx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ProbeServlets) OnStop(serverCtx server.ServerCtx) {
|
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)
|
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) {
|
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 {
|
if nil == bMethod {
|
||||||
return nil, fmt.Errorf("Unexpected probe method: %v", 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)
|
method := string(bMethod)
|
||||||
|
|
||||||
switch method {
|
switch method {
|
||||||
case ocpc.HTTPRequestHeaderValue_Probe_Method_Connect:
|
case occp.HTTPRequestHeaderValue_Probe_Method_Connect:
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Unexpected probe method: %s", method)
|
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 {
|
if nil == bProbeKey {
|
||||||
return nil, fmt.Errorf("Unexpected probe key : %v", 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())
|
return nil, fmt.Errorf("grpc call Error: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
probe := &ocpm.Probe{}
|
probe := &ocmp.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())
|
||||||
}
|
}
|
||||||
|
|
||||||
extHeader := &fasthttp.ResponseHeader{}
|
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.SessionIDKey, probeKey)
|
||||||
servletCtx.SetAttribute(og.SessionClientTypeKey, og.PROBE)
|
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