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
8e578298
Commit
8e578298
authored
Jul 04, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing the configuration of openVPN
parent
66976244
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
51 deletions
+18
-51
main.py
main.py
+18
-51
No files found.
main.py
100644 → 100755
View file @
8e578298
#!/usr/bin/env python
#!/usr/bin/env python
import
argparse
,
errno
,
os
,
subprocess
,
sys
,
time
import
argparse
,
errno
,
os
,
subprocess
,
sys
,
time
import
upnpigd
import
upnpigd
import
openvpn
VIFIB_NET
=
"2001:db8:42::/48"
VIFIB_NET
=
"2001:db8:42::/48"
# TODO : - should we use slapos certificates or
# use new ones we create for openvpn ?
def
openvpn
(
*
args
,
**
kw
):
args
=
[
'openvpn'
,
'--dev'
,
'tap'
,
'--ca'
,
config
.
ca
,
'--cert'
,
config
.
cert
,
'--key'
,
config
.
key
,
'--persist-tun'
,
'--persist-key'
,
'--user'
'nobody'
,
'--group'
,
'nogroup'
,
]
+
list
(
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,
)
# TODO : set iface up when creating a server/client
# ! check working directory before launching up script ?
def
server
(
*
args
,
**
kw
):
return
openvpn
(
'--tls-server'
,
'--client-to-client'
,
#'--keepalive', '10', '60',
mode
=
'server'
,
dh
=
dh_path
,
*
args
,
**
kw
)
def
client
(
ip
,
*
args
,
**
kw
):
return
openvpn
(
'--nobind'
,
remote
=
ip
,
*
args
,
**
kw
)
# TODO : How do we get our vifib ip ?
# TODO : How do we get our vifib ip ?
...
@@ -63,23 +27,26 @@ def babel(network_ip, network_mask, verbose_level):
...
@@ -63,23 +27,26 @@ def babel(network_ip, network_mask, verbose_level):
# TODO : add list of interfaces to use with babel
# TODO : add list of interfaces to use with babel
return
Popen
(
args
)
return
Popen
(
args
)
def
main
():
def
getConfig
():
global
config
global
config
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
'Resilient virtual private network application'
)
description
=
"Resilient virtual private network application"
)
_
=
parser
.
add_argument
_
=
parser
.
add_argument
_
(
'--dh'
,
required
=
True
,
_
(
'--dh'
,
required
=
True
,
help
=
'Path to dh file'
)
help
=
"Path to dh file"
)
_
(
'--babel-state'
,
help
=
'Path to babeld state-file'
)
_
(
'--
babel-state'
,
_
(
'--
verbose'
,
'-v'
,
default
=
'0'
,
help
=
'Defines the verbose level'
)
help
=
"Path to babeld state-file"
)
_
(
'--ca'
,
required
=
True
,
help
=
'Path to the certificate authority'
)
#_('--verbose', '-v', action='count',
_
(
'--key'
,
required
=
True
,
help
=
'Path to the rsa_key'
)
# help="Defines the verbose level"
)
_
(
'--cert'
,
required
=
True
,
help
=
'Pah to the certificate'
)
_
(
'openvpn_args'
,
nargs
=
argparse
.
REMAINDER
,
# Temporary args
help
=
"Common OpenVPN options (e.g. certificates)"
)
_
(
'--ip'
,
required
=
True
,
help
=
'IPv6 of the server'
)
config
=
parser
.
parse_args
()
config
=
parser
.
parse_args
()
# TODO : set the certificates and ker paths, in global variables
# how to setup openvpn connections :
server
=
server
(
dev
=
'server'
,
verb
=
3
)
def
main
():
getConfig
()
serverProcess
=
openvpn
.
server
(
config
,
config
.
ip
)
client1Process
=
openvpn
.
client
(
config
,
'10.1.4.2'
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
main
()
...
...
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