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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
re6stnet
Commits
35e585dc
Commit
35e585dc
authored
Jul 06, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script starts babel
parent
aa7588d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
client-connect
client-connect
+1
-0
main.py
main.py
+9
-6
No files found.
client-connect
View file @
35e585dc
#!/usr/bin/python -S
#!/usr/bin/python -S
import
os
,
sys
import
os
,
sys
import
pdb
;
pdb
.
set_trace
()
os
.
write
(
int
(
sys
.
argv
[
1
]),
'CLIENT_CONNECTED '
+
os
.
environ
[
'trusted_ip'
]
+
'
\
n
'
)
os
.
write
(
int
(
sys
.
argv
[
1
]),
'CLIENT_CONNECTED '
+
os
.
environ
[
'trusted_ip'
]
+
'
\
n
'
)
main.py
View file @
35e585dc
...
@@ -29,7 +29,7 @@ class PeersDB:
...
@@ -29,7 +29,7 @@ class PeersDB:
used INTEGER NOT NULL)"""
)
used INTEGER NOT NULL)"""
)
self
.
db
.
execute
(
"CREATE INDEX IF NOT EXISTS _peers_used ON peers(used)"
)
self
.
db
.
execute
(
"CREATE INDEX IF NOT EXISTS _peers_used ON peers(used)"
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0"
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0"
)
def
getUnusedPeers
(
self
,
nPeers
):
def
getUnusedPeers
(
self
,
nPeers
):
return
self
.
db
.
execute
(
"SELECT id, ip, port, proto FROM peers WHERE used = 0 "
return
self
.
db
.
execute
(
"SELECT id, ip, port, proto FROM peers WHERE used = 0 "
"ORDER BY RANDOM() LIMIT ?"
,
(
nPeers
,))
"ORDER BY RANDOM() LIMIT ?"
,
(
nPeers
,))
...
@@ -37,22 +37,21 @@ class PeersDB:
...
@@ -37,22 +37,21 @@ class PeersDB:
def
usePeer
(
self
,
id
):
def
usePeer
(
self
,
id
):
log_message
(
'Updating peers database : using peer '
+
str
(
id
),
5
)
log_message
(
'Updating peers database : using peer '
+
str
(
id
),
5
)
self
.
db
.
execute
(
"UPDATE peers SET used = 1 WHERE id = ?"
,
(
id
,))
self
.
db
.
execute
(
"UPDATE peers SET used = 1 WHERE id = ?"
,
(
id
,))
def
unusePeer
(
self
,
id
):
def
unusePeer
(
self
,
id
):
log_message
(
'Updating peers database : unusing peer '
+
str
(
id
),
5
)
log_message
(
'Updating peers database : unusing peer '
+
str
(
id
),
5
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0 WHERE id = ?"
,
(
id
,))
self
.
db
.
execute
(
"UPDATE peers SET used = 0 WHERE id = ?"
,
(
id
,))
def
startBabel
():
def
babel
(
network_ip
,
network_mask
):
args
=
[
'babeld'
,
args
=
[
'babeld'
,
'-C'
,
'redistribute local ip %s
/%s'
%
(
network_ip
,
network_mask
),
'-C'
,
'redistribute local ip %s
'
%
(
config
.
ip
),
'-C'
,
'redistribute local deny'
,
'-C'
,
'redistribute local deny'
,
# Route VIFIB ip adresses
# Route VIFIB ip adresses
'-C'
,
'in ip %s'
%
VIFIB_NET
,
'-C'
,
'in ip %s'
%
VIFIB_NET
,
# Route only addresse in the 'local' network,
# Route only addresse in the 'local' network,
# or other entire networks
# or other entire networks
'-C'
,
'in ip %s/%s'
%
(
network_ip
,
network_mask
),
#'-C', 'in ip %s' % (config.ip
),
#'-C', 'in ip ::/0 le %s' % network_mask,
#'-C', 'in ip ::/0 le %s' % network_mask,
# Don't route other addresses
# Don't route other addresses
'-C'
,
'in ip deny'
,
'-C'
,
'in ip deny'
,
...
@@ -169,6 +168,10 @@ def main():
...
@@ -169,6 +168,10 @@ def main():
global
peers_db
# stop using global variables for everything ?
global
peers_db
# stop using global variables for everything ?
peers_db
=
PeersDB
(
config
.
db
)
peers_db
=
PeersDB
(
config
.
db
)
# Launch babel on all interfaces
log_message
(
'Starting babel'
,
3
)
babel
=
startBabel
()
# Create and open read_only pipe to get connect/disconnect events from openvpn
# Create and open read_only pipe to get connect/disconnect events from openvpn
log_message
(
'Creating pipe for openvpn events'
,
3
)
log_message
(
'Creating pipe for openvpn events'
,
3
)
r_pipe
,
write_pipe
=
os
.
pipe
()
r_pipe
,
write_pipe
=
os
.
pipe
()
...
...
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