Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-pubsub
Commits
69868db8
Commit
69868db8
authored
Feb 09, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove obsolete explicit IP whitelisting in favor of subnets
parent
84f577bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
17 deletions
+11
-17
score.go
score.go
+2
-7
score_params.go
score_params.go
+3
-4
score_test.go
score_test.go
+6
-6
No files found.
score.go
View file @
69868db8
...
...
@@ -338,14 +338,9 @@ func (ps *peerScore) ipColocationFactor(p peer.ID) float64 {
var
result
float64
loop
:
for
_
,
ip
:=
range
pstats
.
ips
{
_
,
whitelisted
:=
ps
.
params
.
IPColocationFactorWhitelist
[
ip
]
if
whitelisted
{
continue
}
if
len
(
ps
.
params
.
IPColocationFactorWhitelistSubnets
)
>
0
{
if
len
(
ps
.
params
.
IPColocationFactorWhitelist
)
>
0
{
ipObj
:=
net
.
ParseIP
(
ip
)
for
_
,
ipNet
:=
range
ps
.
params
.
IPColocationFactorWhitelist
Subnets
{
for
_
,
ipNet
:=
range
ps
.
params
.
IPColocationFactorWhitelist
{
if
ipNet
.
Contains
(
ipObj
)
{
continue
loop
}
...
...
score_params.go
View file @
69868db8
...
...
@@ -70,10 +70,9 @@ type PeerScoreParams struct {
// The weight of the parameter MUST be negative, unless you want to disable for testing.
// Note: In order to simulate many IPs in a managable manner when testing, you can set the weight to 0
// thus disabling the IP colocation penalty.
IPColocationFactorWeight
float64
IPColocationFactorThreshold
int
IPColocationFactorWhitelist
map
[
string
]
struct
{}
IPColocationFactorWhitelistSubnets
[]
*
net
.
IPNet
IPColocationFactorWeight
float64
IPColocationFactorThreshold
int
IPColocationFactorWhitelist
[]
*
net
.
IPNet
// P7: behavioural pattern penalties.
// This parameter has an associated counter which tracks misbehaviour as detected by the
...
...
score_test.go
View file @
69868db8
...
...
@@ -743,7 +743,7 @@ func TestScoreIPColocation(t *testing.T) {
}
}
func
TestScoreIPColocationWhitelist
Subnet
(
t
*
testing
.
T
)
{
func
TestScoreIPColocationWhitelist
(
t
*
testing
.
T
)
{
// Create parameters with reasonable default values
mytopic
:=
"mytopic"
...
...
@@ -753,11 +753,11 @@ func TestScoreIPColocationWhitelistSubnet(t *testing.T) {
}
params
:=
&
PeerScoreParams
{
AppSpecificScore
:
func
(
peer
.
ID
)
float64
{
return
0
},
IPColocationFactorThreshold
:
1
,
IPColocationFactorWeight
:
-
1
,
IPColocationFactorWhitelist
Subnets
:
[]
*
net
.
IPNet
{
ipNet
},
Topics
:
make
(
map
[
string
]
*
TopicScoreParams
),
AppSpecificScore
:
func
(
peer
.
ID
)
float64
{
return
0
},
IPColocationFactorThreshold
:
1
,
IPColocationFactorWeight
:
-
1
,
IPColocationFactorWhitelist
:
[]
*
net
.
IPNet
{
ipNet
},
Topics
:
make
(
map
[
string
]
*
TopicScoreParams
),
}
peerA
:=
peer
.
ID
(
"A"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment