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
a536c63a
Commit
a536c63a
authored
Mar 30, 2022
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
registry: add mergePrefixes method
parent
8ea1ddfc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
re6st/registry.py
re6st/registry.py
+23
-2
No files found.
re6st/registry.py
View file @
a536c63a
...
@@ -247,8 +247,7 @@ class RegistryServer(object):
...
@@ -247,8 +247,7 @@ class RegistryServer(object):
(
prefix
,))
(
prefix
,))
elif
not_after
is
None
or
x
<
not_after
:
elif
not_after
is
None
or
x
<
not_after
:
not_after
=
x
not_after
=
x
# TODO: reduce 'cert' table by merging free slots
self
.
mergePrefixes
()
# (IOW, do the contrary of newPrefix)
self
.
timeout
=
not_after
and
not_after
+
GRACE_PERIOD
self
.
timeout
=
not_after
and
not_after
+
GRACE_PERIOD
def
handle_request
(
self
,
request
,
method
,
kw
):
def
handle_request
(
self
,
request
,
method
,
kw
):
...
@@ -386,6 +385,28 @@ class RegistryServer(object):
...
@@ -386,6 +385,28 @@ class RegistryServer(object):
s
.
sendmail
(
self
.
email
,
email
,
msg
.
as_string
())
s
.
sendmail
(
self
.
email
,
email
,
msg
.
as_string
())
s
.
quit
()
s
.
quit
()
def
mergePrefixes
(
self
):
q
=
self
.
db
.
execute
prev_prefix
=
None
max_len
=
128
,
while
True
:
max_len
=
q
(
"SELECT max(length(prefix)) FROM cert"
" WHERE cert is null AND length(prefix) < ?"
,
max_len
).
next
()
if
not
max_len
[
0
]:
break
for
prefix
,
in
q
(
"SELECT prefix FROM cert"
" WHERE cert is null AND length(prefix) = ?"
" ORDER BY prefix"
,
max_len
):
if
prev_prefix
and
prefix
[:
-
1
]
==
prev_prefix
[:
-
1
]:
q
(
"UPDATE cert SET prefix = ? WHERE prefix = ?"
,
(
prefix
[:
-
1
],
prev_prefix
))
q
(
"DELETE FROM cert WHERE prefix = ?"
,
(
prefix
,))
prev_prefix
=
None
else
:
prev_prefix
=
prefix
def
newPrefix
(
self
,
prefix_len
):
def
newPrefix
(
self
,
prefix_len
):
max_len
=
128
-
len
(
self
.
network
)
max_len
=
128
-
len
(
self
.
network
)
assert
0
<
prefix_len
<=
max_len
assert
0
<
prefix_len
<=
max_len
...
...
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