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
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
nexedi
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
Show 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):
...
@@ -69,14 +69,16 @@ class PeerDB(object):
(
prefix
,)).
fetchone
()
(
prefix
,)).
fetchone
()
return
r
and
r
[
0
]
return
r
and
r
[
0
]
def
getPeerList
(
self
,
failed
=
0
):
# Exclude our own address from results in case it is there, which may
# Exclude our own address from results in case it is there, which may
# happen if a node change its certificate without clearing the cache.
# happen if a node change its certificate without clearing the cache.
# IOW, one should probably always put our own address there.
# IOW, one should probably always put our own address there.
return
self
.
_db
.
execute
(
_get_peer_sql
=
"SELECT %s FROM peer, volatile.stat"
\
"SELECT prefix, address FROM peer, volatile.stat"
" WHERE prefix=peer AND prefix!=? AND try=?"
" WHERE prefix=peer AND prefix!=? AND try=? ORDER BY RANDOM()"
,
def
getPeerList
(
self
,
failed
=
0
,
__sql
=
_get_peer_sql
%
"prefix, address"
(
self
.
_prefix
,
failed
))
+
" 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
):
def
getBootstrapPeer
(
self
):
logging
.
info
(
'Getting Boot peer...'
)
logging
.
info
(
'Getting Boot peer...'
)
...
...
re6st/tunnel.py
View file @
e79bb78e
...
@@ -327,9 +327,8 @@ class TunnelManager(object):
...
@@ -327,9 +327,8 @@ class TunnelManager(object):
else
:
# I don't know my IP yet!
else
:
# I don't know my IP yet!
msg
=
[]
msg
=
[]
# Add an extra random peer, mainly for the registry.
# Add an extra random peer, mainly for the registry.
for
peer
in
self
.
_peer_db
.
getPeerList
():
if
random
.
randint
(
0
,
self
.
_peer_db
.
getPeerCount
()):
msg
.
append
(
encode
(
peer
))
msg
.
append
(
encode
(
self
.
_peer_db
.
getPeerList
().
next
()))
break
if
msg
:
if
msg
:
try
:
try
:
self
.
sock
.
sendto
(
'
\
1
'
+
''
.
join
(
msg
),
address
)
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