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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
re6stnet
Commits
00fbbfe9
Commit
00fbbfe9
authored
Mar 12, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New --is-needed option to test whether re6st should be setup or not
parent
3493e13b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
16 deletions
+26
-16
re6st-conf
re6st-conf
+15
-3
re6st/utils.py
re6st/utils.py
+7
-11
re6stnet
re6stnet
+4
-2
No files found.
re6st-conf
View file @
00fbbfe9
...
...
@@ -17,6 +17,10 @@ def main():
_
=
parser
.
add_argument
_
(
'--registry'
,
required
=
True
,
metavar
=
'URL'
,
help
=
"HTTP URL of the server delivering certificates."
)
_
(
'--is-needed'
,
action
=
'store_true'
,
help
=
"Exit immediately after asking the registry CA. Status code is"
" non-zero if we're already part of the network, which means"
" re6st is already running or we're behind a re6st router."
)
_
(
'--ca-only'
,
action
=
'store_true'
,
help
=
'Only fetch CA from registry and exit.'
)
_
(
'-d'
,
'--dir'
,
...
...
@@ -46,8 +50,16 @@ def main():
s
=
xmlrpclib
.
ServerProxy
(
config
.
registry
,
allow_none
=
True
)
# Get CA
create
(
ca_path
,
s
.
getCa
())
ca
=
s
.
getCa
()
network
=
utils
.
networkFromCa
(
ca
)
if
config
.
is_needed
:
route
,
err
=
subprocess
.
Popen
((
'ip'
,
'-6'
,
'-o'
,
'route'
,
'get'
,
utils
.
ipFromBin
(
network
)),
stdout
=
subprocess
.
PIPE
).
communicate
()
sys
.
exit
(
err
or
route
and
utils
.
binFromIp
(
route
.
split
()[
8
]).
startswith
(
network
))
create
(
ca_path
,
ca
)
if
config
.
ca_only
:
sys
.
exit
()
...
...
@@ -145,8 +157,8 @@ dh %s
"""
%
(
config
.
registry
,
ca_path
,
cert_path
,
key_path
,
dh_path
))
print
"Sample configuration file created."
cn
=
utils
.
subnetFromCert
(
cert
_path
)
subnet
=
utils
.
networkFromCa
(
ca_path
)
+
utils
.
binFromSubnet
(
cn
)
cn
=
utils
.
subnetFromCert
(
cert
)
subnet
=
network
+
utils
.
binFromSubnet
(
cn
)
print
"Your subnet: %s/%u (CN=%s)"
\
%
(
utils
.
ipFromBin
(
subnet
),
len
(
subnet
),
cn
)
...
...
re6st/utils.py
View file @
00fbbfe9
...
...
@@ -127,17 +127,13 @@ def ipFromBin(ip, suffix=''):
return
socket
.
inet_ntop
(
socket
.
AF_INET6
,
struct
.
pack
(
'>QQ'
,
int
(
ip
[:
64
],
2
),
int
(
ip
[
64
:],
2
)))
def
networkFromCa
(
ca_path
):
# Get network prefix from ca.crt
with
open
(
ca_path
,
'r'
)
as
f
:
ca
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
f
.
read
())
return
bin
(
ca
.
get_serial_number
())[
3
:]
def
subnetFromCert
(
cert_path
):
# Get ip from cert.crt
with
open
(
cert_path
,
'r'
)
as
f
:
cert
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
f
.
read
())
return
cert
.
get_subject
().
CN
def
networkFromCa
(
ca
):
ca
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
ca
)
return
bin
(
ca
.
get_serial_number
())[
3
:]
def
subnetFromCert
(
cert
):
cert
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
cert
)
return
cert
.
get_subject
().
CN
def
dump_address
(
address
):
return
';'
.
join
(
map
(
','
.
join
,
address
))
...
...
re6stnet
View file @
00fbbfe9
...
...
@@ -111,8 +111,10 @@ def getConfig():
def
main
():
# Get arguments
config
=
getConfig
()
network
=
utils
.
networkFromCa
(
config
.
ca
)
prefix
=
utils
.
binFromSubnet
(
utils
.
subnetFromCert
(
config
.
cert
))
with
open
(
config
.
ca
)
as
f
:
network
=
utils
.
networkFromCa
(
f
.
read
())
with
open
(
config
.
cert
)
as
f
:
prefix
=
utils
.
binFromSubnet
(
utils
.
subnetFromCert
(
f
.
read
()))
config
.
openvpn_args
+=
(
'--ca'
,
config
.
ca
,
'--cert'
,
config
.
cert
,
...
...
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