Skip to content

Commit

Permalink
v1.3.2 data discovery fix key init and response
Browse files Browse the repository at this point in the history
  • Loading branch information
janusec2 committed Mar 18, 2023
1 parent 7ea1450 commit 92c0615
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions data/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func LoadSettings() {
NodeSetting.DataDiscoveryEnabled = PrimarySetting.DataDiscoveryEnabled
NodeSetting.DataDiscoveryAPI = PrimarySetting.DataDiscoveryAPI
NodeSetting.DataDiscoveryKey = PrimarySetting.DataDiscoveryKey
DataDiscoveryKey, _ = hex.DecodeString(NodeSetting.DataDiscoveryKey)
return
}
// Replica nodes, load to Memory
Expand Down
21 changes: 10 additions & 11 deletions firewall/data_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func CheckDiscoveryRules(value string, r *http.Request) {
if _, ok := discoveryCache.Get(uid); !ok {
// Set cache
discoveryCache.Set(uid, 1, cache.DefaultExpiration)
if len(data.NodeSetting.DataDiscoveryAPI) == 0 {
if len(data.NodeSetting.DataDiscoveryAPI) == 0 || len(data.NodeSetting.DataDiscoveryKey) == 0 {
return
}
// report
Expand All @@ -176,17 +176,17 @@ func CheckDiscoveryRules(value string, r *http.Request) {
resp, err := utils.GetResponse(request)
if err != nil {
utils.DebugPrintln("Report Data Discovery", err)
continue
return
}
rpcResp := models.RPCResponse{}
rpcResp := DataDiscoveryAPIResponse{}
err = json.Unmarshal(resp, &rpcResp)
if err != nil {
utils.DebugPrintln("Report Data Discovery Unmarshal", err)
continue
return
}
if len(*rpcResp.Error) > 0 {
utils.DebugPrintln("Report Data Discovery, Receive Error:", *rpcResp.Error)
continue
if rpcResp.Status != 0 {
utils.DebugPrintln("Report Data Discovery, Receive Error:", rpcResp.Error)
return
}
}
//else {
Expand All @@ -213,9 +213,8 @@ func Anonymize(value string) string {
return string(runeValue)
}

type RPCResponse struct {
type DataDiscoveryAPIResponse struct {
// Status 0 represent OK, -1 or non 0 represent abnormal
Status int64 `json:"status"`
Error string `json:"err"`
Data interface{} `json:"data"`
Status int64 `json:"status"`
Error string `json:"err"`
}

0 comments on commit 92c0615

Please sign in to comment.