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