The easiest way to integrate Tor and Pluggable Transports into your app.
This library bundles all building blocks to integrate Tor into your app:
- Tor.framework using
- C-Tor
- GeoIP files
- IPtProxyUI using
- Lyrebird Pluggable Transport
- Snowflake Pluggable Transport
- Auto-configuration support via Moat/RdSys services
- Auto-configuration support for IPv4/IPv6 cappable networks
- OrbotKit to detect and interact with a running Orbot
For an easy, no-brainer integration, change your AppDelegate
like this:
import TorManager
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
TorManager.shared.start { error in
print("[\(String(describing: type(of: self)))] error=\(error?.localizedDescription ?? "(nil)")")
}
return true
}
}
extension TorManager {
static let shared = TorManager(
directory: FileManager.default.urls(
for: .cachesDirectory, in: .userDomainMask).first!.appendingPathComponent("tor", isDirectory: true))
}
Then, when you instantiate a WKWebView
:
let webViewConfiguration = WKWebViewConfiguration()
if #available(iOS 17.0, *), let proxy = TorManager.shared.torSocks5Endpoint {
webViewConfiguration.websiteDataStore.proxyConfigurations.removeAll()
webViewConfiguration.websiteDataStore.proxyConfigurations.append(ProxyConfiguration(socksv5Proxy: proxy))
}
let webView = WKWebView(frame: .zero, configuration: webViewConfiguration)
To configure a URLSession
:
let config = URLSessionConfiguration.default
config.connectionProxyDictionary = TorManager.shared.torSocks5ProxyConf
let session = URLSession(configuration: config)
To run the example project, clone the repo, and run pod install
from the Example directory first.
C-Tor will be compiled on your machine, hence you need to have the necessary dependencies available:
brew install automake autoconf libtool gettext
For more details, see the Tor.framework README
Please add the following to your Info.plist
file for Orbot support to work:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>orbot</string>
</array>
TorManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TorManager'
pod trunk push --allow-warnings
Benjamin Erhart, [email protected] for the Guardian Project
TorManager is available under the MIT license. See the LICENSE file for more info.