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
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
nexedi
re6stnet
Commits
0b7f4b32
Commit
0b7f4b32
authored
Jul 18, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upnp is now used when necessary
parent
d297a650
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
21 deletions
+11
-21
TODO
TODO
+2
-3
upnpigd.py
upnpigd.py
+1
-16
vifibnet.py
vifibnet.py
+8
-2
No files found.
TODO
View file @
0b7f4b32
...
...
@@ -13,6 +13,7 @@ To be done :
Contact the server using vifibnet and not the underlying network when possible
Use a timeout for the peersDB
The peer DB size should depend on the number of connection and the refresh time
Specify a lease duration in ForwardViaUPnP
To be discuss:
U : Remove the --no-boot option since we know when no node is avalaible
...
...
@@ -24,6 +25,4 @@ To be discuss:
U : From what I've read on the internet, when you create a server object, you don't connect to the server,
You only connect to the server once you send a request for a methode and then you can automatically use the same connection for 15sec
Is the bootstrap node used ?
We should separate the getNodesList and advertise options
\ No newline at end of file
Is the bootstrap node used ?
\ No newline at end of file
upnpigd.py
View file @
0b7f4b32
...
...
@@ -10,7 +10,7 @@ def ForwardViaUPnP(localPort):
u
.
selectigd
()
externalPort
=
1194
while
True
:
while
u
.
getspecificportmapping
(
externalPort
,
'
TC
P'
)
!=
None
:
while
u
.
getspecificportmapping
(
externalPort
,
'
UD
P'
)
!=
None
:
externalPort
=
max
(
externalPort
+
1
,
49152
)
if
externalPort
==
65536
:
raise
Exception
...
...
@@ -18,18 +18,3 @@ def ForwardViaUPnP(localPort):
return
(
u
.
externalipaddress
(),
externalPort
)
# TODO : specify a lease duration
# TODO : use more precises exceptions
# TODO : be sure that GetLocalIp do not bug
def
GetLocalIp
():
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
connect
((
'10.8.8.8'
,
0
))
return
s
.
getsockname
()[
0
]
def
GetExternalInfo
(
localPort
):
try
:
return
ForwardViaUPnP
(
localPort
)
except
Exception
:
return
(
GetLocalIp
(),
localPort
)
vifibnet.py
View file @
0b7f4b32
#!/usr/bin/env python
import
argparse
,
errno
,
math
,
os
,
select
,
subprocess
,
sys
,
time
,
traceback
import
argparse
,
errno
,
math
,
os
,
select
,
subprocess
,
sys
,
time
,
traceback
,
upnpigd
from
OpenSSL
import
crypto
import
db
,
plib
,
upnpigd
,
utils
,
tunnel
...
...
@@ -12,7 +12,7 @@ def getConfig():
help
=
'Address for peer discovery server'
)
_
(
'--server-port'
,
required
=
True
,
type
=
int
,
help
=
'Peer discovery server port'
)
_
(
'-l
'
,
'--log
'
,
default
=
'/var/log'
,
_
(
'-l
og'
,
'-l
'
,
default
=
'/var/log'
,
help
=
'Path to vifibnet logs directory'
)
_
(
'--tunnel-refresh'
,
default
=
300
,
type
=
int
,
help
=
'the time (seconds) to wait before changing the connections'
)
...
...
@@ -65,6 +65,12 @@ def main():
read_pipe
=
os
.
fdopen
(
r_pipe
)
# Init db and tunnels
if
config
.
external_ip
==
None
:
try
:
config
.
external_ip
,
config
.
external_port
=
upnpigd
.
ForwardViaUPnP
(
config
.
internal_port
)
except
Exception
:
utils
.
log
(
'An atempt to forward a port via UPnP failed'
,
5
)
peer_db
=
db
.
PeerManager
(
config
.
db
,
config
.
server
,
config
.
server_port
,
config
.
peers_db_refresh
,
config
.
external_ip
,
internal_ip
,
config
.
external_port
,
config
.
proto
,
200
)
tunnel_manager
=
tunnel
.
TunnelManager
(
write_pipe
,
peer_db
,
openvpn_args
,
config
.
tunnel_refresh
,
config
.
connection_count
,
config
.
refresh_rate
)
...
...
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