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
Yohann D'Anello
re6stnet
Commits
27f1c21a
Commit
27f1c21a
authored
Jul 26, 2012
by
Guillaume Bury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small changes in logs
parent
dcb0694e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
db.py
db.py
+11
-11
plib.py
plib.py
+4
-5
No files found.
db.py
View file @
27f1c21a
...
@@ -38,9 +38,9 @@ class PeerManager:
...
@@ -38,9 +38,9 @@ class PeerManager:
if
e
.
args
[
0
]
==
'no such table: peers'
:
if
e
.
args
[
0
]
==
'no such table: peers'
:
raise
RuntimeError
raise
RuntimeError
else
:
else
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
self
.
next_refresh
=
time
.
time
()
self
.
next_refresh
=
time
.
time
()
...
@@ -52,7 +52,7 @@ class PeerManager:
...
@@ -52,7 +52,7 @@ class PeerManager:
(
flag
,))
(
flag
,))
utils
.
log
(
'Blacklist cleared'
,
5
)
utils
.
log
(
'Blacklist cleared'
,
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
blacklist
(
self
,
prefix
,
flag
):
def
blacklist
(
self
,
prefix
,
flag
):
utils
.
log
(
'Blacklisting %s'
%
(
prefix
,),
4
)
utils
.
log
(
'Blacklisting %s'
%
(
prefix
,),
4
)
...
@@ -64,7 +64,7 @@ class PeerManager:
...
@@ -64,7 +64,7 @@ class PeerManager:
VALUES (?,?)"""
,
(
prefix
,
flag
))
VALUES (?,?)"""
,
(
prefix
,
flag
))
utils
.
log
(
'%s blacklisted'
%
(
prefix
,),
5
)
utils
.
log
(
'%s blacklisted'
%
(
prefix
,),
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
whitelist
(
self
,
prefix
):
def
whitelist
(
self
,
prefix
):
utils
.
log
(
'Unblacklisting %s'
%
(
prefix
,),
4
)
utils
.
log
(
'Unblacklisting %s'
%
(
prefix
,),
4
)
...
@@ -73,7 +73,7 @@ class PeerManager:
...
@@ -73,7 +73,7 @@ class PeerManager:
self
.
_db
.
execute
(
"DELETE FROM blacklist WHERE prefix = ?"
,
(
prefix
,))
self
.
_db
.
execute
(
"DELETE FROM blacklist WHERE prefix = ?"
,
(
prefix
,))
utils
.
log
(
'%s whitelisted'
%
(
prefix
,),
5
)
utils
.
log
(
'%s whitelisted'
%
(
prefix
,),
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
refresh
(
self
):
def
refresh
(
self
):
utils
.
log
(
'Refreshing the peers DB...'
,
2
)
utils
.
log
(
'Refreshing the peers DB...'
,
2
)
...
@@ -83,7 +83,7 @@ class PeerManager:
...
@@ -83,7 +83,7 @@ class PeerManager:
utils
.
log
(
'DB refreshed'
,
3
)
utils
.
log
(
'DB refreshed'
,
3
)
self
.
next_refresh
=
time
.
time
()
+
self
.
_refresh_time
self
.
next_refresh
=
time
.
time
()
+
self
.
_refresh_time
except
socket
.
error
,
e
:
except
socket
.
error
,
e
:
utils
.
log
(
str
(
e
)
,
4
)
utils
.
log
(
e
,
4
)
utils
.
log
(
'Connection to server failed, retrying in 30s'
,
2
)
utils
.
log
(
'Connection to server failed, retrying in 30s'
,
2
)
self
.
next_refresh
=
time
.
time
()
+
30
self
.
next_refresh
=
time
.
time
()
+
30
...
@@ -113,7 +113,7 @@ class PeerManager:
...
@@ -113,7 +113,7 @@ class PeerManager:
utils
.
log
(
'DB populated'
,
3
)
utils
.
log
(
'DB populated'
,
3
)
utils
.
log
(
'New peers : %s'
%
', '
.
join
(
map
(
str
,
new_peer_list
)),
5
)
utils
.
log
(
'New peers : %s'
%
', '
.
join
(
map
(
str
,
new_peer_list
)),
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
getUnusedPeers
(
self
,
peer_count
):
def
getUnusedPeers
(
self
,
peer_count
):
try
:
try
:
...
@@ -121,7 +121,7 @@ class PeerManager:
...
@@ -121,7 +121,7 @@ class PeerManager:
<= 0 ORDER BY used DESC,RANDOM() LIMIT ?"""
,
<= 0 ORDER BY used DESC,RANDOM() LIMIT ?"""
,
(
peer_count
,))
(
peer_count
,))
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
return
[(
'0'
,
''
)]
return
[(
'0'
,
''
)]
def
usePeer
(
self
,
prefix
):
def
usePeer
(
self
,
prefix
):
...
@@ -132,7 +132,7 @@ class PeerManager:
...
@@ -132,7 +132,7 @@ class PeerManager:
(
prefix
,))
(
prefix
,))
utils
.
log
(
'DB updated'
,
5
)
utils
.
log
(
'DB updated'
,
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
unusePeer
(
self
,
prefix
):
def
unusePeer
(
self
,
prefix
):
utils
.
log
(
'Updating peers database : unusing peer '
+
str
(
prefix
),
5
)
utils
.
log
(
'Updating peers database : unusing peer '
+
str
(
prefix
),
5
)
...
@@ -142,7 +142,7 @@ class PeerManager:
...
@@ -142,7 +142,7 @@ class PeerManager:
(
prefix
,))
(
prefix
,))
utils
.
log
(
'DB updated'
,
5
)
utils
.
log
(
'DB updated'
,
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
flagPeer
(
self
,
prefix
):
def
flagPeer
(
self
,
prefix
):
utils
.
log
(
'Updating peers database : flagging peer '
+
str
(
prefix
),
5
)
utils
.
log
(
'Updating peers database : flagging peer '
+
str
(
prefix
),
5
)
...
@@ -152,7 +152,7 @@ class PeerManager:
...
@@ -152,7 +152,7 @@ class PeerManager:
(
prefix
,))
(
prefix
,))
utils
.
log
(
'DB updated'
,
5
)
utils
.
log
(
'DB updated'
,
5
)
except
sqlite3
.
Error
,
e
:
except
sqlite3
.
Error
,
e
:
utils
.
log
(
str
(
e
)
,
1
)
utils
.
log
(
e
,
1
)
def
handle_message
(
self
,
msg
):
def
handle_message
(
self
,
msg
):
script_type
,
arg
=
msg
.
split
()
script_type
,
arg
=
msg
.
split
()
...
...
plib.py
View file @
27f1c21a
...
@@ -14,7 +14,7 @@ def openvpn(hello_interval, *args, **kw):
...
@@ -14,7 +14,7 @@ def openvpn(hello_interval, *args, **kw):
'--group'
,
'nogroup'
,
'--group'
,
'nogroup'
,
'--verb'
,
str
(
verbose
),
'--verb'
,
str
(
verbose
),
]
+
list
(
args
)
]
+
list
(
args
)
utils
.
log
(
str
(
args
)
,
5
)
utils
.
log
(
args
,
5
)
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
):
...
@@ -41,9 +41,8 @@ def client(server_address, pipe_fd, hello_interval, *args, **kw):
...
@@ -41,9 +41,8 @@ def client(server_address, pipe_fd, hello_interval, *args, **kw):
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
except
ValueError
,
e
:
except
ValueError
,
e
:
utils
.
log
(
e
,
1
)
utils
.
log
(
'Error "%s" in unpacking address %s for openvpn client'
utils
.
log
(
'Error in unpacking address %s for openvpn client'
%
(
e
,
server_address
,),
1
)
%
(
server_address
,),
1
)
remote
+=
args
remote
+=
args
return
openvpn
(
hello_interval
,
*
remote
,
**
kw
)
return
openvpn
(
hello_interval
,
*
remote
,
**
kw
)
...
@@ -70,6 +69,6 @@ def router(network, internal_ip, interface_list,
...
@@ -70,6 +69,6 @@ def router(network, internal_ip, interface_list,
if
wireless
:
if
wireless
:
args
.
append
(
'-w'
)
args
.
append
(
'-w'
)
args
=
args
+
interface_list
args
=
args
+
interface_list
utils
.
log
(
str
(
args
)
,
5
)
utils
.
log
(
args
,
5
)
return
subprocess
.
Popen
(
args
,
**
kw
)
return
subprocess
.
Popen
(
args
,
**
kw
)
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