mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-02 06:26:10 -04:00
Merge branch 'develop' into censorship
This commit is contained in:
commit
2da1174408
781 changed files with 7753 additions and 3930 deletions
82
desktop/scripts/bridges/__init__.py
Normal file
82
desktop/scripts/bridges/__init__.py
Normal file
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
OnionShare | https://onionshare.org/
|
||||
|
||||
Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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 os
|
||||
import requests
|
||||
|
||||
|
||||
class UpdateTorBridges:
|
||||
"""
|
||||
Update the built-in Tor Bridges in OnionShare's torrc templates.
|
||||
"""
|
||||
|
||||
def __init__(self, root_path):
|
||||
self.root_path = root_path
|
||||
torrc_template_dir = os.path.join(
|
||||
self.root_path, os.pardir, "cli/onionshare_cli/resources"
|
||||
)
|
||||
endpoint = "https://bridges.torproject.org/moat/circumvention/builtin"
|
||||
r = requests.post(
|
||||
endpoint,
|
||||
headers={"Content-Type": "application/vnd.api+json"},
|
||||
)
|
||||
if r.status_code != 200:
|
||||
print(
|
||||
f"There was a problem fetching the latest built-in bridges: status_code={r.status_code}"
|
||||
)
|
||||
return False
|
||||
|
||||
result = r.json()
|
||||
|
||||
if "errors" in result:
|
||||
print(
|
||||
f"There was a problem fetching the latest built-in bridges: errors={result['errors']}"
|
||||
)
|
||||
return False
|
||||
|
||||
for bridge_type in ["meek", "obfs4", "snowflake"]:
|
||||
if result[bridge_type]:
|
||||
if bridge_type == "meek":
|
||||
torrc_template_extension = "meek_lite_azure"
|
||||
else:
|
||||
torrc_template_extension = bridge_type
|
||||
torrc_template = os.path.join(
|
||||
self.root_path,
|
||||
torrc_template_dir,
|
||||
f"torrc_template-{torrc_template_extension}",
|
||||
)
|
||||
|
||||
with open(torrc_template, "w") as f:
|
||||
f.write(f"# Enable built-in {bridge_type} bridge\n")
|
||||
bridges = result[bridge_type]
|
||||
# Sorts the bridges numerically by IP, since they come back in
|
||||
# random order from the API each time, and create noisy git diff.
|
||||
bridges.sort(key=lambda s: s.split()[1])
|
||||
for item in bridges:
|
||||
if bridge_type == "meek":
|
||||
# obfs4proxy expects the bridge type to be meek_lite, and the url/front params
|
||||
# are missing in the Tor API response, so we have to add them in ourselves.
|
||||
bridge = item.replace("meek", "meek_lite")
|
||||
f.write(
|
||||
f"Bridge {bridge} url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com\n"
|
||||
)
|
||||
else:
|
||||
f.write(f"Bridge {item}\n")
|
|
@ -3,7 +3,7 @@
|
|||
"""
|
||||
OnionShare | https://onionshare.org/
|
||||
|
||||
Copyright (C) 2014-2021 Micah Lee, et al. <micah@micahflee.com>
|
||||
Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -48,10 +48,10 @@ def main():
|
|||
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
)
|
||||
if platform.system() == "Windows":
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor", "Tor")
|
||||
dist_path = os.path.join(root_path, "onionshare", "resources", "tor", "Tor")
|
||||
bin_filename = "meek-client.exe"
|
||||
else:
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
|
||||
dist_path = os.path.join(root_path, "onionshare", "resources", "tor")
|
||||
bin_filename = "meek-client"
|
||||
|
||||
bin_path = os.path.join(os.path.expanduser("~"), "go", "bin", bin_filename)
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Check translation lacked or disused.
|
||||
|
||||
Example:
|
||||
in OnionShare directory
|
||||
$ check_lacked_trans.py
|
||||
de disused choose_file
|
||||
de disused gui_starting_server
|
||||
de lacked gui_canceled
|
||||
de lacked gui_starting_server1
|
||||
de lacked gui_starting_server2
|
||||
de lacked gui_starting_server3
|
||||
en disused choose_file
|
||||
es disused choose_file
|
||||
es disused gui_starting_server
|
||||
...
|
||||
|
||||
|
||||
1. search `{{strings.translation_key}}` and `strings._('translation_key')`
|
||||
from .py or .html files.
|
||||
2. load translation key from locale/*.json.
|
||||
3. compare these.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import os
|
||||
import codecs
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def arg_parser():
|
||||
desc = __doc__.strip().splitlines()[0]
|
||||
p = argparse.ArgumentParser(description=desc)
|
||||
p.add_argument(
|
||||
"-d",
|
||||
default=".",
|
||||
help="onionshare directory",
|
||||
metavar="ONIONSHARE_DIR",
|
||||
dest="onionshare_dir",
|
||||
)
|
||||
p.add_argument(
|
||||
"--show-all-keys",
|
||||
action="store_true",
|
||||
help="show translation key in source and exit",
|
||||
),
|
||||
p.add_argument(
|
||||
"-l",
|
||||
default="all",
|
||||
help="language code (default: all)",
|
||||
metavar="LANG_CODE",
|
||||
dest="lang_code",
|
||||
)
|
||||
return p
|
||||
|
||||
|
||||
def files_in(*dirs):
|
||||
dir = os.path.join(*dirs)
|
||||
files = os.listdir(dir)
|
||||
return [os.path.join(dir, f) for f in files]
|
||||
|
||||
|
||||
def main():
|
||||
parser = arg_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
dir = args.onionshare_dir
|
||||
|
||||
src = (
|
||||
files_in(dir, "onionshare_gui")
|
||||
+ files_in(dir, "onionshare_gui/tab")
|
||||
+ files_in(dir, "onionshare_gui/tab/mode")
|
||||
+ files_in(dir, "onionshare_gui/tab/mode/chat_mode")
|
||||
+ files_in(dir, "onionshare_gui/tab/mode/receive_mode")
|
||||
+ files_in(dir, "onionshare_gui/tab/mode/share_mode")
|
||||
+ files_in(dir, "onionshare_gui/tab/mode/website_mode")
|
||||
+ files_in(dir, "install/scripts")
|
||||
)
|
||||
filenames = [p for p in src if p.endswith(".py")]
|
||||
|
||||
lang_code = args.lang_code
|
||||
|
||||
translate_keys = set()
|
||||
for filename in filenames:
|
||||
# load translate key from python source
|
||||
with open(filename) as f:
|
||||
src = f.read()
|
||||
|
||||
# find all the starting strings
|
||||
start_substr = "strings._\("
|
||||
starting_indices = [m.start() for m in re.finditer(start_substr, src)]
|
||||
|
||||
for starting_i in starting_indices:
|
||||
# are we dealing with single quotes or double quotes?
|
||||
quote = None
|
||||
inc = 0
|
||||
while True:
|
||||
quote_i = starting_i + len("strings._(") + inc
|
||||
if src[quote_i] == '"':
|
||||
quote = '"'
|
||||
break
|
||||
if src[quote_i] == "'":
|
||||
quote = "'"
|
||||
break
|
||||
inc += 1
|
||||
|
||||
# find the starting quote
|
||||
starting_i = src.find(quote, starting_i)
|
||||
if starting_i:
|
||||
starting_i += 1
|
||||
# find the ending quote
|
||||
ending_i = src.find(quote, starting_i)
|
||||
if ending_i:
|
||||
key = src[starting_i:ending_i]
|
||||
translate_keys.add(key)
|
||||
|
||||
if args.show_all_keys:
|
||||
for k in sorted(translate_keys):
|
||||
print(k)
|
||||
sys.exit()
|
||||
|
||||
if lang_code == "all":
|
||||
locale_files = [f for f in files_in(dir, "share/locale") if f.endswith(".json")]
|
||||
else:
|
||||
locale_files = [
|
||||
f
|
||||
for f in files_in(dir, "share/locale")
|
||||
if f.endswith("%s.json" % lang_code)
|
||||
]
|
||||
for locale_file in locale_files:
|
||||
with codecs.open(locale_file, "r", encoding="utf-8") as f:
|
||||
trans = json.load(f)
|
||||
# trans -> {"key1": "translate-text1", "key2": "translate-text2", ...}
|
||||
locale_keys = set(trans.keys())
|
||||
|
||||
disused = locale_keys - translate_keys
|
||||
lacked = translate_keys - locale_keys
|
||||
|
||||
locale, ext = os.path.splitext(os.path.basename(locale_file))
|
||||
for k in sorted(disused):
|
||||
print(locale, "disused", k)
|
||||
|
||||
for k in sorted(lacked):
|
||||
print(locale, "lacked", k)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,3 +0,0 @@
|
|||
cd src
|
||||
python -c "import onionshare; onionshare.main()" %*
|
||||
cd ..
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run OnionShare desktop, allowing you to use command-line arguments
|
||||
|
||||
SCRIPTS_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )
|
||||
cd "$SCRIPTS_DIR"
|
||||
|
||||
cd ../src
|
||||
python -c "import onionshare; onionshare.main()" $@
|
|
@ -3,7 +3,7 @@
|
|||
"""
|
||||
OnionShare | https://onionshare.org/
|
||||
|
||||
Copyright (C) 2014-2021 Micah Lee, et al. <micah@micahflee.com>
|
||||
Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -31,13 +31,14 @@ import hashlib
|
|||
import shutil
|
||||
import subprocess
|
||||
import requests
|
||||
from bridges import UpdateTorBridges
|
||||
|
||||
|
||||
def main():
|
||||
tarball_url = "https://dist.torproject.org/torbrowser/11.0a10/tor-browser-linux64-11.0a10_en-US.tar.xz"
|
||||
tarball_filename = "tor-browser-linux64-11.0a10_en-US.tar.xz"
|
||||
tarball_url = "https://dist.torproject.org/torbrowser/11.0.4/tor-browser-linux64-11.0.4_en-US.tar.xz"
|
||||
tarball_filename = "tor-browser-linux64-11.0.4_en-US.tar.xz"
|
||||
expected_tarball_sha256 = (
|
||||
"5d3e2ebc4fb6a10f44624359bc2a5a151a57e8402cbd8563d15f9b2524374f1f"
|
||||
"05a5fd6d633ca84c33bbd3e2f8ffca2d2fa2105032a430b07d3c0cf062d9e15f"
|
||||
)
|
||||
|
||||
# Build paths
|
||||
|
@ -46,7 +47,7 @@ def main():
|
|||
)
|
||||
working_path = os.path.join(root_path, "build", "tor")
|
||||
tarball_path = os.path.join(working_path, tarball_filename)
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
|
||||
dist_path = os.path.join(root_path, "onionshare", "resources", "tor")
|
||||
|
||||
# Make sure dirs exist
|
||||
if not os.path.exists(working_path):
|
||||
|
@ -126,6 +127,9 @@ def main():
|
|||
|
||||
print(f"Tor binaries extracted to: {dist_path}")
|
||||
|
||||
# Fetch the built-in bridges
|
||||
UpdateTorBridges(root_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"""
|
||||
OnionShare | https://onionshare.org/
|
||||
|
||||
Copyright (C) 2014-2021 Micah Lee, et al. <micah@micahflee.com>
|
||||
Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,12 +32,14 @@ import shutil
|
|||
import subprocess
|
||||
import requests
|
||||
|
||||
from bridges import UpdateTorBridges
|
||||
|
||||
|
||||
def main():
|
||||
dmg_url = "https://dist.torproject.org/torbrowser/11.0a10/TorBrowser-11.0a10-osx64_en-US.dmg"
|
||||
dmg_filename = "TorBrowser-11.0a10-osx64_en-US.dmg"
|
||||
dmg_url = "https://dist.torproject.org/torbrowser/11.0.4/TorBrowser-11.0.4-osx64_en-US.dmg"
|
||||
dmg_filename = "TorBrowser-11.0.4-osx64_en-US.dmg"
|
||||
expected_dmg_sha256 = (
|
||||
"c6823a28fd28205437564815f93011ff93b7972da2a8ce16919adfc65909e7b9"
|
||||
"309a67c8a82ae266756d7cf5ea00e94d9242e59d55eaff97dcd6201da3c8449c"
|
||||
)
|
||||
|
||||
# Build paths
|
||||
|
@ -49,7 +51,7 @@ def main():
|
|||
"/Volumes", "Tor Browser", "Tor Browser.app", "Contents"
|
||||
)
|
||||
dmg_path = os.path.join(working_path, dmg_filename)
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
|
||||
dist_path = os.path.join(root_path, "onionshare", "resources", "tor")
|
||||
if not os.path.exists(dist_path):
|
||||
os.makedirs(dist_path, exist_ok=True)
|
||||
|
||||
|
@ -113,6 +115,9 @@ def main():
|
|||
# Eject dmg
|
||||
subprocess.call(["diskutil", "eject", "/Volumes/Tor Browser"])
|
||||
|
||||
# Fetch the built-in bridges
|
||||
UpdateTorBridges(root_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"""
|
||||
OnionShare | https://onionshare.org/
|
||||
|
||||
Copyright (C) 2014-2021 Micah Lee, et al. <micah@micahflee.com>
|
||||
Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -31,12 +31,14 @@ import shutil
|
|||
import subprocess
|
||||
import requests
|
||||
|
||||
from bridges import UpdateTorBridges
|
||||
|
||||
|
||||
def main():
|
||||
exe_url = "https://dist.torproject.org/torbrowser/11.0a10/torbrowser-install-11.0a10_en-US.exe"
|
||||
exe_filename = "torbrowser-install-11.0a10_en-US.exe"
|
||||
exe_url = "https://dist.torproject.org/torbrowser/11.0.4/torbrowser-install-11.0.4_en-US.exe"
|
||||
exe_filename = "torbrowser-install-11.0.4_en-US.exe"
|
||||
expected_exe_sha256 = (
|
||||
"f567dd8368dea0a8d7bbf7c19ece7840f93d493e70662939b92f5058c8dc8d2d"
|
||||
"c7073f58f49a225bcf7668a5630e94f5f5e96fb7bed095feebf3bf8417bd3d07"
|
||||
)
|
||||
# Build paths
|
||||
root_path = os.path.dirname(
|
||||
|
@ -44,7 +46,7 @@ def main():
|
|||
)
|
||||
working_path = os.path.join(root_path, "build", "tor")
|
||||
exe_path = os.path.join(working_path, exe_filename)
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
|
||||
dist_path = os.path.join(root_path, "onionshare", "resources", "tor")
|
||||
|
||||
# Make sure the working folder exists
|
||||
if not os.path.exists(working_path):
|
||||
|
@ -98,6 +100,9 @@ def main():
|
|||
os.path.join(working_path, "Data"), os.path.join(dist_path, "Data", "Tor")
|
||||
)
|
||||
|
||||
# Fetch the built-in bridges
|
||||
UpdateTorBridges(root_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
This script builds the CLI python wheel, copies it to the desktop folder,
|
||||
and installs it in the virtual environment.
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import glob
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
|
||||
def main():
|
||||
# Build paths
|
||||
root_path = os.path.dirname(
|
||||
os.path.dirname(
|
||||
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
)
|
||||
)
|
||||
cli_path = os.path.join(root_path, "cli")
|
||||
desktop_path = os.path.join(root_path, "desktop")
|
||||
|
||||
# Delete old wheels
|
||||
for filename in glob.glob(os.path.join(cli_path, "dist", "*.whl")):
|
||||
os.remove(filename)
|
||||
|
||||
# Build new wheel
|
||||
subprocess.call(["poetry", "install"], cwd=cli_path)
|
||||
subprocess.call(["poetry", "build"], cwd=cli_path)
|
||||
wheel_filename = glob.glob(os.path.join(cli_path, "dist", "*.whl"))[0]
|
||||
wheel_basename = os.path.basename(wheel_filename)
|
||||
shutil.copyfile(
|
||||
wheel_filename,
|
||||
os.path.join(desktop_path, wheel_basename),
|
||||
)
|
||||
|
||||
# Reinstall the new wheel
|
||||
subprocess.call(["pip", "uninstall", "onionshare-cli", "-y"])
|
||||
subprocess.call(["pip", "install", os.path.join(desktop_path, wheel_basename)])
|
||||
subprocess.call(["pip", "install", "typing-extensions"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue