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
dcc76a0d
Commit
dcc76a0d
authored
Jul 03, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
bdc04ba6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
43 deletions
+20
-43
config.py
config.py
+10
-3
configuration.py
configuration.py
+3
-3
main.py
main.py
+6
-37
upnpigd.py
upnpigd.py
+1
-0
No files found.
config.py
View file @
dcc76a0d
import
socket
hostname
=
socket
.
gethostname
()
CaPath
=
'/root/overnet/keys/ca.crt'
CertPath
=
'/root/overnet/keys/server.crt'
KeyPath
=
'/root/overnet/keys/server.key'
DhPath
=
'/root/overnet/keys/dh1024.pem'
Subnet
=
'10.8.0.0'
SubnetMask
=
'255.255.255.0'
if
hostname
==
'm5'
:
IPv6
=
'2000:0:0:1::1/64'
MandatoryConnections
=
[(
'10.1.4.3'
,
1194
)]
elif
hostname
==
'm6'
:
IPv6
=
'2000:0:0:2::1/64'
Debug
=
True
\ No newline at end of file
Debug
=
True
configuration.py
View file @
dcc76a0d
...
...
@@ -23,8 +23,8 @@ FailIfNotExists('CaPath')
FailIfNotExists
(
'CertPath'
)
FailIfNotExists
(
'KeyPath'
)
FailIfNotExists
(
'DhPath'
)
FailIfNotExists
(
'Subnet'
)
FailIfNotExists
(
'SubnetMask'
)
FailIfNotExists
(
'IPv6'
)
SetIfNotExists
(
'Debug'
,
False
)
SetIfNotExists
(
'MandatoryConnections'
,
[])
\ No newline at end of file
SetIfNotExists
(
'MandatoryConnections'
,
[])
SetIfNotExists
(
'LocalPort'
,
1194
)
main.py
View file @
dcc76a0d
#!/usr/bin/env python
import
upnpigd
from
subprocess
import
call
import
openvpn
from
configuration
import
*
# Call == bad !!
# TODO : use subprocess module
def
LaunchOpenVpnClient
(
serverAddress
,
serverPort
):
call
([
'openvpn'
,
'--client'
,
'--dev'
,
'tun'
,
'--proto'
,
'udp'
,
'--remote'
,
serverAddress
,
str
(
serverPort
),
'--nobind'
,
'--persist-key'
,
'--persist-tun'
,
'--ca'
,
config
.
CaPath
,
'--cert'
,
config
.
CertPath
,
'--key'
,
config
.
KeyPath
,
'--ns-cert-type'
,
'server'
,
'--comp-lzo'
,
'--verb'
,
'3'
,
'--daemon'
,
'openVpnClient('
+
serverAddress
+
')'
])
def
LaunchOpenVpnServer
(
port
):
call
([
'openvpn'
,
'--dev'
,
'tun'
,
'--proto'
,
'udp'
,
'--ca'
,
config
.
CaPath
,
'--cert'
,
config
.
CertPath
,
'--key'
,
config
.
KeyPath
,
'--dh'
,
config
.
DhPath
,
'--server'
,
config
.
Subnet
,
config
.
SubnetMask
,
'--port'
,
str
(
port
),
'--ifconfig-pool-persist'
,
'ipp.txt'
,
'--comp-lzo'
,
'--keepalive'
,
'10'
,
'120'
,
'--persist-tun'
,
'--persist-key'
,
'--verb'
,
'3'
])
(
ip
,
port
)
=
upnpigd
.
GetExternalInfo
(
config
.
LocalPort
)
openvpn
.
LaunchServer
()
for
(
address
,
port
)
in
config
.
MandatoryConnections
:
openvpn
.
LaunchClient
(
address
,
port
)
upnpigd.py
View file @
dcc76a0d
...
...
@@ -31,3 +31,4 @@ def GetExternalInfo(localPort):
return
ForwardViaUPnP
(
localPort
)
except
Exception
:
return
(
GetLocalIp
(),
localPort
)
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