洋葱路由 408.12.1

洋葱路由 408.12.1

Benjamin Erhart维护。



洋葱路由 408.12.1

  • Conrad Kramer,Chris Ballinger,Mike Tigas 和 Benjamin Erhart

Tor.framework

Version License Platform

Tor.framework 是在您的iOS应用程序中嵌入洋葱路由的最简单方法。API目前尚不稳定,可能随时更改。

目前,框架在以下版本中编译torlibeventopensslliblzma

tor 0.4.7.14
libevent 2.1.12
OpenSSL 3.1.2
liblzma 5.4.4

示例

要运行示例项目,请克隆仓库,然后从示例目录首先运行pod install

要求

  • iOS 9.0 或更高版本
  • macOS 12.0 或更高版本
  • Xcode 13.0 或更高版本
  • 您的PATH中的autoconfautomakelibtoolgettext

安装

通过Homebrew安装构建工具。

brew install automake autoconf libtool gettext

可以通过CocoaPods访问Tor。要安装它,只需将以下行添加到您的Podfile中

如果使用动态框架,请使用根规范(或Tor/GeoIP - 见下文)。

use_frameworks!
pod 'Tor', '~> 407.13'

(或)。)

如果您需要将其作为静态库添加,您将需要从修改过的podspec添加它。

pod 'Tor', :podspec => 'https://raw.githubusercontent.com/iCepa/Tor.framework/pure_pod/TorStatic.podspec'

目前对静态库的支持不稳定。您可能会遇到构建问题。欢迎针对此问题的任何贡献!

(或)。)

准备新版本

对于Tor.framework的维护者/贡献者,应按照以下步骤准备新版本

确保您已将tor、libevent、openssl和xz的子模块树中的更改提交。

同时更新README.mdTor.podspec中的信息和版本号!

然后按以下方式执行lint操作

pod lib lint --verbose --allow-warnings

(使用verbose,否则您会很无聊。))

如果linting顺利,为版本创建git tag,推送到GitHub,然后公布到CocoaPods

pod trunk push Tor.podspec --verbose --allow-warnings  --use-libraries

(遗憾的是,您无法在发布时进行linting,因此您可能可以跳过首次lint。然而,pod trunk push将会更长,因为它还会克隆所有内容。))

然后在GitHub中创建与tag对应的发布,并附加与旧发布类似的最新的信息。

升级Tor

要升级Tor

cd Tor/tor
git fetch
git checkout tor-0.4.7.13 # Find latest versions with git tag -l
rm -r * && git checkout . # Get rid of all autogenerated configuration files, which may not work with the newest version anymore.
git submodule update --init --recursive # Later Tor has submodules.

-> 通过运行示例应用测试构建。

在报告导航器中检查构建输出。(左窗格中的最后一个选项卡。)

使用方法

启动Tor的实例涉及使用三个类:`TORThread`、`TORConfiguration`和`TORController`。

以下是将Tor与`NSURLSession`集成的示例

TORConfiguration *configuration = [TORConfiguration new];
configuration.ignoreMissingTorrc = YES;
configuration.cookieAuthentication = YES;
configuration.dataDirectory = [NSURL fileURLWithPath:NSTemporaryDirectory()];
configuration.controlSocket = [configuration.dataDirectory URLByAppendingPathComponent:@"control_port"];

TORThread *thread = [[TORThread alloc] initWithConfiguration:configuration];
[thread start];

NSData *cookie = configuration.cookie;
TORController *controller = [[TORController alloc] initWithSocketURL:configuration.controlSocket];

NSError *error;
[controller connect:&error];

if (error) {
    NSLog(@"Error: %@", error);
    return;
}

[controller authenticateWithData:cookie completion:^(BOOL success, NSError *error) {
    if (!success)
        return;

    [controller addObserverForCircuitEstablished:^(BOOL established) {
        if (!established)
            return;

        [controller getSessionConfiguration:^(NSURLSessionConfiguration *configuration) {
            NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
            ...
        }];
    }];
}];

GeoIP

在你的Podfile中使用子规范GeoIPStaticGeoIP,而不是根规范

use_frameworks!
pod 'Tor/GeoIP'

或者

pod 'Tor/GeoIP', :podspec => 'https://raw.githubusercontent.com/iCepa/Tor.framework/pure_pod/TorStatic.podspec'

子规范将创建一个"GeoIP"包并安装运行脚本阶段,该阶段将下载适当的GeoIP文件。

要与Tor一起使用它,将以下内容添加到你的配置中

TORConfiguration *configuration = [TORConfiguration new];
configuration.geoipFile = NSBundle.geoIpBundle.geoipFile;
configuration.geoip6File = NSBundle.geoIpBundle.geoip6File;

作者

许可协议

Tor.framework受MIT许可协议保护。有关更多信息,请参阅LICENSE文件。