remove obsolete explicit IP whitelisting in favor of subnets
This commit is contained in:
parent
84f577bdd1
commit
69868db8cf
9
score.go
9
score.go
|
@ -338,14 +338,9 @@ func (ps *peerScore) ipColocationFactor(p peer.ID) float64 {
|
||||||
var result float64
|
var result float64
|
||||||
loop:
|
loop:
|
||||||
for _, ip := range pstats.ips {
|
for _, ip := range pstats.ips {
|
||||||
_, whitelisted := ps.params.IPColocationFactorWhitelist[ip]
|
if len(ps.params.IPColocationFactorWhitelist) > 0 {
|
||||||
if whitelisted {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ps.params.IPColocationFactorWhitelistSubnets) > 0 {
|
|
||||||
ipObj := net.ParseIP(ip)
|
ipObj := net.ParseIP(ip)
|
||||||
for _, ipNet := range ps.params.IPColocationFactorWhitelistSubnets {
|
for _, ipNet := range ps.params.IPColocationFactorWhitelist {
|
||||||
if ipNet.Contains(ipObj) {
|
if ipNet.Contains(ipObj) {
|
||||||
continue loop
|
continue loop
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,7 @@ type PeerScoreParams struct {
|
||||||
// thus disabling the IP colocation penalty.
|
// thus disabling the IP colocation penalty.
|
||||||
IPColocationFactorWeight float64
|
IPColocationFactorWeight float64
|
||||||
IPColocationFactorThreshold int
|
IPColocationFactorThreshold int
|
||||||
IPColocationFactorWhitelist map[string]struct{}
|
IPColocationFactorWhitelist []*net.IPNet
|
||||||
IPColocationFactorWhitelistSubnets []*net.IPNet
|
|
||||||
|
|
||||||
// P7: behavioural pattern penalties.
|
// P7: behavioural pattern penalties.
|
||||||
// This parameter has an associated counter which tracks misbehaviour as detected by the
|
// This parameter has an associated counter which tracks misbehaviour as detected by the
|
||||||
|
|
|
@ -743,7 +743,7 @@ func TestScoreIPColocation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScoreIPColocationWhitelistSubnet(t *testing.T) {
|
func TestScoreIPColocationWhitelist(t *testing.T) {
|
||||||
// Create parameters with reasonable default values
|
// Create parameters with reasonable default values
|
||||||
mytopic := "mytopic"
|
mytopic := "mytopic"
|
||||||
|
|
||||||
|
@ -756,7 +756,7 @@ func TestScoreIPColocationWhitelistSubnet(t *testing.T) {
|
||||||
AppSpecificScore: func(peer.ID) float64 { return 0 },
|
AppSpecificScore: func(peer.ID) float64 { return 0 },
|
||||||
IPColocationFactorThreshold: 1,
|
IPColocationFactorThreshold: 1,
|
||||||
IPColocationFactorWeight: -1,
|
IPColocationFactorWeight: -1,
|
||||||
IPColocationFactorWhitelistSubnets: []*net.IPNet{ipNet},
|
IPColocationFactorWhitelist: []*net.IPNet{ipNet},
|
||||||
Topics: make(map[string]*TopicScoreParams),
|
Topics: make(map[string]*TopicScoreParams),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue