Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yohann D'Anello
re6stnet
Commits
35ed0e88
Commit
35ed0e88
authored
Jul 07, 2021
by
Yohann D'Anello
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect bad peers
Signed-off-by:
Yohann D'ANELLO
<
ynerant@crans.org
>
parent
38aeb326
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
re6st/tunnel.py
re6st/tunnel.py
+26
-0
No files found.
re6st/tunnel.py
View file @
35ed0e88
...
@@ -210,6 +210,7 @@ class BaseTunnelManager(object):
...
@@ -210,6 +210,7 @@ class BaseTunnelManager(object):
self
.
_neighbours_of_neighbours
=
{}
self
.
_neighbours_of_neighbours
=
{}
self
.
_sent_pings_distance_2
=
{}
self
.
_sent_pings_distance_2
=
{}
self
.
_received_pings_distance_2
=
{}
self
.
_received_pings_distance_2
=
{}
self
.
_bad_scores
=
{}
self
.
_served
=
defaultdict
(
dict
)
self
.
_served
=
defaultdict
(
dict
)
self
.
_version
=
cache
.
version
self
.
_version
=
cache
.
version
self
.
_conf_country
=
conf_country
self
.
_conf_country
=
conf_country
...
@@ -825,14 +826,39 @@ class TunnelManager(BaseTunnelManager):
...
@@ -825,14 +826,39 @@ class TunnelManager(BaseTunnelManager):
for
node
in
neighbours_order_2
:
for
node
in
neighbours_order_2
:
self
.
sendto
(
node
,
'
\
x09
\
x00
'
)
self
.
sendto
(
node
,
'
\
x09
\
x00
'
)
self
.
_sent_pings_distance_2
.
setdefault
(
node
,
[])
self
.
_sent_pings_distance_2
.
setdefault
(
node
,
[])
self
.
_received_pings_distance_2
.
setdefault
(
node
,
[])
# Store the sent ping
# Store the sent ping
self
.
_sent_pings_distance_2
[
node
].
append
(
datetime
.
now
())
self
.
_sent_pings_distance_2
[
node
].
append
(
datetime
.
now
())
# Check bad nodes
for
peer
in
self
.
_sent_pings_distance_2
.
keys
():
# 10 pings over 12 failed, node is not contactable.
# Add bad score to the forwarding node
if
len
(
self
.
_sent_pings_distance_2
[
peer
])
-
len
(
self
.
_received_pings_distance_2
[
peer
])
>=
10
:
print
(
peer
+
" is not reachable"
)
for
node
,
value
in
self
.
ctl
.
neighbours
.
items
():
neighbour
,
routes
=
value
if
peer
in
routes
.
keys
():
break
else
:
print
(
"Unknown peer: "
+
peer
+
", ignoring..."
)
break
self
.
_bad_scores
.
setdefault
(
node
,
[])
self
.
_bad_scores
[
node
].
append
((
peer
,
datetime
.
now
()))
# Clean old pings
# Clean old pings
self
.
_sent_pings_distance_2
=
{
k
:
[
d
for
d
in
v
if
(
datetime
.
now
()
-
d
).
seconds
<
60
]
self
.
_sent_pings_distance_2
=
{
k
:
[
d
for
d
in
v
if
(
datetime
.
now
()
-
d
).
seconds
<
60
]
for
k
,
v
in
self
.
_sent_pings_distance_2
.
items
()}
for
k
,
v
in
self
.
_sent_pings_distance_2
.
items
()}
self
.
_received_pings_distance_2
=
{
k
:
[
d
for
d
in
v
if
(
datetime
.
now
()
-
d
).
seconds
<
60
]
self
.
_received_pings_distance_2
=
{
k
:
[
d
for
d
in
v
if
(
datetime
.
now
()
-
d
).
seconds
<
60
]
for
k
,
v
in
self
.
_received_pings_distance_2
.
items
()}
for
k
,
v
in
self
.
_received_pings_distance_2
.
items
()}
self
.
_bad_scores
=
{
k
:
[(
peer
,
d
)
for
(
peer
,
d
)
in
v
if
(
datetime
.
now
()
-
d
).
seconds
<
60
]
for
k
,
v
in
self
.
_bad_scores
.
items
()}
# Ignore bad nodes
for
peer
in
self
.
_bad_scores
.
keys
():
# FIXME Find better rule
if
self
.
_bad_scores
[
peer
]:
print
(
peer
+
" IS A BAD PEER!"
)
def
babel_dump
(
self
):
def
babel_dump
(
self
):
...
...
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