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
7be78ac9
Commit
7be78ac9
authored
9 months ago
by
Tom Niget
Committed by
Tom Niget
8 months ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: add type hints in registry
parent
84ac321a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
re6st/registry.py
re6st/registry.py
+5
-5
No files found.
re6st/registry.py
View file @
7be78ac9
...
...
@@ -204,7 +204,7 @@ class RegistryServer:
def
sendto
(
self
,
prefix
:
str
,
code
:
int
):
self
.
sock
.
sendto
(
prefix
.
encode
()
+
bytes
((
0
,
code
)),
(
'::1'
,
tunnel
.
PORT
))
def
recv
(
self
,
code
):
def
recv
(
self
,
code
:
int
)
->
(
str
,
str
):
try
:
prefix
,
msg
=
self
.
sock
.
recv
(
1
<<
16
).
split
(
b'
\
x00
'
,
1
)
int
(
prefix
,
2
)
...
...
@@ -213,7 +213,7 @@ class RegistryServer:
else
:
if
msg
:
if
msg
[
0
:
1
]
==
bytes
([
code
]):
return
prefix
.
decode
(),
msg
[
1
:]
return
prefix
.
decode
(),
msg
[
1
:]
.
decode
()
else
:
logging
.
error
(
"Unexpected code: %r"
,
msg
)
else
:
...
...
@@ -614,7 +614,7 @@ class RegistryServer:
v
and
base64
.
b64encode
(
x509
.
encrypt
(
cert
,
v
)).
decode
()
return
zlib
.
compress
(
json
.
dumps
(
config
).
encode
(
"utf-8"
))
def
_queryAddress
(
self
,
peer
):
def
_queryAddress
(
self
,
peer
)
->
str
:
logging
.
info
(
"Querying address for %s/%s %r"
,
int
(
peer
,
2
),
len
(
peer
),
peer
)
self
.
sendto
(
peer
,
1
)
s
=
self
.
sock
,
...
...
@@ -625,13 +625,13 @@ class RegistryServer:
prefix
,
msg
=
self
.
recv
(
1
)
logging
.
info
(
"* received: %r - %r"
,
prefix
,
msg
)
if
prefix
==
peer
:
return
msg
.
decode
()
return
msg
timeout
=
max
(
0
,
end
-
time
.
time
())
logging
.
info
(
"Timeout while querying address for %s/%s"
,
int
(
peer
,
2
),
len
(
peer
))
@
rpc
def
getCountry
(
self
,
cn
,
address
):
def
getCountry
(
self
,
cn
,
address
)
->
bytes
:
country
=
self
.
_geoiplookup
(
address
)[
0
]
return
None
if
country
==
'*'
else
country
.
encode
()
...
...
This diff is collapsed.
Click to expand it.
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