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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
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
import
os
,
sys
import
pdb
;
pdb
.
set_trace
()
os
.
write
(
int
(
sys
.
argv
[
1
]),
'CLIENT_CONNECTED '
+
os
.
environ
[
'trusted_ip'
]
+
'
\
n
'
)
main.py
View file @
35e585dc
...
...
@@ -29,7 +29,7 @@ class PeersDB:
used INTEGER NOT NULL)"""
)
self
.
db
.
execute
(
"CREATE INDEX IF NOT EXISTS _peers_used ON peers(used)"
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0"
)
def
getUnusedPeers
(
self
,
nPeers
):
return
self
.
db
.
execute
(
"SELECT id, ip, port, proto FROM peers WHERE used = 0 "
"ORDER BY RANDOM() LIMIT ?"
,
(
nPeers
,))
...
...
@@ -37,22 +37,21 @@ class PeersDB:
def
usePeer
(
self
,
id
):
log_message
(
'Updating peers database : using peer '
+
str
(
id
),
5
)
self
.
db
.
execute
(
"UPDATE peers SET used = 1 WHERE id = ?"
,
(
id
,))
def
unusePeer
(
self
,
id
):
log_message
(
'Updating peers database : unusing peer '
+
str
(
id
),
5
)
self
.
db
.
execute
(
"UPDATE peers SET used = 0 WHERE id = ?"
,
(
id
,))
def
babel
(
network_ip
,
network_mask
):
def
startBabel
():
args
=
[
'babeld'
,
'-C'
,
'redistribute local ip %s
/%s'
%
(
network_ip
,
network_mask
),
'-C'
,
'redistribute local ip %s
'
%
(
config
.
ip
),
'-C'
,
'redistribute local deny'
,
# Route VIFIB ip adresses
'-C'
,
'in ip %s'
%
VIFIB_NET
,
# Route only addresse in the 'local' network,
# 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,
# Don't route other addresses
'-C'
,
'in ip deny'
,
...
...
@@ -169,6 +168,10 @@ def main():
global
peers_db
# stop using global variables for everything ?
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
log_message
(
'Creating pipe for openvpn events'
,
3
)
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