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
50275cc2
Commit
50275cc2
authored
Oct 21, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move _iterRoutes to utils.py
enable default route check
parent
ab7049d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
29 deletions
+45
-29
re6st/tunnel.py
re6st/tunnel.py
+0
-28
re6st/utils.py
re6st/utils.py
+44
-0
re6stnet
re6stnet
+1
-1
No files found.
re6st/tunnel.py
View file @
50275cc2
...
...
@@ -311,34 +311,6 @@ class TunnelManager(object):
if
self
.
_makeTunnel
(
*
peer
):
break
if
sys
.
platform
==
'cygwin'
:
def
_iterRoutes
(
self
):
# Before Vista
if
platform
.
system
()[
10
:
11
]
==
'5'
:
args
=
(
'netsh'
,
'interface'
,
'ipv6'
,
'show'
,
'route'
,
'verbose'
)
else
:
args
=
(
'ipwin'
,
'ipv6'
,
'show'
,
'route'
,
'verbose'
)
routing_table
=
subprocess
.
check_output
(
args
,
stderr
=
subprocess
.
STDOUT
)
for
line
in
routing_table
.
splitlines
():
fs
=
line
.
split
(
':'
,
1
)
test
=
fs
[
0
].
startswith
if
test
(
'Prefix'
):
prefix
,
prefix_len
=
fs
[
1
].
split
(
'/'
,
1
)
elif
test
(
'Interface'
):
yield
(
fs
[
1
].
strip
(),
utils
.
binFromIp
(
prefix
.
strip
()),
int
(
prefix_len
))
else
:
def
_iterRoutes
(
self
):
with
open
(
'/proc/net/ipv6_route'
)
as
f
:
routing_table
=
f
.
read
()
for
line
in
routing_table
.
splitlines
():
line
=
line
.
split
()
iface
=
line
[
-
1
]
if
iface
!=
'lo'
and
not
(
int
(
line
[
-
2
],
16
)
&
RTF_CACHE
):
yield
(
iface
,
bin
(
int
(
line
[
0
],
16
))[
2
:].
rjust
(
128
,
'0'
),
int
(
line
[
1
],
16
))
def
_countRoutes
(
self
):
logging
.
debug
(
'Starting to count the routes on each interface...'
)
del
self
.
_distant_peers
[:]
...
...
re6st/utils.py
View file @
50275cc2
...
...
@@ -154,6 +154,50 @@ def parse_address(address_list):
def
binFromSubnet
(
subnet
):
p
,
l
=
subnet
.
split
(
'/'
)
return
bin
(
int
(
p
))[
2
:].
rjust
(
int
(
l
),
'0'
)
if
sys
.
platform
==
'cygwin'
:
def
_iterRoutes
(
self
):
# Before Vista
if
platform
.
system
()[
10
:
11
]
==
'5'
:
args
=
(
'netsh'
,
'interface'
,
'ipv6'
,
'show'
,
'route'
,
'verbose'
)
else
:
args
=
(
'ipwin'
,
'ipv6'
,
'show'
,
'route'
,
'verbose'
)
routing_table
=
subprocess
.
check_output
(
args
,
stderr
=
subprocess
.
STDOUT
)
for
line
in
routing_table
.
splitlines
():
fs
=
line
.
split
(
':'
,
1
)
test
=
fs
[
0
].
startswith
if
test
(
'Prefix'
):
prefix
,
prefix_len
=
fs
[
1
].
split
(
'/'
,
1
)
elif
test
(
'Interface'
):
yield
(
fs
[
1
].
strip
(),
utils
.
binFromIp
(
prefix
.
strip
()),
int
(
prefix_len
))
else
:
def
_iterRoutes
():
with
open
(
'/proc/net/ipv6_route'
)
as
f
:
routing_table
=
f
.
read
()
for
line
in
routing_table
.
splitlines
():
line
=
line
.
split
()
iface
=
line
[
-
1
]
if
0
<
int
(
line
[
5
],
16
)
<
1
<<
31
:
# positive metric
yield
(
iface
,
bin
(
int
(
line
[
0
],
16
))[
2
:].
rjust
(
128
,
'0'
),
int
(
line
[
1
],
16
))
_iterRoutes
.
__doc__
=
"""Iterates over all routes
Amongst all returned routes starting with re6st prefix:
- one is the local one with our prefix
- any route with null prefix will be ignored
- other are reachable routes installed by babeld
"""
def
iterRoutes
(
network
,
exclude_prefix
=
None
):
a
=
len
(
network
)
for
iface
,
ip
,
prefix_len
in
_iterRoutes
():
if
ip
[:
a
]
==
network
:
prefix
=
ip
[
a
:
prefix_len
]
if
prefix
and
prefix
!=
exclude_prefix
:
yield
iface
,
prefix
def
decrypt
(
key_path
,
data
):
p
=
subprocess
.
Popen
(
...
...
re6stnet
View file @
50275cc2
...
...
@@ -361,7 +361,7 @@ def main():
exit
(
1
)
t
=
threading
.
Thread
(
target
=
check_no_default_route
)
t
.
daemon
=
True
#
t.start()
t
.
start
()
if
not
sys
.
platform
==
'cygwin'
:
ip
(
'route'
,
'unreachable'
,
*
x
)
...
...
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