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
Xiaowu Zhang
re6stnet
Commits
23f47592
Commit
23f47592
authored
Jul 24, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Openvpn server port and proto in one option
parent
01c99fa5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
+19
-17
db.py
db.py
+6
-7
vifibnet.py
vifibnet.py
+13
-10
No files found.
db.py
View file @
23f47592
...
...
@@ -6,7 +6,7 @@ class PeerManager:
# internal ip = temp arg/attribute
def
__init__
(
self
,
db_dir_path
,
server
,
server_port
,
refresh_time
,
address
,
internal_ip
,
prefix
,
manual
,
p
roto
,
port
,
db_size
):
internal_ip
,
prefix
,
manual
,
p
p
,
db_size
):
self
.
_refresh_time
=
refresh_time
self
.
_address
=
address
self
.
_internal_ip
=
internal_ip
...
...
@@ -14,8 +14,7 @@ class PeerManager:
self
.
_server
=
server
self
.
_server_port
=
server_port
self
.
_db_size
=
db_size
self
.
_proto
=
proto
self
.
_ovpn_port
=
port
self
.
_pp
=
pp
self
.
_manual
=
manual
self
.
_proxy
=
xmlrpclib
.
ServerProxy
(
'http://%s:%u'
...
...
@@ -94,12 +93,12 @@ class PeerManager:
elif
script_type
==
'route-up'
:
if
not
self
.
_manual
:
external_ip
=
arg
new_address
=
list
([
external_ip
,
self
.
_ovpn_
port
,
proto
]
for
p
roto
in
self
.
_proto
)
new_address
=
list
([
external_ip
,
port
,
proto
]
for
p
ort
,
proto
in
self
.
_pp
)
if
self
.
_address
!=
new_address
:
self
.
_address
=
new_address
utils
.
log
(
'Received new external
configuration : %s:%s'
%
(
external_ip
,
external_port
),
3
)
utils
.
log
(
'Received new external
ip : %s'
%
(
external_ip
,
),
3
)
self
.
_declare
()
else
:
utils
.
log
(
'Unknow message recieved from the openvpn pipe : '
...
...
vifibnet.py
View file @
23f47592
...
...
@@ -33,8 +33,6 @@ def getConfig():
# General Configuration options
_
(
'--ip'
,
default
=
None
,
dest
=
'address'
,
action
=
'append'
,
nargs
=
3
,
help
=
'Ip address, port and protocol advertised to other vpn nodes'
)
_
(
'--internal-port'
,
default
=
1194
,
help
=
'Port on the machine to listen on for incomming connections'
)
_
(
'--peers-db-refresh'
,
default
=
3600
,
type
=
int
,
help
=
'the time (seconds) to wait before refreshing the peers db'
)
_
(
'-l'
,
'--log'
,
default
=
'/var/log'
,
...
...
@@ -60,8 +58,8 @@ def getConfig():
for the routing protocol'''
)
# Tunnel options
_
(
'--p
roto'
,
choices
=
[
'udp'
,
'tcp-server'
],
nargs
=
'+'
,
default
=
[
'udp'
]
,
help
=
'P
rotocol(s)
to be used by other peers to connect'
)
_
(
'--p
p'
,
nargs
=
2
,
action
=
'append'
,
help
=
'P
ort and protocol
to be used by other peers to connect'
)
_
(
'--tunnel-refresh'
,
default
=
300
,
type
=
int
,
help
=
'the time (seconds) to wait before changing the connections'
)
_
(
'--dh'
,
required
=
True
,
...
...
@@ -85,6 +83,8 @@ def getConfig():
def
main
():
# Get arguments
config
=
getConfig
()
if
not
config
.
pp
:
config
.
pp
=
[[
'1194'
,
'udp'
]]
manual
=
bool
(
config
.
address
)
network
=
utils
.
networkFromCa
(
config
.
ca
)
internal_ip
,
prefix
=
utils
.
ipFromCert
(
network
,
config
.
cert
)
...
...
@@ -102,19 +102,21 @@ def main():
# Init db and tunnels
if
manual
:
utils
.
log
(
'Manual external configuration'
,
3
)
forward
=
None
else
:
utils
.
log
(
'Attempting automatic configuration via UPnP'
,
4
)
try
:
forward
=
upnpigd
.
UpnpForward
(
config
.
internal_port
,
config
.
proto
)
config
.
address
=
list
([
forward
.
external_ip
,
str
(
forward
.
external_port
),
proto
]
for
proto
in
config
.
proto
)
forward
=
list
([
upnpigd
.
UpnpForward
(
int
(
port
),
proto
),
proto
]
for
port
,
proto
in
config
.
pp
)
config
.
address
=
list
([
ext
.
external_ip
,
str
(
ext
.
external_port
),
proto
]
for
ext
,
proto
in
forward
)
except
Exception
:
forward
=
None
utils
.
log
(
'An atempt to forward a port via UPnP failed'
,
4
)
peer_db
=
db
.
PeerManager
(
config
.
state
,
config
.
server
,
config
.
server_port
,
config
.
peers_db_refresh
,
config
.
address
,
internal_ip
,
prefix
,
manual
,
config
.
p
roto
,
200
)
manual
,
config
.
p
p
,
200
)
tunnel_manager
=
tunnel
.
TunnelManager
(
write_pipe
,
peer_db
,
openvpn_args
,
config
.
hello
,
config
.
tunnel_refresh
,
config
.
connection_count
,
config
.
refresh_rate
)
...
...
@@ -128,11 +130,12 @@ def main():
# Establish connections
server_process
=
list
(
plib
.
server
(
internal_ip
,
len
(
network
)
+
len
(
prefix
),
config
.
connection_count
,
config
.
dh
,
write_pipe
,
config
.
internal_
port
,
config
.
connection_count
,
config
.
dh
,
write_pipe
,
port
,
proto
,
config
.
hello
,
'--dev'
,
'vifibnet'
,
*
openvpn_args
,
stdout
=
os
.
open
(
os
.
path
.
join
(
config
.
log
,
'vifibnet.server.%s.log'
%
(
proto
,)),
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
))
for
proto
in
config
.
proto
)
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
))
for
port
,
proto
in
config
.
pp
)
tunnel_manager
.
refresh
()
# main loop
...
...
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