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
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
nexedi
re6stnet
Commits
827575ae
Commit
827575ae
authored
Apr 16, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use --dev-node other than --dev when run openvpn in the Cygwin;
Add function TunnelManager._get_win32_ipv6_route_table.
parent
94e8a309
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
11 deletions
+51
-11
re6st/plib.py
re6st/plib.py
+2
-2
re6st/tunnel.py
re6st/tunnel.py
+49
-9
No files found.
re6st/plib.py
View file @
827575ae
import
logging
,
errno
,
os
import
logging
,
errno
,
os
,
sys
from
.
import
utils
from
.
import
utils
here
=
os
.
path
.
realpath
(
os
.
path
.
dirname
(
__file__
))
here
=
os
.
path
.
realpath
(
os
.
path
.
dirname
(
__file__
))
...
@@ -9,7 +9,7 @@ ovpn_log = None
...
@@ -9,7 +9,7 @@ ovpn_log = None
def
openvpn
(
iface
,
encrypt
,
*
args
,
**
kw
):
def
openvpn
(
iface
,
encrypt
,
*
args
,
**
kw
):
args
=
[
'openvpn'
,
args
=
[
'openvpn'
,
'--dev-type'
,
'tap'
,
'--dev-type'
,
'tap'
,
'--dev'
,
iface
,
'--dev
-node'
if
sys
.
platform
==
'cygwin'
else
'--dev
'
,
iface
,
'--persist-tun'
,
'--persist-tun'
,
'--persist-key'
,
'--persist-key'
,
'--script-security'
,
'2'
,
'--script-security'
,
'2'
,
...
...
re6st/tunnel.py
View file @
827575ae
...
@@ -283,6 +283,25 @@ class TunnelManager(object):
...
@@ -283,6 +283,25 @@ class TunnelManager(object):
if
self
.
_makeTunnel
(
*
peer
):
if
self
.
_makeTunnel
(
*
peer
):
break
break
def
_get_win32_ipv6_route_table
(
self
):
cmd
=
[
'netsh'
,
'interface ipv6 show route verbose'
]
rttable
=
[]
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
s
,
_x
=
p
.
communicate
()
if
p
.
returncode
!=
0
:
return
[]
# Or raise exception?
for
line
in
s
.
splitlines
():
fs
=
line
.
split
(
':'
,
1
)
if
fs
==
[]:
continue
if
fs
[
0
].
startswith
(
'Prefix'
):
prefix
,
prefix_len
=
fs
[
1
].
split
(
'/'
,
1
)
elif
fs
[
0
].
startswith
(
'Interface'
):
iface
=
fs
[
1
].
strip
()
elif
fs
[
0
].
startswith
(
'Site Prefix Length'
):
rttable
.
append
([
utils
.
binFromIp
(
prefix
),
int
(
prefix_len
),
iface
])
return
rttable
def
_countRoutes
(
self
):
def
_countRoutes
(
self
):
logging
.
debug
(
'Starting to count the routes on each interface...'
)
logging
.
debug
(
'Starting to count the routes on each interface...'
)
del
self
.
_distant_peers
[:]
del
self
.
_distant_peers
[:]
...
@@ -291,6 +310,7 @@ class TunnelManager(object):
...
@@ -291,6 +310,7 @@ class TunnelManager(object):
a
=
len
(
self
.
_network
)
a
=
len
(
self
.
_network
)
b
=
a
+
len
(
self
.
_prefix
)
b
=
a
+
len
(
self
.
_prefix
)
other
=
[]
other
=
[]
try
:
with
open
(
'/proc/net/ipv6_route'
)
as
f
:
with
open
(
'/proc/net/ipv6_route'
)
as
f
:
self
.
_last_routing_table
=
f
.
read
()
self
.
_last_routing_table
=
f
.
read
()
for
line
in
self
.
_last_routing_table
.
splitlines
():
for
line
in
self
.
_last_routing_table
.
splitlines
():
...
@@ -314,6 +334,26 @@ class TunnelManager(object):
...
@@ -314,6 +334,26 @@ class TunnelManager(object):
other
.
append
(
prefix
)
other
.
append
(
prefix
)
else
:
else
:
self
.
_distant_peers
.
append
(
prefix
)
self
.
_distant_peers
.
append
(
prefix
)
except
IOError
:
self
.
_last_routing_table
=
self
.
_get_win32_ipv6_route_table
()
for
rtline
in
self
.
_last_routing_table
:
iface
=
rtline
[
2
]
ip
=
rtline
[
0
][
2
:].
rjust
(
128
,
'0'
)
if
ip
[:
a
]
!=
self
.
_network
or
ip
[
a
:
b
]
==
self
.
_prefix
:
continue
prefix_len
=
rtline
[
1
]
prefix
=
ip
[
a
:
prefix_len
]
logging
.
trace
(
'Route on iface %s detected to %s/%u'
,
iface
,
utils
.
ipFromBin
(
ip
),
prefix_len
)
nexthop
=
self
.
_iface_to_prefix
.
get
(
iface
)
if
nexthop
:
self
.
_connection_dict
[
nexthop
].
routes
+=
1
if
prefix
in
self
.
_served
or
prefix
in
self
.
_connection_dict
:
continue
if
iface
in
self
.
_iface_list
:
other
.
append
(
prefix
)
else
:
self
.
_distant_peers
.
append
(
prefix
)
is_registry
=
self
.
_peer_db
.
registry_ip
[
a
:].
startswith
is_registry
=
self
.
_peer_db
.
registry_ip
[
a
:].
startswith
if
is_registry
(
self
.
_prefix
)
or
any
(
is_registry
(
peer
)
if
is_registry
(
self
.
_prefix
)
or
any
(
is_registry
(
peer
)
for
peer
in
chain
(
self
.
_distant_peers
,
other
,
for
peer
in
chain
(
self
.
_distant_peers
,
other
,
...
...
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