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
03f01032
Commit
03f01032
authored
Apr 07, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disallow anonymous and email options
parent
43d4c9a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
61 deletions
+15
-61
re6st-conf
re6st-conf
+1
-15
re6st/registry.py
re6st/registry.py
+14
-46
No files found.
re6st-conf
View file @
03f01032
...
...
@@ -36,13 +36,7 @@ def main():
" which actually encodes your allocated prefix in the network."
" You can repeat this option to add any field you want to its"
" subject."
)
_
(
'--email'
,
help
=
"Email address where your token is sent. Use -r option if you"
" want to show an email in your certificate."
)
_
(
'--token'
,
help
=
"The token you received."
)
_
(
'--anonymous'
,
action
=
'store_true'
,
help
=
"Request an anonymous certificate. No email is required but the"
" registry may deliver a longer prefix."
)
config
=
parser
.
parse_args
()
if
config
.
dir
:
os
.
chdir
(
config
.
dir
)
...
...
@@ -103,15 +97,7 @@ def main():
cert_fd
=
token_advice
=
None
try
:
token
=
config
.
token
if
config
.
anonymous
:
if
not
(
token
is
config
.
email
is
None
):
parser
.
error
(
"--anonymous conflicts with --email/--token"
)
token
=
''
elif
not
token
:
if
not
config
.
email
:
config
.
email
=
raw_input
(
'Please enter your email address: '
)
s
.
requestToken
(
config
.
email
)
if
not
token
:
token_advice
=
"Use --token to retry without asking a new token
\
n
"
while
not
token
:
token
=
raw_input
(
'Please enter your token: '
)
...
...
re6st/registry.py
View file @
03f01032
...
...
@@ -290,38 +290,9 @@ class RegistryServer(object):
@
rpc
def
requestToken
(
self
,
email
):
with
self
.
lock
:
while
True
:
# Generating token
token
=
''
.
join
(
random
.
sample
(
string
.
ascii_lowercase
,
8
))
args
=
token
,
email
,
self
.
config
.
prefix_length
,
int
(
time
.
time
())
# Updating database
try
:
self
.
db
.
execute
(
"INSERT INTO token VALUES (?,?,?,?)"
,
args
)
break
except
sqlite3
.
IntegrityError
:
pass
self
.
timeout
=
1
# Creating and sending email
msg
=
MIMEText
(
'Hello, your token to join re6st network is: %s
\
n
'
%
token
)
msg
[
'Subject'
]
=
'[re6stnet] Token Request'
if
self
.
email
:
msg
[
'From'
]
=
self
.
email
msg
[
'To'
]
=
email
if
os
.
path
.
isabs
(
self
.
config
.
mailhost
)
or
\
os
.
path
.
isfile
(
self
.
config
.
mailhost
):
with
self
.
lock
:
m
=
mailbox
.
mbox
(
self
.
config
.
mailhost
)
try
:
m
.
add
(
msg
)
finally
:
m
.
close
()
else
:
s
=
smtplib
.
SMTP
(
self
.
config
.
mailhost
)
s
.
sendmail
(
self
.
email
,
email
,
msg
.
as_string
())
s
.
quit
()
logging
.
info
(
"This re6st version doesn't allow client to request token. Email is %s"
%
email
)
return
@
rpc
def
requestAddToken
(
self
,
token
,
email
):
...
...
@@ -381,20 +352,17 @@ class RegistryServer(object):
req
=
crypto
.
load_certificate_request
(
crypto
.
FILETYPE_PEM
,
req
)
with
self
.
lock
:
with
self
.
db
:
if
token
:
try
:
token
,
email
,
prefix_len
,
_
=
self
.
db
.
execute
(
"SELECT * FROM token WHERE token = ?"
,
(
token
,)).
next
()
except
StopIteration
:
return
self
.
db
.
execute
(
"DELETE FROM token WHERE token = ?"
,
(
token
,))
else
:
prefix_len
=
self
.
config
.
anonymous_prefix_length
if
not
prefix_len
:
return
email
=
None
try
:
token
,
email
,
prefix_len
,
_
=
self
.
db
.
execute
(
"SELECT * FROM token WHERE token = ?"
,
(
token
,)).
next
()
except
StopIteration
:
return
if
not
token
:
logging
.
info
(
"Empty token is not allowed for this re6st version."
)
return
self
.
db
.
execute
(
"DELETE FROM token WHERE token = ?"
,
(
token
,))
prefix
=
self
.
newPrefix
(
prefix_len
)
self
.
db
.
execute
(
"UPDATE cert SET email = ? WHERE prefix = ?"
,
(
email
,
prefix
))
...
...
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