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
356e1468
Commit
356e1468
authored
Jul 23, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added time-out for peers in registry
parent
03e3061a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
README
README
+4
-1
registry.py
registry.py
+9
-0
vifibnet.py
vifibnet.py
+1
-1
No files found.
README
View file @
356e1468
...
...
@@ -107,7 +107,10 @@ OPTIONS : VIFIBNET.PY
-s, --state directory
Path to the directory used for state files. State files include :
- peers.db : the peers db used to establish connection
- vifibnet.babeld.state : babeld state file
- vifibnet.babeld.state : babeld state file ( created if does not
exists, overriden if exists )
There must be a valid peers db file ( named peers.db ) in the
directory. A valid peers db file can be created with setup.py
Default : /var/lib/vifibnet
-v, --verbose level
...
...
registry.py
View file @
356e1468
...
...
@@ -3,6 +3,7 @@ import argparse, math, random, select, smtplib, sqlite3, string, socket, time, t
from
SimpleXMLRPCServer
import
SimpleXMLRPCServer
,
SimpleXMLRPCRequestHandler
from
email.mime.text
import
MIMEText
from
OpenSSL
import
crypto
from
time
import
time
import
utils
# To generate server ca and key with serial for 2001:db8:42::/48
...
...
@@ -32,6 +33,9 @@ class main(object):
def
__init__
(
self
):
self
.
cert_duration
=
365
*
86400
self
.
time_out
=
86400
self
.
refresh_interval
=
600
self
.
last_refresh
=
time
()
# Command line parsing
parser
=
argparse
.
ArgumentParser
(
...
...
@@ -54,6 +58,7 @@ class main(object):
prefix text primary key not null,
address text not null,
date integer default (strftime('%s','now')))"""
)
self
.
db
.
execute
(
"CREATE INDEX IF NOT EXISTS peers_ping ON peers(date)"
)
self
.
db
.
execute
(
"""CREATE TABLE IF NOT EXISTS tokens (
token text primary key not null,
email text not null,
...
...
@@ -193,6 +198,10 @@ class main(object):
assert
0
<
n
<
1000
client_ip
=
utils
.
binFromIp
(
client_address
)
if
client_ip
.
startswith
(
self
.
network
):
if
time
()
>
self
.
last_refresh
+
self
.
refresh_interval
:
print
"refreshing peers for dead ones"
self
.
db
.
execute
(
"DELETE FROM peers WHERE ( date + ? ) <= CAST (strftime('%s', 'now') AS INTEGER)"
,
(
self
.
time_out
,))
self
.
last_refesh
=
time
()
print
"sending peers"
return
self
.
db
.
execute
(
"SELECT prefix, address FROM peers ORDER BY random() LIMIT ?"
,
(
n
,)).
fetchall
()
else
:
...
...
vifibnet.py
View file @
356e1468
...
...
@@ -34,7 +34,7 @@ def getConfig():
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'
,
_
(
'-l'
,
'-
-
log'
,
default
=
'/var/log'
,
help
=
'Path to vifibnet logs directory'
)
_
(
'-s'
,
'--state'
,
default
=
'/var/lib/vifibnet'
,
help
=
'Path to VPN state directory'
)
...
...
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