Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
re6stnet
Commits
3dc25c00
Commit
3dc25c00
authored
Dec 18, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 2 new experimental commands: re6st-cn & re6st-geo
parent
ee745d9b
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
314 additions
and
0 deletions
+314
-0
re6st-cn
draft/re6st-cn
+33
-0
re6st-geo
draft/re6st-geo
+281
-0
No files found.
draft/re6st-cn
0 → 100755
View file @
3dc25c00
#!/usr/bin/python
import
sqlite3
,
sys
import
os
;
sys
.
path
[
0
]
=
os
.
path
.
dirname
(
sys
.
path
[
0
])
from
re6st
import
utils
from
OpenSSL
import
crypto
with
open
(
"/etc/re6stnet/ca.crt"
)
as
f
:
ca
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
f
.
read
())
network
=
utils
.
networkFromCa
(
ca
)
db
=
sqlite3
.
connect
(
"/var/lib/re6stnet/registry.db"
)
for
x
in
sys
.
argv
[
1
:]:
try
:
a
,
b
=
x
.
split
(
'/'
)
except
ValueError
:
prefix
=
x
else
:
b
=
int
(
b
)
try
:
prefix
=
bin
(
int
(
a
))[
2
:]
.
zfill
(
b
)
except
ValueError
:
a
=
utils
.
binFromIp
(
a
)
assert
a
.
startswith
(
network
)
prefix
=
a
[
len
(
network
):
b
]
a
=
db
.
execute
(
"select * from cert where prefix=?"
,
(
prefix
,))
.
fetchone
()
b
=
network
+
prefix
b
=
'
%
s/
%
s'
%
(
utils
.
ipFromBin
(
b
),
len
(
b
))
if
a
:
subject
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
a
[
2
])
.
get_subject
()
print
"
%
s
\t
%
s
\t
%
s"
%
(
b
,
a
[
1
],
''
.
join
(
'/
%
s=
%
s'
%
x
for
x
in
subject
.
get_components
()))
else
:
print
"
%
s
\t
-"
%
b
db
.
close
()
draft/re6st-geo
0 → 100755
View file @
3dc25c00
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