mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-28 08:49:30 -05:00
Replace onionshare slug with 2-words from securedrop diceware list (#238)
This commit is contained in:
parent
3d07fccc11
commit
b47ef630d5
@ -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.
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user