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
5744a9dd
Commit
5744a9dd
authored
Jun 24, 2021
by
Yohann D'Anello
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Announce neighbours to our peers
Signed-off-by:
Yohann D'ANELLO
<
ynerant@crans.org
>
parent
ba573ab7
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 @
5744a9dd
...
...
@@ -531,6 +531,13 @@ class BaseTunnelManager(object):
# XXX: Quick'n dirty way to log in a common place.
if
peer
and
self
.
_prefix
==
self
.
cache
.
registry_prefix
:
logging
.
info
(
"%s/%s: %s"
,
int
(
peer
,
2
),
len
(
peer
),
msg
)
elif
code
==
8
:
# neighbours
# The peer announced its neighbours
plen
=
len
(
self
.
_prefix
)
prefixes
=
[
msg
[
i
*
plen
:(
i
+
1
)
*
plen
]
for
i
in
range
(
len
(
msg
)
//
plen
)]
# FIXME Store neighbours of the peer instead of printing them
print
(
utils
.
ipFromBin
(
self
.
_network
+
peer
)
+
" has neighbours: "
+
str
(
list
(
map
(
lambda
prefix
:
utils
.
ipFromBin
(
self
.
_network
+
prefix
),
prefixes
))))
def
askInfo
(
self
,
prefix
):
return
self
.
sendto
(
prefix
,
'
\
4
'
+
self
.
_info
(
True
))
...
...
@@ -542,6 +549,18 @@ class BaseTunnelManager(object):
rina
.
shim
is
not
None
,
))
def
sendNeighbours
(
self
,
prefix
):
# Send our connected peers to the given neighbour
# The message has code 8 is directly the concatenation
# of prefixes of neighbours
msg
=
'
\
x08
'
for
neighbour
in
self
.
ctl
.
neighbours
:
# Don't announce ourself
if
neighbour
is
None
or
neighbour
==
prefix
:
continue
msg
+=
neighbour
return
self
.
sendto
(
prefix
,
msg
)
@
staticmethod
def
_restart
():
raise
utils
.
ReexecException
(
...
...
@@ -777,6 +796,13 @@ class TunnelManager(BaseTunnelManager):
self
.
_next_refresh
=
time
.
time
()
+
5
self
.
checkRoutingCache
()
# Send to our all neighbours who are our neighbours
for
neighbour
in
self
.
ctl
.
neighbours
.
keys
():
if
neighbour
is
None
:
continue
self
.
sendNeighbours
(
neighbour
)
def
babel_dump
(
self
):
t
=
time
.
time
()
if
self
.
_killing
:
...
...
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