From d66f9912c1ec46ff2f810ed00c543bfeb483685b Mon Sep 17 00:00:00 2001 From: Benjamin Erhart Date: Tue, 17 Jan 2023 17:37:04 +0100 Subject: [PATCH] Issue #46: Re-added default Obfs4 bridges, request via mail and request via Telegram. --- Orbot Mac/EditAuthViewController.swift | 2 +- Orbot Mac/MainViewController.swift | 4 +- Orbot Mac/SettingsViewController.swift | 2 +- Orbot.xcodeproj/project.pbxproj | 42 +++----- Orbot/BridgesViewController.swift | 122 +++++++++++++++++++++--- Orbot/CaptchaViewController.swift | 4 +- Orbot/CustomBridgesViewController.swift | 2 +- Orbot/MainViewController.swift | 2 +- Podfile | 25 ++--- Podfile.lock | 14 ++- Shared/L10n.swift | 12 --- 11 files changed, 154 insertions(+), 77 deletions(-) diff --git a/Orbot Mac/EditAuthViewController.swift b/Orbot Mac/EditAuthViewController.swift index 8bd0645..b0ea6d9 100644 --- a/Orbot Mac/EditAuthViewController.swift +++ b/Orbot Mac/EditAuthViewController.swift @@ -42,7 +42,7 @@ class EditAuthViewController: NSViewController, NSWindowDelegate { @IBOutlet weak var cancelBt: NSButton! { didSet { - cancelBt.title = L10n.cancel + cancelBt.title = IPtProxyUI.L10n.cancel } } diff --git a/Orbot Mac/MainViewController.swift b/Orbot Mac/MainViewController.swift index 069680a..1bbc5b4 100644 --- a/Orbot Mac/MainViewController.swift +++ b/Orbot Mac/MainViewController.swift @@ -81,7 +81,7 @@ class MainViewController: NSViewController, NSWindowDelegate, NSToolbarItemValid item.label = L10n.authCookies case "bridges": - item.label = L10n.bridgeConf + item.label = IPtProxyUI.L10n.bridgeConfiguration default: break @@ -132,7 +132,7 @@ class MainViewController: NSViewController, NSWindowDelegate, NSToolbarItemValid let showError = { (error: Error) in hud?.progress = 1 - hud?.labelText = L10n.error + hud?.labelText = IPtProxyUI.L10n.error hud?.detailsLabelText = error.localizedDescription hud?.hide(true, afterDelay: 3) } diff --git a/Orbot Mac/SettingsViewController.swift b/Orbot Mac/SettingsViewController.swift index 8e1dfd3..d0074aa 100644 --- a/Orbot Mac/SettingsViewController.swift +++ b/Orbot Mac/SettingsViewController.swift @@ -237,7 +237,7 @@ class SettingsViewController: NSViewController { alert.messageText = L10n.warning alert.informativeText = L10n.settingsExplanation3 alert.addButton(withTitle: L10n.activate) - alert.addButton(withTitle: L10n.cancel) + alert.addButton(withTitle: IPtProxyUI.L10n.cancel) let response = alert.runModal() diff --git a/Orbot.xcodeproj/project.pbxproj b/Orbot.xcodeproj/project.pbxproj index e786b34..a949bcd 100644 --- a/Orbot.xcodeproj/project.pbxproj +++ b/Orbot.xcodeproj/project.pbxproj @@ -802,8 +802,8 @@ A01AB5F328A53465008A79EE /* Frameworks */, A01AB5F428A53465008A79EE /* Resources */, 61AE61C4AE5791BF2DBDCC61 /* [CP] Embed Pods Frameworks */, - B8D8CA9AB89FD71BC834A5D8 /* [CP] Copy Pods Resources */, A01AB6AC28A55706008A79EE /* Embed Foundation Extensions */, + A8CC658E10E591DC6C1D0A6E /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -826,7 +826,7 @@ A06D605C29019D33001A2E2C /* Embed Frameworks */, A01AB69C28A55706008A79EE /* Frameworks */, A01AB69D28A55706008A79EE /* Resources */, - 390E15C770E5B4A49902D7F6 /* [CP] Copy Pods Resources */, + 021E681CE032ED2489488CC7 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -848,7 +848,7 @@ A05B73AE24755CE600930C40 /* Resources */, A0A735D9247561F200073C81 /* Embed Foundation Extensions */, EA613F0B6D61304A533884FE /* [CP] Embed Pods Frameworks */, - ED8A4F585C565CFB646DACF1 /* [CP] Copy Pods Resources */, + 329E559D33FDBA00740F2EDE /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -889,7 +889,6 @@ A06D605F29019D3B001A2E2C /* Embed Frameworks */, A0A735CA247561F200073C81 /* Frameworks */, A0A735CB247561F200073C81 /* Resources */, - 16978536BCC6E5D81EE5DC54 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -1053,38 +1052,38 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 16978536BCC6E5D81EE5DC54 /* [CP] Copy Pods Resources */ = { + 021E681CE032ED2489488CC7 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-TorVPN/Pods-TorVPN-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-TorVPN Mac/Pods-TorVPN Mac-resources-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-TorVPN/Pods-TorVPN-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-TorVPN Mac/Pods-TorVPN Mac-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TorVPN/Pods-TorVPN-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TorVPN Mac/Pods-TorVPN Mac-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 390E15C770E5B4A49902D7F6 /* [CP] Copy Pods Resources */ = { + 329E559D33FDBA00740F2EDE /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-TorVPN Mac/Pods-TorVPN Mac-resources-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-resources-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-TorVPN Mac/Pods-TorVPN Mac-resources-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TorVPN Mac/Pods-TorVPN Mac-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-resources.sh\"\n"; showEnvVarsInLog = 0; }; 409194A5E6D0FCFF456B4364 /* [CP] Check Pods Manifest.lock */ = { @@ -1186,7 +1185,7 @@ shellPath = /bin/sh; shellScript = "if [ -f /opt/homebrew/bin/bartycrouch ]; then\n /opt/homebrew/bin/bartycrouch update -x\n /opt/homebrew/bin/bartycrouch lint -x\nelse\n echo \"warning: BartyCrouch not installed. Download it form https://github.com/Flinesoft/BartyCrouch\"\nfi\n"; }; - B8D8CA9AB89FD71BC834A5D8 /* [CP] Copy Pods Resources */ = { + A8CC658E10E591DC6C1D0A6E /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -1264,23 +1263,6 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - ED8A4F585C565CFB646DACF1 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Orbot/Pods-Orbot-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/Orbot/BridgesViewController.swift b/Orbot/BridgesViewController.swift index 564a47c..6f04d73 100644 --- a/Orbot/BridgesViewController.swift +++ b/Orbot/BridgesViewController.swift @@ -9,14 +9,18 @@ import UIKit import Eureka import IPtProxyUI +import MessageUI -class BridgesViewController: BaseFormViewController, BridgesConfDelegate { +class BridgesViewController: BaseFormViewController, BridgesConfDelegate, MFMailComposeViewControllerDelegate { enum Option: String, CaseIterable { case direct = "transport_none" + case obfs4 = "transport_obfs4" case snowflake = "transport_snowflake" case snowflakeAmp = "transport_snowflake_amp" case request = "request" + case requestMail = "request_mail" + case requestTelegram = "request_telegram" case custom = "transport_custom" var localizedDescription: String { @@ -24,6 +28,9 @@ class BridgesViewController: BaseFormViewController, BridgesConfDelegate { case .direct: return NSLocalizedString("Direct connection to Tor", comment: "") + case .obfs4: + return NSLocalizedString("Well-known Obfs4 bridges", comment: "") + case .snowflake: return NSLocalizedString("Snowflake", comment: "") @@ -31,10 +38,16 @@ class BridgesViewController: BaseFormViewController, BridgesConfDelegate { return NSLocalizedString("Snowflake (AMP rendezvous)", comment: "") case .request: - return NSLocalizedString("Get a bridge from Tor (Obfs4)", comment: "") + return NSLocalizedString("Get bridges from Tor (Obfs4)", comment: "") + + case .requestMail: + return NSLocalizedString("Get bridges via Mail", comment: "") + + case .requestTelegram: + return NSLocalizedString("Get bridges via Telegram", comment: "") case .custom: - return NSLocalizedString("Custom bridge", comment: "") + return NSLocalizedString("Custom bridges", comment: "") } } @@ -43,12 +56,24 @@ class BridgesViewController: BaseFormViewController, BridgesConfDelegate { case .direct: return NSLocalizedString("The best way to connect to Tor. Use if Tor is not blocked.", comment: "") - case .snowflake, .snowflakeAmp: + case .obfs4: + return NSLocalizedString("Blocked in some countries, but great otherwise when you don't trust the network you're in.", comment: "") + + case .snowflake: return NSLocalizedString("Connects through Tor volunteers. Gets around some Tor blocking.", comment: "") + case .snowflakeAmp: + return NSLocalizedString("Find Snowflake volunteers through another mechanism.", comment: "") + case .request: return NSLocalizedString("Cloaks your traffic. Gets around some Tor blocking.", comment: "") + case .requestMail: + return NSLocalizedString("In case you cannot reach Tor's bridge distribution website, you can try via mail. Has to be from a Gmail or Riseup account.", comment: "") + + case .requestTelegram: + return NSLocalizedString("If Telegram works for you, you can ask the Telgram Tor Bot for bridges. Tap on 'Start' or write '/start' or '/bridges' in the chat.", comment: "") + case .custom: return NSLocalizedString("Most likely to keep you connected if Tor is severly blocked. Requires a bridge address from someone you trust.", comment: "") } @@ -59,17 +84,33 @@ class BridgesViewController: BaseFormViewController, BridgesConfDelegate { case .direct: return Settings.transport == .none + case .obfs4: + return Settings.transport == .obfs4 + case .snowflake: return Settings.transport == .snowflake case .snowflakeAmp: return Settings.transport == .snowflakeAmp - case .request: - return false - case .custom: return Settings.transport == .custom + + default: + return false + } + } + + var isEnabled: Bool { + switch self { + case .requestMail: + return MFMailComposeViewController.canSendMail() + + case .requestTelegram: + return UIApplication.shared.canOpenURL(Constants.telegramBot) + + default: + return true } } } @@ -103,7 +144,7 @@ class BridgesViewController: BaseFormViewController, BridgesConfDelegate { form +++ section - for option in Option.allCases { + for option in Option.allCases.filter({ $0.isEnabled }) { form.last! <<< ListCheckRow