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
Rafael Monnerat
re6stnet
Commits
409ebea5
Commit
409ebea5
authored
Jul 13, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bootstrap problem solved ( not tested though )
parent
483e034f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
15 deletions
+27
-15
setup.py
setup.py
+17
-1
vifibnet.py
vifibnet.py
+10
-14
No files found.
setup.py
View file @
409ebea5
...
...
@@ -42,9 +42,10 @@ def main():
req
.
sign
(
pkey
,
'sha1'
)
req
=
crypto
.
dump_certificate_request
(
crypto
.
FILETYPE_PEM
,
req
)
# Get certificates
# Get certificates
and bootstrap peers
ca
=
s
.
getCa
()
cert
=
s
.
requestCertificate
(
token
,
req
)
boot_ip
,
boot_port
,
boot_proto
=
s
.
getBootstrapPeer
()
# Generating dh file
subprocess
.
call
([
'openssl'
,
'dhparam'
,
'-out'
,
os
.
path
.
join
(
config
.
dir
,
'dh2048.pem'
),
'2048'
])
...
...
@@ -57,6 +58,21 @@ def main():
with
open
(
os
.
path
.
join
(
config
.
dir
,
'ca.pem'
),
'w'
)
as
f
:
f
.
write
(
ca
)
# Create and initialize peers DB
self
.
db
=
sqlite3
.
connect
(
os
.
path
.
join
(
config
.
dir
,
'peers.db'
),
isolation_level
=
None
)
try
:
self
.
db
.
execute
(
"""CREATE TABLE peers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT NOT NULL,
port INTEGER NOT NULL,
proto TEXT NOT NULL,
used INTEGER NOT NULL default 0)"""
)
self
.
db
.
execute
(
"CREATE INDEX _peers_used ON peers(used)"
)
self
.
db
.
execute
(
"INSERT INTO peers (ip, port, proto) VALUES (?,?,?)"
,
(
boot_ip
,
boot_port
,
boot_proto
))
except
sqlite3
.
OperationalError
,
e
:
if
e
.
args
[
0
]
==
'table peers already exists'
:
print
"Table peers already exists, leaving it as it is"
print
"Certificate setup complete."
if
__name__
==
"__main__"
:
...
...
vifibnet.py
View file @
409ebea5
...
...
@@ -16,26 +16,21 @@ free_interface_set = set(('client1', 'client2', 'client3', 'client4', 'client5',
class
PeersDB
:
def
__init__
(
self
,
dbPath
):
self
.
proxy
=
xmlrpclib
.
ServerProxy
(
'http://%s:%u'
%
(
config
.
server
,
config
.
server_port
))
log
.
log
(
'Connectiong to peers database'
,
4
)
self
.
db
=
sqlite3
.
connect
(
dbPath
,
isolation_level
=
None
)
log
.
log
(
'
Initializ
ing peers database'
,
4
)
log
.
log
(
'
Prepar
ing peers database'
,
4
)
try
:
self
.
db
.
execute
(
"""CREATE TABLE peers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT NOT NULL,
port INTEGER NOT NULL,
proto TEXT NOT NULL,
used INTEGER NOT NULL default 0)"""
)
self
.
db
.
execute
(
"CREATE INDEX _peers_used ON peers(used)"
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0"
)
except
sqlite3
.
OperationalError
,
e
:
if
e
.
args
[
0
]
!=
'
table peers already exist
s'
:
if
e
.
args
[
0
]
!=
'
no such table: peer
s'
:
raise
RuntimeError
def
populateDB
(
self
,
n
):
def
populate
(
self
,
n
):
log
.
log
(
'Connecting to remote server'
,
3
)
self
.
proxy
=
xmlrpclib
.
ServerProxy
(
'http://%s:%u'
%
(
config
.
server
,
config
.
server_port
))
log
.
log
(
'Populating Peers DB'
,
2
)
# TODO: determine port and proto
port
=
1194
proto
=
'udp'
new_peer_list
=
self
.
proxy
.
getPeerList
(
n
,
(
config
.
external_ip
,
port
,
proto
))
...
...
@@ -90,6 +85,7 @@ def getConfig():
parser
=
argparse
.
ArgumentParser
(
description
=
'Resilient virtual private network application'
)
_
=
parser
.
add_argument
# Server address MUST be a vifib address ( else requests will be denied )
_
(
'--server'
,
required
=
True
,
help
=
'Address for peer discovery server'
)
_
(
'--server-port'
,
required
=
True
,
type
=
int
,
...
...
@@ -213,13 +209,13 @@ def main():
getConfig
()
log
.
verbose
=
config
.
verbose
# TODO: how do we decide which protocol we use ?
(
externalIp
,
externalPort
)
=
upnpigd
.
GetExternalInfo
(
1194
)
#
(externalIp, externalPort) = upnpigd.GetExternalInfo(1194)
# Setup database
global
peers_db
# stop using global variables for everything ?
peers_db
=
PeersDB
(
config
.
db
)
# Launch babel on all interfaces
# Launch babel on all interfaces
. WARNING : you have to be root to start babeld
log
.
log
(
'Starting babel'
,
3
)
babel
=
startBabel
(
stdout
=
os
.
open
(
os
.
path
.
join
(
config
.
log
,
'vifibnet.babeld.log'
),
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
),
stderr
=
subprocess
.
STDOUT
)
...
...
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