mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Reverted to using homebrew's tor
This commit is contained in:
parent
8427252fb8
commit
1f34e8bbee
@ -19,9 +19,6 @@ expected_win64_sha256 = (
|
|||||||
expected_macos_sha256 = (
|
expected_macos_sha256 = (
|
||||||
"b80d3dba83b343fab7a6c8fc08440b2751da1ac12f86fe593da8e74069e4d7f6"
|
"b80d3dba83b343fab7a6c8fc08440b2751da1ac12f86fe593da8e74069e4d7f6"
|
||||||
)
|
)
|
||||||
expected_macos_aarch64_sha256 = (
|
|
||||||
"0ff0badfaab6ec797b80998c933205f5d1083828ff08bf190780c16ab71a76bf"
|
|
||||||
)
|
|
||||||
expected_linux64_sha256 = (
|
expected_linux64_sha256 = (
|
||||||
"90cdce3854e9114ee7232aaa74672a2d9f3a40b6fa8ac33971f586ee3a3cf75a"
|
"90cdce3854e9114ee7232aaa74672a2d9f3a40b6fa8ac33971f586ee3a3cf75a"
|
||||||
)
|
)
|
||||||
@ -32,8 +29,6 @@ win64_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/torbro
|
|||||||
win64_filename = f"torbrowser-install-win64-{torbrowser_version}_en-US.exe"
|
win64_filename = f"torbrowser-install-win64-{torbrowser_version}_en-US.exe"
|
||||||
macos_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/TorBrowser-{torbrowser_version}-osx64_en-US.dmg"
|
macos_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/TorBrowser-{torbrowser_version}-osx64_en-US.dmg"
|
||||||
macos_filename = f"TorBrowser-{torbrowser_version}-osx64_en-US.dmg"
|
macos_filename = f"TorBrowser-{torbrowser_version}-osx64_en-US.dmg"
|
||||||
macos_aarch64_url = f"https://www.torproject.org/dist/torbrowser/12.0a4/TorBrowser-12.0a4-osx64_ALL.dmg"
|
|
||||||
macos_aarch64_filename = f"TorBrowser-12.0a4-osx64_ALL.dmg"
|
|
||||||
linux64_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/tor-browser-linux64-{torbrowser_version}_en-US.tar.xz"
|
linux64_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/tor-browser-linux64-{torbrowser_version}_en-US.tar.xz"
|
||||||
linux64_filename = f"tor-browser-linux64-{torbrowser_version}_en-US.tar.xz"
|
linux64_filename = f"tor-browser-linux64-{torbrowser_version}_en-US.tar.xz"
|
||||||
|
|
||||||
@ -210,64 +205,90 @@ def get_tor_macos_x86_64():
|
|||||||
|
|
||||||
|
|
||||||
def get_tor_macos_aarch64():
|
def get_tor_macos_aarch64():
|
||||||
|
# Versions and shasums
|
||||||
|
torbin_version = "0.4.7.10"
|
||||||
|
libevent_version = "2.1.12"
|
||||||
|
expected_torbin_sha256 = "01abf45e673649f6c0fee07f1fcffcce82b2bdb5f5db0c15a9cdcfda6e5eb187"
|
||||||
|
expected_geoip_sha256 = "7e777efc194ea9788171636085b19875d19397d3249fbb88136534037a3dc38f"
|
||||||
|
expected_geoip6_sha256 = "f11bd1d7546cad00b6db0a1594f3ac1daf9f541004fd7efb5414e068693d6add"
|
||||||
|
expected_libevent_sha256 = "2de95fd8cf8849028f9146f04cbde8cc7399ba0191b65ab92825a9a5e691a464"
|
||||||
|
|
||||||
# Build paths
|
# Build paths
|
||||||
dmg_tor_path = os.path.join(
|
|
||||||
"/Volumes", "Tor Browser", "Tor Browser.app", "Contents"
|
|
||||||
)
|
|
||||||
dmg_path = os.path.join(working_path, macos_aarch64_filename)
|
|
||||||
dist_path = os.path.join(root_path, "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)
|
|
||||||
|
|
||||||
# Make sure the working folder exists
|
# Make sure homebrew is installed and in path
|
||||||
if not os.path.exists(working_path):
|
brew_path = shutil.which("brew")
|
||||||
os.makedirs(working_path)
|
if brew_path is None:
|
||||||
|
print("brew not found in path. Homebrew must be installed")
|
||||||
|
sys.exit(-1)
|
||||||
|
brew_prefix = os.path.dirname(os.path.dirname(brew_path))
|
||||||
|
|
||||||
# Make sure the zip is downloaded
|
# Check that tor is installed, otherwise install it
|
||||||
if not os.path.exists(dmg_path):
|
tor_path = os.path.join(brew_prefix, "Cellar", "tor", torbin_version)
|
||||||
print("Downloading {}".format(macos_aarch64_url))
|
libevent_path = os.path.join(brew_prefix, "Cellar", "libevent", libevent_version)
|
||||||
r = requests.get(macos_aarch64_url)
|
torbin_path = os.path.join(tor_path, "bin", "tor")
|
||||||
open(dmg_path, "wb").write(r.content)
|
if not os.path.exists(torbin_path):
|
||||||
dmg_sha256 = hashlib.sha256(r.content).hexdigest()
|
print(f"Installing tor v{torbin_version}...")
|
||||||
else:
|
if subprocess.call([os.path.join(brew_path), "install", "tor"]) != 0:
|
||||||
dmg_data = open(dmg_path, "rb").read()
|
print(f"Could not install tor using homebrew")
|
||||||
dmg_sha256 = hashlib.sha256(dmg_data).hexdigest()
|
|
||||||
|
|
||||||
# Compare the hash
|
|
||||||
if dmg_sha256 != expected_macos_aarch64_sha256:
|
|
||||||
print("ERROR! The sha256 doesn't match:")
|
|
||||||
print("expected: {}".format(expected_macos_aarch64_sha256))
|
|
||||||
print(" actual: {}".format(dmg_sha256))
|
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# Mount the dmg, copy data to the working path
|
# Compute the hashes
|
||||||
subprocess.call(["hdiutil", "attach", dmg_path])
|
torbin_data = open(torbin_path, "rb").read()
|
||||||
|
torbin_sha256 = hashlib.sha256(torbin_data).hexdigest()
|
||||||
|
geoip_data = open(
|
||||||
|
os.path.join(tor_path, "share", "tor", "geoip"),
|
||||||
|
"rb").read()
|
||||||
|
geoip_sha256 = hashlib.sha256(geoip_data).hexdigest()
|
||||||
|
geoip6_data = open(
|
||||||
|
os.path.join(tor_path, "share", "tor", "geoip6"),
|
||||||
|
"rb").read()
|
||||||
|
geoip6_sha256 = hashlib.sha256(geoip6_data).hexdigest()
|
||||||
|
libeventlib_path = os.path.join(libevent_path, "lib", "libevent-2.1.7.dylib")
|
||||||
|
libevent_data = open(libeventlib_path, "rb").read()
|
||||||
|
libevent_sha256 = hashlib.sha256(libevent_data).hexdigest()
|
||||||
|
|
||||||
|
# Compare the hashes
|
||||||
|
if torbin_sha256 != expected_torbin_sha256:
|
||||||
|
print("ERROR! The sha256 doesn't match (tor):")
|
||||||
|
print("expected: {}".format(expected_torbin_sha256))
|
||||||
|
print(" actual: {}".format(torbin_sha256))
|
||||||
|
sys.exit(-1)
|
||||||
|
if geoip_sha256 != expected_geoip_sha256:
|
||||||
|
print("ERROR! The sha256 doesn't match (geoip):")
|
||||||
|
print("expected: {}".format(expected_geoip_sha256))
|
||||||
|
print(" actual: {}".format(geoip_sha256))
|
||||||
|
sys.exit(-1)
|
||||||
|
if geoip6_sha256 != expected_geoip6_sha256:
|
||||||
|
print("ERROR! The sha256 doesn't match (geoip6):")
|
||||||
|
print("expected: {}".format(expected_geoip6_sha256))
|
||||||
|
print(" actual: {}".format(geoip6_sha256))
|
||||||
|
sys.exit(-1)
|
||||||
|
if libevent_sha256 != expected_libevent_sha256:
|
||||||
|
print("ERROR! The sha256 doesn't match (libevent):")
|
||||||
|
print("expected: {}".format(expected_libevent_sha256))
|
||||||
|
print(" actual: {}".format(libevent_sha256))
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
# Copy into dist
|
# Copy into dist
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip"),
|
os.path.join(tor_path, "share", "tor", "geoip"),
|
||||||
os.path.join(dist_path, "geoip"),
|
os.path.join(dist_path, "geoip"),
|
||||||
)
|
)
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip6"),
|
os.path.join(tor_path, "share", "tor", "geoip6"),
|
||||||
os.path.join(dist_path, "geoip6"),
|
os.path.join(dist_path, "geoip6"),
|
||||||
)
|
)
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "MacOS", "Tor", "tor.real"),
|
torbin_path,
|
||||||
os.path.join(dist_path, "tor"),
|
os.path.join(dist_path, "tor"),
|
||||||
)
|
)
|
||||||
os.chmod(os.path.join(dist_path, "tor"), 0o755)
|
os.chmod(os.path.join(dist_path, "tor"), 0o755)
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "MacOS", "Tor", "libevent-2.1.7.dylib"),
|
libeventlib_path,
|
||||||
os.path.join(dist_path, "libevent-2.1.7.dylib"),
|
os.path.join(dist_path, "libevent-2.1.7.dylib"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Eject dmg
|
|
||||||
subprocess.call(["diskutil", "eject", "/Volumes/Tor Browser"])
|
|
||||||
|
|
||||||
# Fetch the built-in bridges
|
|
||||||
update_tor_bridges()
|
|
||||||
|
|
||||||
|
|
||||||
def get_tor_linux64():
|
def get_tor_linux64():
|
||||||
# Build paths
|
# Build paths
|
||||||
|
Loading…
Reference in New Issue
Block a user