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
fbf3367d
Commit
fbf3367d
authored
Aug 13, 2021
by
Yohann D'Anello
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[monitoring] Send pings
Signed-off-by:
Yohann D'ANELLO
<
ynerant@crans.org
>
parent
a6bb0d25
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
+38
-5
re6st/tunnel.py
re6st/tunnel.py
+38
-5
No files found.
re6st/tunnel.py
View file @
fbf3367d
...
@@ -376,7 +376,7 @@ class BaseTunnelManager(object):
...
@@ -376,7 +376,7 @@ class BaseTunnelManager(object):
self
.
_forward
=
to
self
.
_forward
=
to
code
=
ord
(
msg
[
0
])
code
=
ord
(
msg
[
0
])
if
prefix
==
self
.
_prefix
:
if
prefix
==
self
.
_prefix
:
msg
=
self
.
_processPacket
(
msg
)
msg
=
self
.
_processPacket
(
msg
,
to
)
if
msg
:
if
msg
:
self
.
_sendto
(
to
,
'%s
\
0
%c%s'
%
(
prefix
,
code
,
msg
))
self
.
_sendto
(
to
,
'%s
\
0
%c%s'
%
(
prefix
,
code
,
msg
))
else
:
else
:
...
@@ -452,10 +452,10 @@ class BaseTunnelManager(object):
...
@@ -452,10 +452,10 @@ class BaseTunnelManager(object):
elif
msg
:
elif
msg
:
# We got a valid and non-empty message. Always reply
# We got a valid and non-empty message. Always reply
# something so that the sender knows we're still connected.
# something so that the sender knows we're still connected.
answer
=
self
.
_processPacket
(
msg
,
peer
.
prefix
)
answer
=
self
.
_processPacket
(
msg
,
to
,
peer
.
prefix
)
self
.
_sendto
(
to
,
msg
[
0
]
+
answer
if
answer
else
""
,
peer
)
self
.
_sendto
(
to
,
msg
[
0
]
+
answer
if
answer
else
""
,
peer
)
def
_processPacket
(
self
,
msg
,
peer
=
None
):
def
_processPacket
(
self
,
msg
,
sender
,
peer
=
None
):
c
=
ord
(
msg
[
0
])
c
=
ord
(
msg
[
0
])
msg
=
msg
[
1
:]
msg
=
msg
[
1
:]
code
=
c
&
0x7f
code
=
c
&
0x7f
...
@@ -532,6 +532,10 @@ class BaseTunnelManager(object):
...
@@ -532,6 +532,10 @@ class BaseTunnelManager(object):
# XXX: Quick'n dirty way to log in a common place.
# XXX: Quick'n dirty way to log in a common place.
if
peer
and
self
.
_prefix
==
self
.
cache
.
registry_prefix
:
if
peer
and
self
.
_prefix
==
self
.
cache
.
registry_prefix
:
logging
.
info
(
"%s/%s: %s"
,
int
(
peer
,
2
),
len
(
peer
),
msg
)
logging
.
info
(
"%s/%s: %s"
,
int
(
peer
,
2
),
len
(
peer
),
msg
)
elif
code
==
8
:
print
(
"Monitoring!"
)
print
(
sender
[
0
])
self
.
_getPeer
(
peer
).
_i
-=
1
# Don't increment seqno with this packet
def
askInfo
(
self
,
prefix
):
def
askInfo
(
self
,
prefix
):
return
self
.
sendto
(
prefix
,
'
\
4
'
+
self
.
_info
(
True
))
return
self
.
sendto
(
prefix
,
'
\
4
'
+
self
.
_info
(
True
))
...
@@ -677,10 +681,11 @@ class BaseTunnelManager(object):
...
@@ -677,10 +681,11 @@ class BaseTunnelManager(object):
for
prefix
in
list
(
self
.
_neighbour_monitoring_addresses
.
keys
()):
for
prefix
in
list
(
self
.
_neighbour_monitoring_addresses
.
keys
()):
if
prefix
not
in
self
.
ctl
.
neighbours
:
if
prefix
not
in
self
.
ctl
.
neighbours
:
address
=
self
.
_neighbour_monitoring_addresses
[
prefix
]
address
=
self
.
_neighbour_monitoring_addresses
[
prefix
]
# FIXME Replace lo by main inteface name
# FIXME Replace lo by main inteface name
subprocess
.
check_call
((
'ip'
,
'-6'
,
'address'
,
'del'
,
address
,
'dev'
,
'lo'
))
subprocess
.
check_call
((
'ip'
,
'-6'
,
'address'
,
'del'
,
address
,
'dev'
,
'lo'
))
subprocess
.
check_call
((
'ip'
,
'-6'
,
'route'
,
'del'
,
my_address
,
subprocess
.
check_call
((
'ip'
,
'-6'
,
'route'
,
'del'
,
my_address
,
'from'
,
address
,
'dev'
,
'lo'
,
'table'
,
'34071'
))
'from'
,
address
,
'table'
,
'34071'
))
del
self
.
_neighbour_monitoring_addresses
[
prefix
]
# Babel is not initialized yet.
# Babel is not initialized yet.
if
not
hasattr
(
self
.
ctl
,
'neighbours'
):
if
not
hasattr
(
self
.
ctl
,
'neighbours'
):
...
@@ -723,6 +728,33 @@ class BaseTunnelManager(object):
...
@@ -723,6 +728,33 @@ class BaseTunnelManager(object):
'via'
,
nexthop
,
'dev'
,
iface
,
'src'
,
address
,
'table'
,
'34071'
),
'via'
,
nexthop
,
'dev'
,
iface
,
'src'
,
address
,
'table'
,
'34071'
),
stderr
=
subprocess
.
STDOUT
)
stderr
=
subprocess
.
STDOUT
)
def
monitorLinks
(
self
):
"""
Try to forward packets through each direct link.
"""
my_address
=
utils
.
ipFromBin
(
self
.
_network
+
self
.
_prefix
,
'1'
)
for
prefix
,
address
in
self
.
_neighbour_monitoring_addresses
.
items
():
msock
=
None
try
:
print
(
"Send ping from "
+
address
+
" for "
+
utils
.
ipFromBin
(
self
.
_network
+
prefix
)
+
" to "
+
my_address
+
"..."
)
msock
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
msock
.
bind
((
address
,
PORT
+
1
))
msg
=
b'
\
x08
'
peer
=
self
.
_getPeer
(
self
.
_prefix
)
data
=
peer
.
encode
(
msg
)
peer
.
_j
-=
1
# Don't increment seqno with this packet
msock
.
sendto
(
data
,
(
my_address
,
PORT
))
except
Exception
,
e
:
logging
.
error
(
"Error while monitoring "
+
utils
.
ipFromBin
(
self
.
_network
+
prefix
)
+
": "
+
str
(
e
))
finally
:
if
msock
:
try
:
msock
.
close
()
finally
:
pass
def
_updateCountry
(
self
,
address
):
def
_updateCountry
(
self
,
address
):
def
update
():
def
update
():
for
a
in
address
:
for
a
in
address
:
...
@@ -835,6 +867,7 @@ class TunnelManager(BaseTunnelManager):
...
@@ -835,6 +867,7 @@ class TunnelManager(BaseTunnelManager):
self
.
_next_refresh
=
time
.
time
()
+
5
self
.
_next_refresh
=
time
.
time
()
+
5
self
.
checkRoutingCache
()
self
.
checkRoutingCache
()
self
.
updateMonitoringLinks
()
self
.
updateMonitoringLinks
()
self
.
monitorLinks
()
def
babel_dump
(
self
):
def
babel_dump
(
self
):
t
=
time
.
time
()
t
=
time
.
time
()
...
...
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