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
Boris Kocherov
re6stnet
Commits
0820ffd1
Commit
0820ffd1
authored
Jul 24, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.erp5.org/repos/vifibnet
Conflicts: TODO
parents
6b0076d2
23f47592
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
21 deletions
+22
-21
TODO
TODO
+1
-1
db.py
db.py
+7
-7
ovpn-client
ovpn-client
+1
-1
ovpn-server
ovpn-server
+0
-2
vifibnet.py
vifibnet.py
+13
-10
No files found.
TODO
View file @
0820ffd1
Bugs:
The address of the client is declared while it should only be the address
of the server
of the server
To be done :
use the server as a bootstrap node -> switch peer discovery to be done
...
...
db.py
View file @
0820ffd1
...
...
@@ -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
,
db_size
):
internal_ip
,
prefix
,
manual
,
p
p
,
db_size
):
self
.
_refresh_time
=
refresh_time
self
.
_address
=
address
self
.
_internal_ip
=
internal_ip
...
...
@@ -14,7 +14,7 @@ class PeerManager:
self
.
_server
=
server
self
.
_server_port
=
server_port
self
.
_db_size
=
db_size
self
.
_p
roto
=
proto
self
.
_p
p
=
pp
self
.
_manual
=
manual
self
.
_proxy
=
xmlrpclib
.
ServerProxy
(
'http://%s:%u'
...
...
@@ -92,13 +92,13 @@ class PeerManager:
utils
.
log
(
'%s has disconnected'
%
(
arg
,),
3
)
elif
script_type
==
'route-up'
:
if
not
self
.
_manual
:
external_ip
,
external_port
=
arg
.
split
(
','
)
new_address
=
list
([
external_ip
,
external_
port
,
proto
]
for
p
roto
in
self
.
_proto
)
external_ip
=
arg
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 : '
...
...
ovpn-client
View file @
0820ffd1
...
...
@@ -5,4 +5,4 @@ if os.environ['script_type'] == 'up':
os
.
execlp
(
'ip'
,
'ip'
,
'link'
,
'set'
,
os
.
environ
[
'dev'
],
'up'
)
# Write into pipe external ip address received
os
.
write
(
int
(
sys
.
argv
[
1
]),
'%(script_type)s %(OPENVPN_external_ip)s
,%(OPENVPN_external_port)s
\
n
'
%
os
.
environ
)
os
.
write
(
int
(
sys
.
argv
[
1
]),
'%(script_type)s %(OPENVPN_external_ip)s
\
n
'
%
os
.
environ
)
ovpn-server
View file @
0820ffd1
...
...
@@ -49,8 +49,6 @@ if script_type == 'client-connect':
with
open
(
sys
.
argv
[
2
],
'w'
)
as
f
:
f
.
write
(
'push "setenv-safe external_ip %s"
\
n
'
%
os
.
environ
[
'trusted_ip'
])
f
.
write
(
'push "setenv-safe external_port %s"
\
n
'
%
os
.
environ
[
'trusted_port'
])
# Write into pipe connect/disconnect events
os
.
write
(
int
(
sys
.
argv
[
1
]),
'%(script_type)s %(common_name)s
\
n
'
%
os
.
environ
)
vifibnet.py
View file @
0820ffd1
...
...
@@ -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