permission: node validation changed from string compare to enode id match in ValidateNodeForTxn

This commit is contained in:
vsmk98 2019-08-14 14:15:02 +08:00
parent b53841d1d7
commit 01f4e9b131
1 changed files with 13 additions and 3 deletions

View File

@ -1,8 +1,8 @@
package types package types
import ( import (
"github.com/ethereum/go-ethereum/p2p/enode"
"math/big" "math/big"
"strings"
"sync" "sync"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -391,16 +391,26 @@ func ValidateNodeForTxn(enodeId string, from common.Address) bool {
if enodeId == "" { if enodeId == "" {
return true return true
} }
passedEnodeId, err := enode.ParseV4(enodeId)
if err != nil {
return false
}
ac := AcctInfoMap.GetAccount(from) ac := AcctInfoMap.GetAccount(from)
if ac == nil { if ac == nil {
return true return true
} }
ultimateParent := OrgInfoMap.GetOrg(ac.OrgId).UltimateParent ultimateParent := OrgInfoMap.GetOrg(ac.OrgId).UltimateParent
// scan through the node list and validate // scan through the node list and validate
for _, n := range NodeInfoMap.GetNodeList() { for _, n := range NodeInfoMap.GetNodeList() {
if OrgInfoMap.GetOrg(n.OrgId).UltimateParent == ultimateParent && strings.Contains(n.Url, enodeId) { if OrgInfoMap.GetOrg(n.OrgId).UltimateParent == ultimateParent {
recEnodeId, _ := enode.ParseV4(n.Url)
if recEnodeId.ID() == passedEnodeId.ID() {
return true return true
} }
} }
}
return false return false
} }