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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
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'
CaPath
=
'/root/overnet/keys/ca.crt'
CertPath
=
'/root/overnet/keys/server.crt'
CertPath
=
'/root/overnet/keys/server.crt'
KeyPath
=
'/root/overnet/keys/server.key'
KeyPath
=
'/root/overnet/keys/server.key'
DhPath
=
'/root/overnet/keys/dh1024.pem'
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
Debug
=
True
\ No newline at end of file
configuration.py
View file @
dcc76a0d
...
@@ -23,8 +23,8 @@ FailIfNotExists('CaPath')
...
@@ -23,8 +23,8 @@ FailIfNotExists('CaPath')
FailIfNotExists
(
'CertPath'
)
FailIfNotExists
(
'CertPath'
)
FailIfNotExists
(
'KeyPath'
)
FailIfNotExists
(
'KeyPath'
)
FailIfNotExists
(
'DhPath'
)
FailIfNotExists
(
'DhPath'
)
FailIfNotExists
(
'Subnet'
)
FailIfNotExists
(
'IPv6'
)
FailIfNotExists
(
'SubnetMask'
)
SetIfNotExists
(
'Debug'
,
False
)
SetIfNotExists
(
'Debug'
,
False
)
SetIfNotExists
(
'MandatoryConnections'
,
[])
SetIfNotExists
(
'MandatoryConnections'
,
[])
\ No newline at end of file
SetIfNotExists
(
'LocalPort'
,
1194
)
main.py
View file @
dcc76a0d
#!/usr/bin/env python
import
upnpigd
import
upnpigd
from
subprocess
import
call
import
openvpn
from
configuration
import
*
from
configuration
import
*
# Call == bad !!
(
ip
,
port
)
=
upnpigd
.
GetExternalInfo
(
config
.
LocalPort
)
# TODO : use subprocess module
openvpn
.
LaunchServer
()
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'
])
for
(
address
,
port
)
in
config
.
MandatoryConnections
:
openvpn
.
LaunchClient
(
address
,
port
)
upnpigd.py
View file @
dcc76a0d
...
@@ -31,3 +31,4 @@ def GetExternalInfo(localPort):
...
@@ -31,3 +31,4 @@ def GetExternalInfo(localPort):
return
ForwardViaUPnP
(
localPort
)
return
ForwardViaUPnP
(
localPort
)
except
Exception
:
except
Exception
:
return
(
GetLocalIp
(),
localPort
)
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