diff --git a/cli/onionshare_cli/resources/torrc_template-meek_lite_azure b/cli/onionshare_cli/resources/torrc_template-meek_lite_azure index e3140fe3..73ad5042 100644 --- a/cli/onionshare_cli/resources/torrc_template-meek_lite_azure +++ b/cli/onionshare_cli/resources/torrc_template-meek_lite_azure @@ -1,2 +1,2 @@ -# Enable built-in meek_lite bridge +# Enable built-in meek-azure bridge Bridge meek_lite 192.0.2.2:2 97700DFE9F483596DDA6264C4D7DF7641E1E39CE url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com diff --git a/cli/onionshare_cli/resources/torrc_template-obfs4 b/cli/onionshare_cli/resources/torrc_template-obfs4 index cd5437b6..c6091b87 100644 --- a/cli/onionshare_cli/resources/torrc_template-obfs4 +++ b/cli/onionshare_cli/resources/torrc_template-obfs4 @@ -1,5 +1,4 @@ # Enable built-in obfs4 bridge -Bridge obfs4 144.217.20.138:80 FB70B257C162BF1038CA669D568D76F5B7F0BABB cert=vYIV5MgrghGQvZPIi1tJwnzorMgqgmlKaB77Y3Z9Q/v94wZBOAXkW+fdx4aSxLVnKO+xNw iat-mode=0 Bridge obfs4 146.57.248.225:22 10A6CD36A537FCE513A322361547444B393989F0 cert=K1gDtDAIcUfeLqbstggjIw2rtgIKqdIhUlHp82XRqNSq/mtAjp1BIC9vHKJ2FAEpGssTPw iat-mode=0 Bridge obfs4 192.95.36.142:443 CDF2E852BF539B82BD10E27E9115A31734E378C2 cert=qUVQ0srL1JI/vO6V6m/24anYXiJD3QP2HgzUKQtQ7GRqqUvs7P+tG43RtAqdhLOALP7DJQ iat-mode=1 Bridge obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0 @@ -8,6 +7,7 @@ Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert= Bridge obfs4 209.148.46.65:443 74FAD13168806246602538555B5521A0383A1875 cert=ssH+9rP8dG2NLDN2XuFw63hIO/9MNNinLmxQDpVa+7kTOa9/m+tGWT1SmSYpQ9uTBGa6Hw iat-mode=0 Bridge obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0 Bridge obfs4 38.229.1.78:80 C8CBDB2464FC9804A69531437BCF2BE31FDD2EE4 cert=Hmyfd2ev46gGY7NoVxA9ngrPF2zCZtzskRTzoWXbxNkzeVnGFPWmrTtILRyqCTjHR+s9dg iat-mode=1 +Bridge obfs4 38.229.33.83:80 0BAC39417268B96B9F514E7F63FA6FBA1A788955 cert=VwEFpk9F/UN9JED7XpG1XOjm/O8ZCXK80oPecgWnNDZDv5pdkhq1OpbAH0wNqOT6H6BmRQ iat-mode=1 Bridge obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0 Bridge obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0 Bridge obfs4 85.31.186.26:443 91A6354697E6B02A386312F68D82CF86824D3606 cert=PBwr+S8JTVZo6MPdHnkTwXJPILWADLqfMGoVvhZClMq/Urndyd42BwX9YFJHZnBB3H0XCw iat-mode=0 diff --git a/desktop/scripts/get-tor.py b/desktop/scripts/get-tor.py index 3e6dc053..0f67fde8 100644 --- a/desktop/scripts/get-tor.py +++ b/desktop/scripts/get-tor.py @@ -286,46 +286,46 @@ def update_tor_bridges(): torrc_template_dir = os.path.join( root_path, os.pardir, "cli/onionshare_cli/resources" ) - - r = requests.get("https://gitweb.torproject.org/builders/tor-browser-build.git/plain/projects/tor-browser/Bundle-Data/PTConfigs/bridge_prefs.js") + 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 - - # Parse the bridges from this javascript file - bridges = {} - for line in r.content.decode().split("\n"): - if line.startswith('pref("extensions.torlauncher.default_bridge.'): - i = line.index('", "') + 4 - bridge = line[i:].rstrip('");') - bridge_type = bridge.split()[0] - if bridge_type not in bridges: - bridges[bridge_type] = [] + result = r.json() + print(f"Built-in bridges: {result}") - bridges[bridge_type].append(bridge) - - for bridge_type in bridges: - if bridge_type == "meek_lite": - torrc_template_extension = "meek_lite_azure" - else: - torrc_template_extension = bridge_type - - torrc_template = os.path.join( - root_path, - torrc_template_dir, - f"torrc_template-{torrc_template_extension}", + if "errors" in result: + print( + f"There was a problem fetching the latest built-in bridges: errors={result['errors']}" ) + return False - with open(torrc_template, "w") as f: - f.write(f"# Enable built-in {bridge_type} bridge\n") - # Sorts the bridges numerically by IP, since they come back in - # random order from the API each time, and create noisy git diff. - bridges[bridge_type].sort(key=lambda s: s.split()[1]) - for item in bridges[bridge_type]: - f.write(f"Bridge {item}\n") + for bridge_type in ["meek-azure", "obfs4", "snowflake"]: + if bridge_type in result and result[bridge_type]: + if bridge_type == "meek-azure": + torrc_template_extension = "meek_lite_azure" + else: + torrc_template_extension = bridge_type + torrc_template = os.path.join( + 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: + f.write(f"Bridge {item}\n") @click.command()