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
e79bb78e
Commit
e79bb78e
authored
Oct 12, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug preventing the registry to send its own address for bootstrap
parent
b6d43ac1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
re6st/db.py
re6st/db.py
+10
-8
re6st/tunnel.py
re6st/tunnel.py
+2
-3
No files found.
re6st/db.py
View file @
e79bb78e
...
...
@@ -69,14 +69,16 @@ class PeerDB(object):
(
prefix
,)).
fetchone
()
return
r
and
r
[
0
]
def
getPeerList
(
self
,
failed
=
0
):
# Exclude our own address from results in case it is there, which may
# happen if a node change its certificate without clearing the cache.
# IOW, one should probably always put our own address there.
return
self
.
_db
.
execute
(
"SELECT prefix, address FROM peer, volatile.stat"
" WHERE prefix=peer AND prefix!=? AND try=? ORDER BY RANDOM()"
,
(
self
.
_prefix
,
failed
))
# Exclude our own address from results in case it is there, which may
# happen if a node change its certificate without clearing the cache.
# IOW, one should probably always put our own address there.
_get_peer_sql
=
"SELECT %s FROM peer, volatile.stat"
\
" WHERE prefix=peer AND prefix!=? AND try=?"
def
getPeerList
(
self
,
failed
=
0
,
__sql
=
_get_peer_sql
%
"prefix, address"
+
" ORDER BY RANDOM()"
):
return
self
.
_db
.
execute
(
__sql
,
(
self
.
_prefix
,
failed
))
def
getPeerCount
(
self
,
failed
=
0
,
__sql
=
_get_peer_sql
%
"COUNT(*)"
):
return
self
.
_db
.
execute
(
__sql
,
(
self
.
_prefix
,
failed
)).
next
()[
0
]
def
getBootstrapPeer
(
self
):
logging
.
info
(
'Getting Boot peer...'
)
...
...
re6st/tunnel.py
View file @
e79bb78e
...
...
@@ -327,9 +327,8 @@ class TunnelManager(object):
else
:
# I don't know my IP yet!
msg
=
[]
# Add an extra random peer, mainly for the registry.
for
peer
in
self
.
_peer_db
.
getPeerList
():
msg
.
append
(
encode
(
peer
))
break
if
random
.
randint
(
0
,
self
.
_peer_db
.
getPeerCount
()):
msg
.
append
(
encode
(
self
.
_peer_db
.
getPeerList
().
next
()))
if
msg
:
try
:
self
.
sock
.
sendto
(
'
\
1
'
+
''
.
join
(
msg
),
address
)
...
...
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