mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-26 00:11:36 +00:00
Case-insensitive checking of null if string, don't print the nodeinfo again
This commit is contained in:
parent
586deed0f9
commit
f6b0075989
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -114,7 +115,7 @@ func (m *nodeinfo) setNodeInfo(given interface{}, privacy bool) error {
|
|||||||
if nodeinfomap, ok := given.(map[string]interface{}); ok {
|
if nodeinfomap, ok := given.(map[string]interface{}); ok {
|
||||||
for key, value := range nodeinfomap {
|
for key, value := range nodeinfomap {
|
||||||
if _, ok := defaults[key]; ok {
|
if _, ok := defaults[key]; ok {
|
||||||
if strvalue, strok := value.(string); strok && strvalue == "null" || value == nil {
|
if strvalue, strok := value.(string); strok && strings.EqualFold(strvalue, "null") || value == nil {
|
||||||
delete(newnodeinfo, key)
|
delete(newnodeinfo, key)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -123,7 +124,6 @@ func (m *nodeinfo) setNodeInfo(given interface{}, privacy bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if newjson, err := json.Marshal(newnodeinfo); err == nil {
|
if newjson, err := json.Marshal(newnodeinfo); err == nil {
|
||||||
m.core.log.Println(string(newjson))
|
|
||||||
if len(newjson) > 16384 {
|
if len(newjson) > 16384 {
|
||||||
return errors.New("NodeInfo exceeds max length of 16384 bytes")
|
return errors.New("NodeInfo exceeds max length of 16384 bytes")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user