5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-22 18:45:40 +00:00

Case-insensitive checking of null if string, don't print the nodeinfo again

This commit is contained in:
Neil Alexander 2018-12-21 10:04:32 +00:00
parent 586deed0f9
commit f6b0075989
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"runtime"
"strings"
"sync"
"time"
@ -114,7 +115,7 @@ func (m *nodeinfo) setNodeInfo(given interface{}, privacy bool) error {
if nodeinfomap, ok := given.(map[string]interface{}); ok {
for key, value := range nodeinfomap {
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)
}
continue
@ -123,7 +124,6 @@ func (m *nodeinfo) setNodeInfo(given interface{}, privacy bool) error {
}
}
if newjson, err := json.Marshal(newnodeinfo); err == nil {
m.core.log.Println(string(newjson))
if len(newjson) > 16384 {
return errors.New("NodeInfo exceeds max length of 16384 bytes")
}