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
6c1addf4
Commit
6c1addf4
authored
Feb 12, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more intelligent handling of ip whitelist check
parent
69868db8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
score.go
score.go
+21
-4
No files found.
score.go
View file @
6c1addf4
...
...
@@ -27,6 +27,9 @@ type peerStats struct {
// IP tracking; store as string for easy processing
ips
[]
string
// IP whitelisting cache
ipWhitelist
map
[
string
]
bool
// behavioural pattern penalties (applied by the router)
behaviourPenalty
float64
}
...
...
@@ -339,11 +342,25 @@ func (ps *peerScore) ipColocationFactor(p peer.ID) float64 {
loop
:
for
_
,
ip
:=
range
pstats
.
ips
{
if
len
(
ps
.
params
.
IPColocationFactorWhitelist
)
>
0
{
ipObj
:=
net
.
ParseIP
(
ip
)
for
_
,
ipNet
:=
range
ps
.
params
.
IPColocationFactorWhitelist
{
if
ipNet
.
Contains
(
ipObj
)
{
continue
loop
if
pstats
.
ipWhitelist
==
nil
{
pstats
.
ipWhitelist
=
make
(
map
[
string
]
bool
)
}
whitelisted
,
ok
:=
pstats
.
ipWhitelist
[
ip
]
if
!
ok
{
ipObj
:=
net
.
ParseIP
(
ip
)
for
_
,
ipNet
:=
range
ps
.
params
.
IPColocationFactorWhitelist
{
if
ipNet
.
Contains
(
ipObj
)
{
pstats
.
ipWhitelist
[
ip
]
=
true
continue
loop
}
}
pstats
.
ipWhitelist
[
ip
]
=
false
}
if
whitelisted
{
continue
loop
}
}
...
...
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