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
8ea1ddfc
Commit
8ea1ddfc
authored
Mar 29, 2022
by
Julien Muchembled
Committed by
Joanne Hugé
May 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
registry: clean-up
parent
99cf2adc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
re6st/registry.py
re6st/registry.py
+21
-15
No files found.
re6st/registry.py
View file @
8ea1ddfc
...
@@ -88,7 +88,8 @@ class RegistryServer(object):
...
@@ -88,7 +88,8 @@ class RegistryServer(object):
"prefix TEXT PRIMARY KEY NOT NULL"
,
"prefix TEXT PRIMARY KEY NOT NULL"
,
"email TEXT"
,
"email TEXT"
,
"cert TEXT"
)
"cert TEXT"
)
self
.
db
.
execute
(
"INSERT OR IGNORE INTO cert VALUES ('',null,null)"
)
if
not
self
.
db
.
execute
(
"SELECT 1 FROM cert LIMIT 1"
).
fetchone
():
self
.
db
.
execute
(
"INSERT INTO cert VALUES ('',null,null)"
)
utils
.
sqliteCreateTable
(
self
.
db
,
"crl"
,
utils
.
sqliteCreateTable
(
self
.
db
,
"crl"
,
"serial INTEGER PRIMARY KEY NOT NULL"
,
"serial INTEGER PRIMARY KEY NOT NULL"
,
# Expiration date of revoked certificate.
# Expiration date of revoked certificate.
...
@@ -388,20 +389,25 @@ class RegistryServer(object):
...
@@ -388,20 +389,25 @@ class RegistryServer(object):
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
try
:
q
=
self
.
db
.
execute
prefix
,
=
self
.
db
.
execute
(
"""SELECT prefix FROM cert WHERE length(prefix) <= ? AND cert is null
while
True
:
ORDER BY length(prefix) DESC"""
,
(
prefix_len
,)).
next
()
try
:
except
StopIteration
:
prefix
,
=
q
(
logging
.
error
(
'No more free /%u prefix available'
,
prefix_len
)
"SELECT prefix FROM cert"
raise
" WHERE length(prefix) <= ? AND cert is null"
while
len
(
prefix
)
<
prefix_len
:
" ORDER BY length(prefix) DESC"
,
self
.
db
.
execute
(
"UPDATE cert SET prefix = ? WHERE prefix = ?"
,
(
prefix
+
'1'
,
prefix
))
(
prefix_len
,)).
next
()
prefix
+=
'0'
except
StopIteration
:
self
.
db
.
execute
(
"INSERT INTO cert VALUES (?,null,null)"
,
(
prefix
,))
logging
.
error
(
'No more free /%u prefix available'
,
prefix_len
)
if
len
(
prefix
)
<
max_len
or
'1'
in
prefix
:
raise
return
prefix
while
len
(
prefix
)
<
prefix_len
:
self
.
db
.
execute
(
"UPDATE cert SET cert = 'reserved' WHERE prefix = ?"
,
(
prefix
,))
q
(
"UPDATE cert SET prefix = ? WHERE prefix = ?"
,
return
self
.
newPrefix
(
prefix_len
)
(
prefix
+
'1'
,
prefix
))
prefix
+=
'0'
q
(
"INSERT INTO cert VALUES (?,null,null)"
,
(
prefix
,))
if
len
(
prefix
)
<
max_len
or
'1'
in
prefix
:
return
prefix
q
(
"UPDATE cert SET cert = 'reserved' WHERE prefix = ?"
,
(
prefix
,))
@
rpc
@
rpc
def
requestCertificate
(
self
,
token
,
req
):
def
requestCertificate
(
self
,
token
,
req
):
...
...
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