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
zhifan huang
re6stnet
Commits
45b09b5a
Commit
45b09b5a
authored
May 06, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more_registry update
parent
8527bff8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
re6st/registry.py
re6st/registry.py
+3
-3
re6st/tests/test_unit/test_registry.py
re6st/tests/test_unit/test_registry.py
+4
-4
re6st/x509.py
re6st/x509.py
+2
-1
No files found.
re6st/registry.py
View file @
45b09b5a
...
...
@@ -164,7 +164,7 @@ class RegistryServer(object):
self
.
sendto
(
self
.
prefix
,
0
)
# The following entry lists values that are base64-encoded.
kw
[
''
]
=
'version'
,
kw
[
'version'
]
=
base64
.
b64encode
(
self
.
version
)
kw
[
'version'
]
=
base64
.
b64encode
(
self
.
version
)
self
.
network_config
=
kw
def
increaseVersion
(
self
):
...
...
@@ -517,7 +517,7 @@ class RegistryServer(object):
v
and
x509
.
encrypt
(
cert
,
v
).
encode
(
'base64'
)
return
zlib
.
compress
(
json
.
dumps
(
config
))
def
_queryAddress
(
self
,
peer
):
def
_queryAddress
(
self
,
peer
)
->
bytes
:
self
.
sendto
(
peer
,
1
)
s
=
self
.
sock
,
timeout
=
3
...
...
@@ -563,7 +563,7 @@ class RegistryServer(object):
msg
=
';'
.
join
(
','
.
join
(
a
.
split
(
','
)[:
3
])
for
a
in
msg
.
split
(
';'
))
cert
=
self
.
getCert
(
cn
)
msg
=
"%s %s"
%
(
peer
,
msg
)
msg
=
b
"%s %s"
%
(
peer
,
msg
)
logging
.
info
(
"Sending bootstrap peer: %s"
,
msg
)
return
x509
.
encrypt
(
cert
,
msg
)
...
...
re6st/tests/test_unit/test_registry.py
View file @
45b09b5a
...
...
@@ -362,12 +362,11 @@ class TestRegistryServer(unittest.TestCase):
cn
=
new_prefix
()
pkey
,
_
=
insert_cert
(
self
.
server
.
db
,
self
.
server
.
cert
,
cn
)
self
.
server
.
sessions
[
cn
]
=
[(
0
,
7
)]
query
.
return_value
=
expect_msg
=
"address"
query
.
return_value
=
expect_msg
=
b
"address"
self
.
server
.
ctl
.
neighbours
=
neigh
=
{}
# peers while looke like [0, 1, 2, 3, 4], have 5 peer
for
i
in
1
,
2
,
3
,
4
:
neigh
[
i
]
=
(
i
,
{
format
(
i
,
"016b"
):
i
})
neigh
[
i
]
=
(
i
,
{
format
(
i
,
"016b"
).
encode
():
i
})
msg
=
self
.
server
.
getBootstrapPeer
(
cn
)
...
...
@@ -489,7 +488,8 @@ class TestRegistryServer(unittest.TestCase):
(
None
,
None
),
(
"0000000000000000"
,
"v0"
),
(
"0000000000000001"
,
"v1"
),
(
"0000000000000001"
,
"v1"
)
(
"0000000000000001"
,
"v1"
),
(
"0000000000000000"
,
"v0"
)
]
recv
.
side_effect
=
recv_case
select_side_effect
.
i
=
len
(
recv_case
)
+
1
...
...
re6st/x509.py
View file @
45b09b5a
...
...
@@ -27,7 +27,8 @@ def openssl(*args, **kwargs):
stderr
=
subprocess
.
PIPE
,
**
kwargs
)
def
encrypt
(
cert
,
data
):
# use communicate so set data and return as bytes
def
encrypt
(
cert
,
data
:
bytes
)
->
bytes
:
r
,
w
=
os
.
pipe
()
# https://peps.python.org/pep-0446/ Make newly created file descriptors non-inheritable
# so need pass fd by subprocess
...
...
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