From 01f4e9b1318d786b0c450b390e2ff5c120b3914e Mon Sep 17 00:00:00 2001 From: vsmk98 Date: Wed, 14 Aug 2019 14:15:02 +0800 Subject: [PATCH] permission: node validation changed from string compare to enode id match in ValidateNodeForTxn --- core/types/permissions_cache.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/types/permissions_cache.go b/core/types/permissions_cache.go index 2726e6651..23341339a 100644 --- a/core/types/permissions_cache.go +++ b/core/types/permissions_cache.go @@ -1,8 +1,8 @@ package types import ( + "github.com/ethereum/go-ethereum/p2p/enode" "math/big" - "strings" "sync" "github.com/ethereum/go-ethereum/common" @@ -391,15 +391,25 @@ func ValidateNodeForTxn(enodeId string, from common.Address) bool { if enodeId == "" { return true } + + passedEnodeId, err := enode.ParseV4(enodeId) + if err != nil { + return false + } + ac := AcctInfoMap.GetAccount(from) if ac == nil { return true } + ultimateParent := OrgInfoMap.GetOrg(ac.OrgId).UltimateParent // scan through the node list and validate for _, n := range NodeInfoMap.GetNodeList() { - if OrgInfoMap.GetOrg(n.OrgId).UltimateParent == ultimateParent && strings.Contains(n.Url, enodeId) { - return true + if OrgInfoMap.GetOrg(n.OrgId).UltimateParent == ultimateParent { + recEnodeId, _ := enode.ParseV4(n.Url) + if recEnodeId.ID() == passedEnodeId.ID() { + return true + } } } return false