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
Joanne Hugé
re6stnet
Commits
d0f47075
Commit
d0f47075
authored
Jul 20, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaner server connection
parent
49685121
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
9 deletions
+15
-9
README
README
+1
-2
db.py
db.py
+9
-4
setup.py
setup.py
+4
-3
vifibnet.py
vifibnet.py
+1
-0
No files found.
README
View file @
d0f47075
...
...
@@ -13,4 +13,3 @@ The organisation of the code
tunnel.py To choose wich connection delete/keep/...
upnpigd.py To open a port
db.py
View file @
d0f47075
import
sqlite3
,
xmlrpclib
,
time
import
sqlite3
,
socket
,
xmlrpclib
,
time
import
utils
class
PeerManager
:
...
...
@@ -29,9 +29,14 @@ class PeerManager:
def
refresh
(
self
):
utils
.
log
(
'Refreshing the peers DB'
,
2
)
try
:
self
.
_declare
()
self
.
_populate
()
self
.
next_refresh
=
time
.
time
()
+
self
.
_refresh_time
except
socket
.
error
,
e
:
utils
.
log
(
str
(
e
),
3
)
utils
.
log
(
'Connection to server failed, retrying in 30s'
,
2
)
self
.
next_refresh
=
time
.
time
()
+
30
def
_declare
(
self
):
if
self
.
_address
!=
None
:
...
...
setup.py
View file @
d0f47075
...
...
@@ -42,9 +42,6 @@ def main():
used INTEGER NOT NULL DEFAULT 0,
date INTEGER DEFAULT (strftime('%s', 'now')))"""
)
db
.
execute
(
"CREATE INDEX _peers_used ON peers(used)"
)
if
not
config
.
no_boot
:
prefix
,
address
=
s
.
getBootstrapPeer
()
db
.
execute
(
"INSERT INTO peers (prefix, address) VALUES (?,?)"
,
(
prefix
,
address
))
except
sqlite3
.
OperationalError
,
e
:
if
e
.
args
[
0
]
==
'table peers already exists'
:
print
"Table peers already exists, leaving it as it is"
...
...
@@ -52,6 +49,10 @@ def main():
print
"sqlite3.OperationalError :"
+
e
.
args
[
0
]
sys
.
exit
(
1
)
if
not
config
.
no_boot
:
prefix
,
address
=
s
.
getBootstrapPeer
()
db
.
execute
(
"INSERT INTO peers (prefix, address) VALUES (?,?)"
,
(
prefix
,
address
))
if
config
.
db_only
:
sys
.
exit
(
0
)
...
...
vifibnet.py
View file @
d0f47075
...
...
@@ -116,6 +116,7 @@ def main():
server_process
=
plib
.
server
(
internal_ip
,
network
,
config
.
connection_count
,
config
.
dh
,
write_pipe
,
config
.
internal_port
,
config
.
proto
,
config
.
hello
,
'--dev'
,
'vifibnet'
,
*
openvpn_args
,
stdout
=
os
.
open
(
os
.
path
.
join
(
config
.
log
,
'vifibnet.server.log'
),
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
))
tunnel_manager
.
refresh
()
# main loop
try
:
...
...
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