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
35557fbc
Commit
35557fbc
authored
May 21, 2024
by
Tom Niget
Committed by
Tom Niget
Jun 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: add type hints in registry
parent
8bf8de4e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
re6st/registry.py
re6st/registry.py
+6
-6
No files found.
re6st/registry.py
View file @
35557fbc
...
@@ -201,10 +201,10 @@ class RegistryServer:
...
@@ -201,10 +201,10 @@ class RegistryServer:
x
=
utils
.
packInteger
(
1
+
utils
.
unpackInteger
(
self
.
version
)[
0
])
x
=
utils
.
packInteger
(
1
+
utils
.
unpackInteger
(
self
.
version
)[
0
])
self
.
version
=
x
+
self
.
cert
.
sign
(
x
)
self
.
version
=
x
+
self
.
cert
.
sign
(
x
)
def
sendto
(
self
,
prefix
,
code
):
def
sendto
(
self
,
prefix
:
str
,
code
:
int
):
self
.
sock
.
sendto
((
"%s
\
0
%c"
%
(
prefix
,
code
)).
encode
(
"utf-8"
),
(
'::1'
,
tunnel
.
PORT
))
self
.
sock
.
sendto
((
"%s
\
0
%c"
%
(
prefix
,
code
)).
encode
(
"utf-8"
),
(
'::1'
,
tunnel
.
PORT
))
def
recv
(
self
,
code
):
def
recv
(
self
,
code
:
int
)
->
(
str
,
str
):
try
:
try
:
data
=
self
.
sock
.
recv
(
1
<<
16
)
data
=
self
.
sock
.
recv
(
1
<<
16
)
logging
.
info
(
"recv raw: %r"
,
data
)
logging
.
info
(
"recv raw: %r"
,
data
)
...
@@ -215,7 +215,7 @@ class RegistryServer:
...
@@ -215,7 +215,7 @@ class RegistryServer:
else
:
else
:
if
msg
:
if
msg
:
if
msg
[
0
:
1
]
==
bytes
([
code
]):
if
msg
[
0
:
1
]
==
bytes
([
code
]):
return
prefix
.
decode
(),
msg
[
1
:]
return
prefix
.
decode
(),
msg
[
1
:]
.
decode
()
else
:
else
:
logging
.
error
(
"Unexpected code: %r"
,
msg
)
logging
.
error
(
"Unexpected code: %r"
,
msg
)
else
:
else
:
...
@@ -615,7 +615,7 @@ class RegistryServer:
...
@@ -615,7 +615,7 @@ class RegistryServer:
v
and
base64
.
b64encode
(
x509
.
encrypt
(
cert
,
v
)).
decode
(
"ascii"
)
v
and
base64
.
b64encode
(
x509
.
encrypt
(
cert
,
v
)).
decode
(
"ascii"
)
return
zlib
.
compress
(
json
.
dumps
(
config
).
encode
(
"utf-8"
))
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
)
logging
.
info
(
"Querying address for %s/%s %r"
,
int
(
peer
,
2
),
len
(
peer
),
peer
)
self
.
sendto
(
peer
,
1
)
self
.
sendto
(
peer
,
1
)
s
=
self
.
sock
,
s
=
self
.
sock
,
...
@@ -626,13 +626,13 @@ class RegistryServer:
...
@@ -626,13 +626,13 @@ class RegistryServer:
prefix
,
msg
=
self
.
recv
(
1
)
prefix
,
msg
=
self
.
recv
(
1
)
logging
.
info
(
"* received: %r - %r"
,
prefix
,
msg
)
logging
.
info
(
"* received: %r - %r"
,
prefix
,
msg
)
if
prefix
==
peer
:
if
prefix
==
peer
:
return
msg
.
decode
()
return
msg
timeout
=
max
(
0
,
end
-
time
.
time
())
timeout
=
max
(
0
,
end
-
time
.
time
())
logging
.
info
(
"Timeout while querying address for %s/%s"
,
logging
.
info
(
"Timeout while querying address for %s/%s"
,
int
(
peer
,
2
),
len
(
peer
))
int
(
peer
,
2
),
len
(
peer
))
@
rpc
@
rpc
def
getCountry
(
self
,
cn
,
address
):
def
getCountry
(
self
,
cn
,
address
)
->
bytes
:
country
=
self
.
_geoiplookup
(
address
)[
0
]
country
=
self
.
_geoiplookup
(
address
)[
0
]
return
None
if
country
==
'*'
else
country
.
encode
()
return
None
if
country
==
'*'
else
country
.
encode
()
...
...
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