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
f6e96b71
Commit
f6e96b71
authored
Jul 31, 2012
by
Ulysse Beaugnon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put all annexes python files into a subfolder
parent
7072b80f
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
9 additions
and
87 deletions
+9
-87
propagation.py
propagation.py
+0
-81
re6st-registry.py
re6st-registry.py
+1
-1
re6st/__init__.py
re6st/__init__.py
+0
-0
re6st/db.py
re6st/db.py
+0
-0
re6st/plib.py
re6st/plib.py
+5
-2
re6st/tunnel.py
re6st/tunnel.py
+2
-2
re6st/upnpigd.py
re6st/upnpigd.py
+0
-0
re6st/utils.py
re6st/utils.py
+0
-0
re6stnet.py
re6stnet.py
+1
-1
No files found.
propagation.py
deleted
100644 → 0
View file @
7072b80f
import
socket
,
uuid
import
log
# create an upd socket
# listen on it for incoming messages and forward them
# manage the forwarding routing table
# the peudo-code can be found here http://en.wikipedia.org/wiki/Chord_%28peer-to-peer%29
class
RingMember
:
def
__init__
(
self
,
id
,
ip
,
port
):
self
.
port
=
port
self
.
ip
=
ip
self
.
id
=
id
def
toString
(
self
):
return
str
(
self
.
id
)
+
' '
+
self
.
ip
+
' '
+
str
(
self
.
port
)
class
Ring
:
def
__init__
(
self
,
entry_point
):
# initialize the connection
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
self
.
sock
.
bind
((
''
,
0
))
self
.
me
=
RingMember
(
uuid
.
uuid1
().
int
,
''
,
self
.
sock
.
getsockname
()[
1
])
# TODO : get the address
# to enter the ring
self
.
predecessor
=
None
if
entry_point
==
None
:
self
.
successor
=
self
.
me
else
:
self
.
send
(
'FIND_SUCCESSOR '
+
str
(
self
.
me
.
id
)
+
' '
+
self
.
me
.
toString
(),
entry_point
)
log
.
log
(
'Init the ring with me = '
+
self
.
me
.
toString
(),
3
)
# TODO :
def
handleMessages
(
self
):
# TODO : switch to log
log
.
log
(
'Handling messages ...'
,
3
)
pass
def
send
(
self
,
message
,
target
):
# TODO : switch to log
log
.
log
(
'Sending : '
+
message
+
' to '
+
target
.
toString
(),
5
)
self
.
sock
.
sendto
(
message
,
(
target
.
ip
,
target
.
port
))
def
findSuccessor
(
self
,
id
,
sender
):
if
self
.
id
<
id
and
id
<=
self
.
successor
:
self
.
send
(
'SUCCESSOR_IS '
+
self
.
successor
.
toString
(),
sender
)
else
:
self
.
send
(
'FIND_SUCCESSOR '
+
str
(
id
)
+
' '
+
sender
.
toString
(),
successor
)
# TODO : use the fingers
# Just copying the pseudocode from wikipedia, I will make it work later
# Possible messages (just for the creation of the ring) :
#
# find_successor $id $sender : $sender whants the IP of the successor of $id
# successor_is $ip $successor
# get_predecessor
# notify $sender_ip $sender_id
# PING
# called periodically
# pb : how to fix successor
# def stabilize(self):
# x = SEND get_predecessor TO self.successor
# if n < x && x < self.successor:
# self.successor = x
# SEND notify self.ip, self.id TO self.successor
# def notify(self, n2)
# if self.predecessor == None || (predecessor < n2 && n2 < n):
# self.predecessor = n2
# to be called periodically
# def fixFingers(self)
# # XXX: naming - should be finger_count
# next = (next + 1) mod (nFingers) # Or Random, cf google
# finger[next] = find_successor(n+2^{next-1});
# to be called periodically
# def checkPredecessor(self)
# if NO PING from self.predecessor:
# self.predecessor = None
re6st-registry.py
View file @
f6e96b71
...
@@ -4,7 +4,7 @@ import subprocess, time, threading, traceback, errno, logging, os, xmlrpclib
...
@@ -4,7 +4,7 @@ import subprocess, time, threading, traceback, errno, logging, os, xmlrpclib
from
SimpleXMLRPCServer
import
SimpleXMLRPCServer
,
SimpleXMLRPCRequestHandler
from
SimpleXMLRPCServer
import
SimpleXMLRPCServer
,
SimpleXMLRPCRequestHandler
from
email.mime.text
import
MIMEText
from
email.mime.text
import
MIMEText
from
OpenSSL
import
crypto
from
OpenSSL
import
crypto
import
utils
from
re6st
import
utils
# To generate server ca and key with serial for 2001:db8:42::/48
# To generate server ca and key with serial for 2001:db8:42::/48
# openssl req -nodes -new -x509 -key ca.key -set_serial 0x120010db80042 -days 365 -out ca.crt
# openssl req -nodes -new -x509 -key ca.key -set_serial 0x120010db80042 -days 365 -out ca.crt
...
...
re6st/__init__.py
0 → 100644
View file @
f6e96b71
db.py
→
re6st/
db.py
View file @
f6e96b71
File moved
plib.py
→
re6st/
plib.py
View file @
f6e96b71
...
@@ -3,6 +3,7 @@ import utils
...
@@ -3,6 +3,7 @@ import utils
verbose
=
0
verbose
=
0
def
openvpn
(
hello_interval
,
*
args
,
**
kw
):
def
openvpn
(
hello_interval
,
*
args
,
**
kw
):
args
=
[
'openvpn'
,
args
=
[
'openvpn'
,
'--dev-type'
,
'tap'
,
'--dev-type'
,
'tap'
,
...
@@ -16,6 +17,7 @@ def openvpn(hello_interval, *args, **kw):
...
@@ -16,6 +17,7 @@ def openvpn(hello_interval, *args, **kw):
logging
.
trace
(
'%s'
%
(
args
,))
logging
.
trace
(
'%s'
%
(
args
,))
return
subprocess
.
Popen
(
args
,
**
kw
)
return
subprocess
.
Popen
(
args
,
**
kw
)
def
server
(
server_ip
,
ip_length
,
max_clients
,
dh_path
,
pipe_fd
,
port
,
proto
,
hello_interval
,
*
args
,
**
kw
):
def
server
(
server_ip
,
ip_length
,
max_clients
,
dh_path
,
pipe_fd
,
port
,
proto
,
hello_interval
,
*
args
,
**
kw
):
logging
.
debug
(
'Starting server...'
)
logging
.
debug
(
'Starting server...'
)
return
openvpn
(
hello_interval
,
return
openvpn
(
hello_interval
,
...
@@ -30,12 +32,13 @@ def server(server_ip, ip_length, max_clients, dh_path, pipe_fd, port, proto, hel
...
@@ -30,12 +32,13 @@ def server(server_ip, ip_length, max_clients, dh_path, pipe_fd, port, proto, hel
'--proto'
,
proto
,
'--proto'
,
proto
,
*
args
,
**
kw
)
*
args
,
**
kw
)
def
client
(
server_address
,
pipe_fd
,
hello_interval
,
*
args
,
**
kw
):
def
client
(
server_address
,
pipe_fd
,
hello_interval
,
*
args
,
**
kw
):
logging
.
debug
(
'Starting client...'
)
logging
.
debug
(
'Starting client...'
)
remote
=
[
'--nobind'
,
remote
=
[
'--nobind'
,
'--client'
,
'--client'
,
'--up'
,
'ovpn-client'
,
'--up'
,
'ovpn-client'
,
'--route-up'
,
'ovpn-client '
+
str
(
pipe_fd
)
]
'--route-up'
,
'ovpn-client '
+
str
(
pipe_fd
)]
try
:
try
:
for
ip
,
port
,
proto
in
utils
.
address_list
(
server_address
):
for
ip
,
port
,
proto
in
utils
.
address_list
(
server_address
):
remote
+=
'--remote'
,
ip
,
port
,
proto
remote
+=
'--remote'
,
ip
,
port
,
proto
...
@@ -45,6 +48,7 @@ def client(server_address, pipe_fd, hello_interval, *args, **kw):
...
@@ -45,6 +48,7 @@ def client(server_address, pipe_fd, hello_interval, *args, **kw):
remote
+=
args
remote
+=
args
return
openvpn
(
hello_interval
,
*
remote
,
**
kw
)
return
openvpn
(
hello_interval
,
*
remote
,
**
kw
)
def
router
(
network
,
internal_ip
,
interface_list
,
def
router
(
network
,
internal_ip
,
interface_list
,
wireless
,
hello_interval
,
state_path
,
**
kw
):
wireless
,
hello_interval
,
state_path
,
**
kw
):
logging
.
info
(
'Starting babel...'
)
logging
.
info
(
'Starting babel...'
)
...
@@ -70,4 +74,3 @@ def router(network, internal_ip, interface_list,
...
@@ -70,4 +74,3 @@ def router(network, internal_ip, interface_list,
args
=
args
+
interface_list
args
=
args
+
interface_list
logging
.
trace
(
'%s'
%
args
)
logging
.
trace
(
'%s'
%
args
)
return
subprocess
.
Popen
(
args
,
**
kw
)
return
subprocess
.
Popen
(
args
,
**
kw
)
tunnel.py
→
re6st/
tunnel.py
View file @
f6e96b71
import
os
,
random
,
traceback
,
time
,
struct
,
subprocess
,
operator
,
math
,
logging
import
os
,
traceback
,
time
,
subprocess
,
math
,
logging
import
plib
,
utils
,
db
import
plib
smooth
=
0.3
# this is used to smooth the traffic sampling. Lower value
smooth
=
0.3
# this is used to smooth the traffic sampling. Lower value
# mean more smooth
# mean more smooth
...
...
upnpigd.py
→
re6st/
upnpigd.py
View file @
f6e96b71
File moved
utils.py
→
re6st/
utils.py
View file @
f6e96b71
File moved
re6stnet.py
View file @
f6e96b71
#!/usr/bin/env python
#!/usr/bin/env python
import
argparse
,
errno
,
os
,
select
,
subprocess
,
sqlite3
,
time
,
logging
import
argparse
,
errno
,
os
,
select
,
subprocess
,
sqlite3
,
time
,
logging
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
import
db
,
plib
,
upnpigd
,
utils
,
tunnel
from
re6st
import
plib
,
utils
,
db
,
upnpigd
,
tunnel
class
ArgParser
(
ArgumentParser
):
class
ArgParser
(
ArgumentParser
):
...
...
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