ing
This commit is contained in:
parent
14c4949480
commit
2551703bc2
|
@ -9,8 +9,6 @@ import (
|
|||
cc "git.loafle.net/commons_go/config"
|
||||
ooccn "git.loafle.net/overflow/overflow_commons_go/config/noauthprobe"
|
||||
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
|
||||
noauthprobeM "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe/model"
|
||||
probeM "git.loafle.net/overflow/overflow_commons_go/modules/probe/model"
|
||||
oopai "git.loafle.net/overflow/overflow_probes/auth/info"
|
||||
"git.loafle.net/overflow/overflow_probes/config"
|
||||
)
|
||||
|
@ -22,26 +20,31 @@ type NoAuthProbeService struct {
|
|||
Config ooccn.NoAuthProbeConfig
|
||||
}
|
||||
|
||||
func (s *NoAuthProbeService) Accept(probe *probeM.Probe) {
|
||||
config.Config.Probe.Key = &probe.ProbeKey
|
||||
func (s *NoAuthProbeService) Accept(probeKey string) error {
|
||||
config.Config.Probe.Key = &probeKey
|
||||
|
||||
if err := cc.Save(*config.Config, *config.ConfigFilePath, true); nil != err {
|
||||
s.DoneChan <- fmt.Errorf("Auth: Saving of config file[%s] failed error[%v]", *config.ConfigFilePath, err)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
logging.Logger().Info(fmt.Sprintf("Auth: Probe[%s] has been accepted from central", probeKey))
|
||||
s.DoneChan <- nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *NoAuthProbeService) Deny(noAuthProbe *noauthprobeM.NoAuthProbe) {
|
||||
func (s *NoAuthProbeService) Deny() error {
|
||||
n := time.Now()
|
||||
s.Config.DenyDate = &n
|
||||
if err := cc.Save(s.Config, s.ConfigPath, true); nil != err {
|
||||
s.DoneChan <- fmt.Errorf("Auth: Saving of NoAuth config file[%s] failed error[%v]", s.ConfigPath, err)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
logging.Logger().Info(fmt.Sprintf("Auth: Probe has been denyed from central"))
|
||||
s.DoneChan <- nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *NoAuthProbeService) GetRequestHeader() map[string][]string {
|
||||
|
@ -53,7 +56,7 @@ func (s *NoAuthProbeService) GetRequestHeader() map[string][]string {
|
|||
|
||||
case ooccn.NoAuthProbeStateTypeRegisterd:
|
||||
header[oocmn.HTTPRequestHeaderKey_NoAuthProbe_Method] = []string{oocmn.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect}
|
||||
header[oocmn.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey] = []string{oocmn.HTTPRequestHeaderValue_NoAuthProbe_Method_Connect}
|
||||
header[oocmn.HTTPRequestHeaderKey_NoAuthProbe_TempProbeKey] = []string{*s.Config.TempKey}
|
||||
}
|
||||
|
||||
return header
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
func newSocketBuilder() cwfc.SocketBuilder {
|
||||
sb := &SocketBuilders{}
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_Data)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.
|
|||
}
|
||||
|
||||
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been disconnected soc[%v]", soc))
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ func (sh *SocketHandlers) OnConnect(socketContext cwfc.SocketContext, res *http.
|
|||
}
|
||||
|
||||
func (sh *SocketHandlers) OnDisconnect(soc cwfc.Socket) {
|
||||
logging.Logger().Info(fmt.Sprintf("Auth: client has been disconnected soc[%v]", soc))
|
||||
logging.Logger().Info(fmt.Sprintf("Probe: client has been disconnected soc[%v]", soc))
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
func NewSocketBuilder(entryPath string) *SocketBuilders {
|
||||
sb := &SocketBuilders{}
|
||||
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmp.HTTPEntry_Probe)
|
||||
sb.SocketBuilders = oopccc.NewSocketBuilder(entryPath)
|
||||
if nil == sb.SocketBuilders {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
"readBufferSize": 8192,
|
||||
"writeBufferSize": 8192
|
||||
},
|
||||
"probe": {
|
||||
"key": "95d8bcdc739741dca74c4a0e489e0774"
|
||||
},
|
||||
"paths": {
|
||||
"root": "",
|
||||
"bin": "bin",
|
||||
"config": "config",
|
||||
"pid": "pid"
|
||||
"pid": "pid",
|
||||
"root": ""
|
||||
}
|
||||
}
|
||||
}
|
3
noauthprobe.json
Normal file
3
noauthprobe.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"tempKey": "969946e1-4de3-486a-b11c-00d311244c3a"
|
||||
}
|
Loading…
Reference in New Issue
Block a user