mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 03:37:28 -03:00
Update bridge related settings in Settings, and use those new settings in Onion
This commit is contained in:
parent
54f4f2a53f
commit
2b3b6d7635
3 changed files with 46 additions and 50 deletions
|
@ -319,40 +319,39 @@ class Onion(object):
|
|||
f.write(torrc_template)
|
||||
|
||||
# Bridge support
|
||||
if self.settings.get("tor_bridges_use_obfs4"):
|
||||
with open(
|
||||
self.common.get_resource_path("torrc_template-obfs4")
|
||||
) as o:
|
||||
for line in o:
|
||||
f.write(line)
|
||||
elif self.settings.get("tor_bridges_use_meek_lite_azure"):
|
||||
with open(
|
||||
self.common.get_resource_path("torrc_template-meek_lite_azure")
|
||||
) as o:
|
||||
for line in o:
|
||||
f.write(line)
|
||||
elif self.settings.get("tor_bridges_use_snowflake"):
|
||||
with open(
|
||||
self.common.get_resource_path("torrc_template-snowflake")
|
||||
) as o:
|
||||
for line in o:
|
||||
f.write(line)
|
||||
if self.settings.get("bridges_enabled"):
|
||||
if self.settings.get("bridges_type") == "built-in":
|
||||
if self.settings.get("bridges_builtin_pt") == "obfs4":
|
||||
with open(
|
||||
self.common.get_resource_path("torrc_template-obfs4")
|
||||
) as o:
|
||||
f.write(o.read())
|
||||
elif self.settings.get("bridges_builtin_pt") == "meek-azure":
|
||||
with open(
|
||||
self.common.get_resource_path(
|
||||
"torrc_template-meek_lite_azure"
|
||||
)
|
||||
) as o:
|
||||
f.write(o.read())
|
||||
elif self.settings.get("bridges_builtin_pt") == "snowflake":
|
||||
with open(
|
||||
self.common.get_resource_path(
|
||||
"torrc_template-snowflake"
|
||||
)
|
||||
) as o:
|
||||
f.write(o.read())
|
||||
|
||||
elif self.settings.get("tor_bridges_use_moat"):
|
||||
for line in self.settings.get("tor_bridges_use_moat_bridges").split(
|
||||
"\n"
|
||||
):
|
||||
if line.strip() != "":
|
||||
f.write(f"Bridge {line}\n")
|
||||
f.write("\nUseBridges 1\n")
|
||||
elif self.settings.get("bridges_type") == "moat":
|
||||
for line in self.settings.get("bridges_moat").split("\n"):
|
||||
if line.strip() != "":
|
||||
f.write(f"Bridge {line}\n")
|
||||
f.write("\nUseBridges 1\n")
|
||||
|
||||
elif self.settings.get("tor_bridges_use_custom_bridges"):
|
||||
for line in self.settings.get(
|
||||
"tor_bridges_use_custom_bridges"
|
||||
).split("\n"):
|
||||
if line.strip() != "":
|
||||
f.write(f"Bridge {line}\n")
|
||||
f.write("\nUseBridges 1\n")
|
||||
elif self.settings.get("bridges_type") == "custom":
|
||||
for line in self.settings.get("bridges_custom").split("\n"):
|
||||
if line.strip() != "":
|
||||
f.write(f"Bridge {line}\n")
|
||||
f.write("\nUseBridges 1\n")
|
||||
|
||||
# Execute a tor subprocess
|
||||
start_ts = time.time()
|
||||
|
|
|
@ -105,13 +105,11 @@ class Settings(object):
|
|||
"auth_password": "",
|
||||
"use_autoupdate": True,
|
||||
"autoupdate_timestamp": None,
|
||||
"no_bridges": True,
|
||||
"tor_bridges_use_obfs4": False,
|
||||
"tor_bridges_use_meek_lite_azure": False,
|
||||
"tor_bridges_use_snowflake": False,
|
||||
"tor_bridges_use_moat": False,
|
||||
"tor_bridges_use_moat_bridges": "",
|
||||
"tor_bridges_use_custom_bridges": "",
|
||||
"bridges_enabled": False,
|
||||
"bridges_type": "built-in", # "built-in", "moat", or "custom"
|
||||
"bridges_builtin_pt": "obfs4", # "obfs4", "meek-azure", or "snowflake"
|
||||
"bridges_moat": "",
|
||||
"bridges_custom": "",
|
||||
"persistent_tabs": [],
|
||||
"locale": None, # this gets defined in fill_in_defaults()
|
||||
"theme": 0,
|
||||
|
|
|
@ -29,13 +29,11 @@ class TestSettings:
|
|||
"auth_password": "",
|
||||
"use_autoupdate": True,
|
||||
"autoupdate_timestamp": None,
|
||||
"no_bridges": True,
|
||||
"tor_bridges_use_obfs4": False,
|
||||
"tor_bridges_use_meek_lite_azure": False,
|
||||
"tor_bridges_use_snowflake": False,
|
||||
"tor_bridges_use_moat": False,
|
||||
"tor_bridges_use_moat_bridges": "",
|
||||
"tor_bridges_use_custom_bridges": "",
|
||||
"bridges_enabled": False,
|
||||
"bridges_type": "built-in",
|
||||
"bridges_builtin_pt": "obfs4",
|
||||
"bridges_moat": "",
|
||||
"bridges_custom": "",
|
||||
"persistent_tabs": [],
|
||||
"theme": 0,
|
||||
}
|
||||
|
@ -96,10 +94,11 @@ class TestSettings:
|
|||
assert settings_obj.get("use_autoupdate") is True
|
||||
assert settings_obj.get("autoupdate_timestamp") is None
|
||||
assert settings_obj.get("autoupdate_timestamp") is None
|
||||
assert settings_obj.get("no_bridges") is True
|
||||
assert settings_obj.get("tor_bridges_use_obfs4") is False
|
||||
assert settings_obj.get("tor_bridges_use_meek_lite_azure") is False
|
||||
assert settings_obj.get("tor_bridges_use_custom_bridges") == ""
|
||||
assert settings_obj.get("bridges_enabled") is False
|
||||
assert settings_obj.get("bridges_type") == "built-in"
|
||||
assert settings_obj.get("bridges_builtin_pt") == "obfs4"
|
||||
assert settings_obj.get("bridges_moat") == ""
|
||||
assert settings_obj.get("bridges_custom") == ""
|
||||
|
||||
def test_set_version(self, settings_obj):
|
||||
settings_obj.set("version", "CUSTOM_VERSION")
|
||||
|
|
Loading…
Reference in a new issue