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
c119a92f
Commit
c119a92f
authored
Jun 07, 2019
by
Killian Lufau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Fix startup of nodes for HMAC
parent
0f77428d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
13 deletions
+28
-13
re6st/cache.py
re6st/cache.py
+7
-2
re6st/registry.py
re6st/registry.py
+1
-1
re6st/tunnel.py
re6st/tunnel.py
+17
-10
re6st/x509.py
re6st/x509.py
+3
-0
No files found.
re6st/cache.py
View file @
c119a92f
...
@@ -8,6 +8,7 @@ class Cache(object):
...
@@ -8,6 +8,7 @@ class Cache(object):
def
__init__
(
self
,
db_path
,
registry
,
cert
,
db_size
=
200
):
def
__init__
(
self
,
db_path
,
registry
,
cert
,
db_size
=
200
):
self
.
_prefix
=
cert
.
prefix
self
.
_prefix
=
cert
.
prefix
self
.
_db_size
=
db_size
self
.
_db_size
=
db_size
self
.
_crypt_size
=
len
(
cert
)
self
.
_decrypt
=
cert
.
decrypt
self
.
_decrypt
=
cert
.
decrypt
self
.
_registry
=
RegistryClient
(
registry
,
cert
)
self
.
_registry
=
RegistryClient
(
registry
,
cert
)
...
@@ -237,14 +238,18 @@ class Cache(object):
...
@@ -237,14 +238,18 @@ class Cache(object):
logging
.
info
(
'Getting Boot peer...'
)
logging
.
info
(
'Getting Boot peer...'
)
try
:
try
:
bootpeer
=
self
.
_registry
.
getBootstrapPeer
(
self
.
_prefix
)
bootpeer
=
self
.
_registry
.
getBootstrapPeer
(
self
.
_prefix
)
prefix
,
address
=
self
.
_decrypt
(
bootpeer
).
split
()
n
=
self
.
_crypt_size
prefix
,
address
=
self
.
_decrypt
(
bootpeer
[:
n
]).
split
()
except
(
socket
.
error
,
subprocess
.
CalledProcessError
,
ValueError
),
e
:
except
(
socket
.
error
,
subprocess
.
CalledProcessError
,
ValueError
),
e
:
logging
.
warning
(
'Failed to bootstrap (%s)'
,
logging
.
warning
(
'Failed to bootstrap (%s)'
,
e
if
bootpeer
else
'no peer returned'
)
e
if
bootpeer
else
'no peer returned'
)
else
:
else
:
version
=
bootpeer
[
n
:]
if
self
.
version
==
version
:
version
=
None
if
prefix
!=
self
.
_prefix
:
if
prefix
!=
self
.
_prefix
:
self
.
addPeer
(
prefix
,
address
)
self
.
addPeer
(
prefix
,
address
)
return
prefix
,
address
return
prefix
,
address
,
version
logging
.
warning
(
'Buggy registry sent us our own address'
)
logging
.
warning
(
'Buggy registry sent us our own address'
)
def
addPeer
(
self
,
prefix
,
address
,
set_preferred
=
False
):
def
addPeer
(
self
,
prefix
,
address
,
set_preferred
=
False
):
...
...
re6st/registry.py
View file @
c119a92f
...
@@ -534,7 +534,7 @@ class RegistryServer(object):
...
@@ -534,7 +534,7 @@ class RegistryServer(object):
cert
=
self
.
getCert
(
cn
)
cert
=
self
.
getCert
(
cn
)
msg
=
"%s %s"
%
(
peer
,
msg
)
msg
=
"%s %s"
%
(
peer
,
msg
)
logging
.
info
(
"Sending bootstrap peer: %s"
,
msg
)
logging
.
info
(
"Sending bootstrap peer: %s"
,
msg
)
return
x509
.
encrypt
(
cert
,
msg
)
return
x509
.
encrypt
(
cert
,
msg
)
+
self
.
version
@
rpc_private
@
rpc_private
def
revoke
(
self
,
cn_or_serial
):
def
revoke
(
self
,
cn_or_serial
):
...
...
re6st/tunnel.py
View file @
c119a92f
...
@@ -302,6 +302,7 @@ class BaseTunnelManager(object):
...
@@ -302,6 +302,7 @@ class BaseTunnelManager(object):
logging
.
debug
(
"timeout: updating %r (%s)"
,
callback
.
__name__
,
next
)
logging
.
debug
(
"timeout: updating %r (%s)"
,
callback
.
__name__
,
next
)
t
[
i
]
=
next
,
callback
t
[
i
]
=
next
,
callback
return
return
if
next
:
logging
.
debug
(
"timeout: adding %r (%s)"
,
callback
.
__name__
,
next
)
logging
.
debug
(
"timeout: adding %r (%s)"
,
callback
.
__name__
,
next
)
t
.
append
((
next
,
callback
))
t
.
append
((
next
,
callback
))
...
@@ -538,6 +539,7 @@ class BaseTunnelManager(object):
...
@@ -538,6 +539,7 @@ class BaseTunnelManager(object):
logging
.
info
(
"will retry to update network parameters in 5 minutes"
)
logging
.
info
(
"will retry to update network parameters in 5 minutes"
)
self
.
selectTimeout
(
time
.
time
()
+
300
,
self
.
newVersion
)
self
.
selectTimeout
(
time
.
time
()
+
300
,
self
.
newVersion
)
return
return
assert
changed
logging
.
info
(
"changed: %r"
,
changed
)
logging
.
info
(
"changed: %r"
,
changed
)
self
.
selectTimeout
(
None
,
self
.
newVersion
)
self
.
selectTimeout
(
None
,
self
.
newVersion
)
self
.
_version
=
self
.
cache
.
version
self
.
_version
=
self
.
cache
.
version
...
@@ -889,11 +891,11 @@ class TunnelManager(BaseTunnelManager):
...
@@ -889,11 +891,11 @@ class TunnelManager(BaseTunnelManager):
if
route_dumped
:
if
route_dumped
:
logging
.
debug
(
'Analyze routes ...'
)
logging
.
debug
(
'Analyze routes ...'
)
neighbours
=
self
.
ctl
.
neighbours
neighbours
=
self
.
ctl
.
neighbours
# Collect all nodes known by Babel
# Collect all
reachable
nodes known by Babel
peers
=
set
(
prefix
peers
=
set
(
prefix
for
neigh_routes
in
neighbours
.
itervalues
()
for
neigh_routes
in
neighbours
.
itervalues
()
for
prefix
in
neigh_routes
[
1
]
for
prefix
,
route
in
neigh_routes
[
1
].
iteritems
()
if
prefix
)
if
prefix
and
route
.
metric
<
0xffff
)
# Keep only distant peers.
# Keep only distant peers.
distant_peers
[:]
=
peers
.
difference
(
neighbours
)
distant_peers
[:]
=
peers
.
difference
(
neighbours
)
distant_peers
.
sort
(
key
=
self
.
_newTunnelScore
)
distant_peers
.
sort
(
key
=
self
.
_newTunnelScore
)
...
@@ -904,9 +906,7 @@ class TunnelManager(BaseTunnelManager):
...
@@ -904,9 +906,7 @@ class TunnelManager(BaseTunnelManager):
# Faster recovery of registry node: use cache instead
# Faster recovery of registry node: use cache instead
# of waiting that another node tries to connect to it.
# of waiting that another node tries to connect to it.
distant_peers
=
None
distant_peers
=
None
elif
(
registry
in
peers
or
elif
registry
in
peers
:
registry
in
self
.
_connection_dict
or
registry
in
self
.
_served
):
self
.
_disconnected
=
0
self
.
_disconnected
=
0
# Be ready to receive any message from the registry.
# Be ready to receive any message from the registry.
self
.
sendto
(
registry
,
None
)
self
.
sendto
(
registry
,
None
)
...
@@ -921,7 +921,7 @@ class TunnelManager(BaseTunnelManager):
...
@@ -921,7 +921,7 @@ class TunnelManager(BaseTunnelManager):
if
peers
:
if
peers
:
# We aren't the only disconnected node
# We aren't the only disconnected node
# so force rebootstrapping.
# so force rebootstrapping.
peer
=
self
.
cache
.
getBootstrapPeer
()
peer
=
self
.
getBootstrapPeer
()
if
not
peer
:
if
not
peer
:
# Registry dead ? Assume we're connected after all.
# Registry dead ? Assume we're connected after all.
distant_peers
=
self
.
_distant_peers
distant_peers
=
self
.
_distant_peers
...
@@ -966,7 +966,7 @@ class TunnelManager(BaseTunnelManager):
...
@@ -966,7 +966,7 @@ class TunnelManager(BaseTunnelManager):
if
not
(
new
or
peers
):
if
not
(
new
or
peers
):
if
bootstrap
and
registry
!=
self
.
_prefix
:
if
bootstrap
and
registry
!=
self
.
_prefix
:
# Startup without any good address in the cache.
# Startup without any good address in the cache.
peer
=
self
.
cache
.
getBootstrapPeer
()
peer
=
self
.
getBootstrapPeer
()
if
peer
and
self
.
_makeTunnel
(
*
peer
):
if
peer
and
self
.
_makeTunnel
(
*
peer
):
return
return
# Failed to bootstrap ! Last chance to connect is to
# Failed to bootstrap ! Last chance to connect is to
...
@@ -975,6 +975,13 @@ class TunnelManager(BaseTunnelManager):
...
@@ -975,6 +975,13 @@ class TunnelManager(BaseTunnelManager):
if
self
.
_makeTunnel
(
*
peer
):
if
self
.
_makeTunnel
(
*
peer
):
break
break
def
getBootstrapPeer
(
self
):
peer
,
prefix
,
version
=
self
.
cache
.
getBootstrapPeer
()
if
version
:
self
.
_version
=
version
self
.
newVersion
()
return
peer
,
prefix
def
killAll
(
self
):
def
killAll
(
self
):
for
prefix
in
self
.
_connection_dict
.
keys
():
for
prefix
in
self
.
_connection_dict
.
keys
():
self
.
_kill
(
prefix
)
self
.
_kill
(
prefix
)
...
...
re6st/x509.py
View file @
c119a92f
...
@@ -94,6 +94,9 @@ class Cert(object):
...
@@ -94,6 +94,9 @@ class Cert(object):
with
open
(
cert
)
as
f
:
with
open
(
cert
)
as
f
:
self
.
cert
=
self
.
loadVerify
(
f
.
read
())
self
.
cert
=
self
.
loadVerify
(
f
.
read
())
def
__len__
(
self
):
return
self
.
key
.
bits
()
//
8
@
property
@
property
def
prefix
(
self
):
def
prefix
(
self
):
return
utils
.
binFromSubnet
(
subnetFromCert
(
self
.
cert
))
return
utils
.
binFromSubnet
(
subnetFromCert
(
self
.
cert
))
...
...
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