Skip to content

Commit 92c0615

Browse files
committed
v1.3.2 data discovery fix key init and response
1 parent 7ea1450 commit 92c0615

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

data/setting.go

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ func LoadSettings() {
296296
NodeSetting.DataDiscoveryEnabled = PrimarySetting.DataDiscoveryEnabled
297297
NodeSetting.DataDiscoveryAPI = PrimarySetting.DataDiscoveryAPI
298298
NodeSetting.DataDiscoveryKey = PrimarySetting.DataDiscoveryKey
299+
DataDiscoveryKey, _ = hex.DecodeString(NodeSetting.DataDiscoveryKey)
299300
return
300301
}
301302
// Replica nodes, load to Memory

firewall/data_discovery.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func CheckDiscoveryRules(value string, r *http.Request) {
161161
if _, ok := discoveryCache.Get(uid); !ok {
162162
// Set cache
163163
discoveryCache.Set(uid, 1, cache.DefaultExpiration)
164-
if len(data.NodeSetting.DataDiscoveryAPI) == 0 {
164+
if len(data.NodeSetting.DataDiscoveryAPI) == 0 || len(data.NodeSetting.DataDiscoveryKey) == 0 {
165165
return
166166
}
167167
// report
@@ -176,17 +176,17 @@ func CheckDiscoveryRules(value string, r *http.Request) {
176176
resp, err := utils.GetResponse(request)
177177
if err != nil {
178178
utils.DebugPrintln("Report Data Discovery", err)
179-
continue
179+
return
180180
}
181-
rpcResp := models.RPCResponse{}
181+
rpcResp := DataDiscoveryAPIResponse{}
182182
err = json.Unmarshal(resp, &rpcResp)
183183
if err != nil {
184184
utils.DebugPrintln("Report Data Discovery Unmarshal", err)
185-
continue
185+
return
186186
}
187-
if len(*rpcResp.Error) > 0 {
188-
utils.DebugPrintln("Report Data Discovery, Receive Error:", *rpcResp.Error)
189-
continue
187+
if rpcResp.Status != 0 {
188+
utils.DebugPrintln("Report Data Discovery, Receive Error:", rpcResp.Error)
189+
return
190190
}
191191
}
192192
//else {
@@ -213,9 +213,8 @@ func Anonymize(value string) string {
213213
return string(runeValue)
214214
}
215215

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

0 commit comments

Comments
 (0)