[Pkg-privacy-commits] [onionshare] 54/66: Replace onionshare slug with 2-words from securedrop diceware list (#238)
Ulrike Uhlig
u-guest at moszumanska.debian.org
Wed Apr 13 22:17:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository onionshare.
commit b47ef630d58a83992caba7d19f6aa6fbba352080
Author: Micah Lee <micah at micahflee.com>
Date: Tue Apr 12 16:29:05 2016 -0700
Replace onionshare slug with 2-words from securedrop diceware list (#238)
---
onionshare/helpers.py | 14 ++++++++++++++
onionshare/onionshare.py | 3 +++
onionshare/web.py | 2 +-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index c6d29f0..ae58488 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import sys, os, inspect, hashlib, base64, hmac, platform, zipfile, tempfile, math, time
+from random import SystemRandom
def get_platform():
@@ -26,6 +27,7 @@ def get_platform():
"""
return platform.system()
+
def get_resource_path(filename):
"""
Returns the absolute path of a resource, regardless of whether OnionShare is installed
@@ -49,6 +51,7 @@ def get_resource_path(filename):
return os.path.join(resources_dir, filename)
+
def get_version():
"""
Returns the version of OnionShare that is running.
@@ -88,6 +91,17 @@ def random_string(num_bytes, output_len=None):
return s[:output_len]
+def build_slug():
+ """
+ Returns a random string made from two words from the wordlist, such as "deter-trig".
+ """
+ wordlist = open(get_resource_path('wordlist.txt')).read().split('\n')
+ wordlist.remove('')
+
+ r = SystemRandom()
+ return '-'.join(r.choice(wordlist) for x in range(2))
+
+
def human_readable_filesize(b):
"""
Returns filesize in a human readable format.
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index 34e64b0..0ccf394 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -169,6 +169,9 @@ def main(cwd=None):
ready = app.hs.wait_for_hs(app.onion_host)
if not ready:
sys.exit()
+ else:
+ # Wait for web.generate_slug() to finish running
+ time.sleep(0.2)
print(strings._("give_this_url"))
print('http://{0:s}/{1:s}'.format(app.onion_host, web.slug))
diff --git a/onionshare/web.py b/onionshare/web.py
index e1f8050..ebff67b 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -92,7 +92,7 @@ def add_request(request_type, path, data=None):
slug = None
def generate_slug():
global slug
- slug = helpers.random_string(16)
+ slug = helpers.build_slug()
download_count = 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git
More information about the Pkg-privacy-commits
mailing list