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
Rafael Monnerat
re6stnet
Commits
ec7c78d6
Commit
ec7c78d6
authored
Jul 04, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrections in babel function
parent
8cba4e19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
34 deletions
+29
-34
main.py
main.py
+15
-13
openvpn.py
openvpn.py
+14
-21
No files found.
main.py
View file @
ec7c78d6
...
...
@@ -8,23 +8,24 @@ VIFIB_NET = "2001:db8:42::/48"
# TODO : How do we get our vifib ip ?
def
babel
(
network_ip
,
network_mask
,
verbose_level
):
args
=
[
'-I'
,
'redistribute local ip %s/%s'
%
(
network_ip
,
network_mask
),
'-I'
,
'redistribute local deny'
,
args
=
[
'babeld'
,
'-C'
,
'redistribute local ip %s/%s'
%
(
network_ip
,
network_mask
),
'-C'
,
'redistribute local deny'
,
# Route VIFIB ip adresses
'-
I
'
,
'in ip %s'
%
VIFIB_NET
,
'-
C
'
,
'in ip %s'
%
VIFIB_NET
,
# Route only addresse in the 'local' network,
# or other entire networks
#'-
I
', 'in ip %s/%s' % (network_ip,network_mask),
#'-
I
', 'in ip ::/0 le %s' % network_mask,
#'-
C
', 'in ip %s/%s' % (network_ip,network_mask),
#'-
C
', 'in ip ::/0 le %s' % network_mask,
# Don't route other addresses
'-
I
'
,
'in ip deny'
,
'-
C
'
,
'in ip deny'
,
'-d'
,
str
(
verbose_level
),
'-s'
,
]
if
config
.
babel_state
:
args
+=
'-S'
,
config
.
babel_state
# TODO : add list of interfaces to use with babel
return
Popen
(
args
)
return
subprocess
.
Popen
(
args
)
def
getConfig
():
global
config
...
...
@@ -32,24 +33,25 @@ def getConfig():
_
=
parser
.
add_argument
_
(
'--dh'
,
required
=
True
,
help
=
'Path to dh file'
)
_
(
'--babel-state'
,
_
(
'--babel-state'
,
help
=
'Path to babeld state-file'
)
_
(
'--verbose'
,
'-v'
,
default
=
'0'
,
_
(
'--verbose'
,
'-v'
,
default
=
'0'
,
help
=
'Defines the verbose level'
)
# Temporary args
_
(
'--ip'
,
required
=
True
,
help
=
'IPv6 of the server'
)
# Openvpn options
_
(
'openvpn_args'
,
nargs
=
argparse
.
REMAINDER
,
help
=
"Common OpenVPN options (e.g. certificates)"
)
config
=
parser
.
parse_args
()
openvpn
.
config
=
config
=
parser
.
parse_args
()
if
config
.
openvpn_args
[
0
]
==
"--"
:
del
config
.
openvpn_args
[
0
]
def
main
():
getConfig
()
if
config
.
ip
!=
'none'
:
serverProcess
=
openvpn
.
server
(
config
,
config
.
ip
)
serverProcess
=
openvpn
.
server
(
config
.
ip
,
"--dev"
,
"server"
)
else
:
client1Process
=
openvpn
.
client
(
config
,
'10.1.4.2'
)
client1Process
=
openvpn
.
client
(
'10.1.4.2'
)
if
__name__
==
"__main__"
:
main
()
...
...
openvpn.py
View file @
ec7c78d6
import
subprocess
def
openvpn
(
config
,
*
args
):
def
openvpn
(
*
args
,
**
kw
):
args
=
[
'openvpn'
,
'--dev'
,
'tap'
,
'--ca'
,
config
.
ca
,
'--cert'
,
config
.
cert
,
'--key'
,
config
.
key
,
'--dev-type'
,
'tap'
,
'--persist-tun'
,
'--persist-key'
,
'--script-security'
,
'2'
,
'--user'
,
'nobody'
,
'--group'
,
'nogroup'
,
'--verb'
,
config
.
verbose
'--verb'
,
config
.
verbose
,
]
+
list
(
args
)
+
config
.
openvpn_args
#stdin = kw.pop('stdin', None)
#stdout = kw.pop('stdout', None)
#stderr = kw.pop('stderr', None)
#for i in kw.iteritems():
# args.append('--%s=%s' % i)
return
subprocess
.
Popen
(
args
#stdin=stdin, stdout=stdout, stderr=stderr,
)
print
repr
(
args
)
return
subprocess
.
Popen
(
args
,
**
kw
)
# TODO : set iface up when creating a server/client
# ! check working directory before launching up script ?
def
server
(
config
,
ip
):
return
openvpn
(
config
,
def
server
(
ip
,
*
args
):
return
openvpn
(
'--tls-server'
,
'--keepalive'
,
'10'
,
'60'
,
'--mode'
,
'server'
,
'--duplicate-cn'
,
'--duplicate-cn'
,
# XXX : to be removed
'--up'
,
'up-server '
+
ip
,
'--dh'
,
config
.
dh
)
'--dh'
,
config
.
dh
,
*
args
)
def
client
(
config
,
serverIp
):
return
openvpn
(
config
,
def
client
(
serverIp
,
*
args
):
return
openvpn
(
'--nobind'
,
'--tls-client'
,
'--remote'
,
serverIp
,
'--up'
,
'up-client'
)
'--up'
,
'up-client'
,
*
args
)
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