我将使用tor连接到Android应用程序中的服务器,但不使用orbot。我找到了这个库:https://github.com/jehy/Tor-Onion-Proxy-Library
我添加了
compile 'com.github.jehy:Tor-Onion-Proxy-Library:0.0.7'
compile 'org.slf4j:slf4j-api:1.7.7'
compile 'org.slf4j:slf4j-android:1.7.7'到我的build.gradle (模块:应用程序)和
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}}
接下来,我在onCreateView中添加了我的片段
int totalSecondsPerTorStartup = 4 * 60;
int totalTriesPerTorStartup = 5;
try {
boolean ok = onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup);
if (!ok)
Log.e("TorTest", "Couldn't start Tor!");
}
catch (InterruptedException | IOException e) {
e.printStackTrace();
}但是我得到了一个错误的Cannot resolve symbol 'onionProxyManager'。我按照Github上的说明..。
如果我将onionProxyManager更改为OnionProxyManager,我可以导入com.msopentech.thali.toronionproxy.OnionProxyManager,但在startWithRepeat上得到一个错误。
所以如果可以的话请帮帮我。谢谢!
发布于 2018-02-24 08:20:07
int totalSecondsPerTorStartup = 4 * 60;
int totalTriesPerTorStartup = 5;
String fileStorageLocation = "torfiles";
OnionProxyManager onionProxyManager =
new AndroidOnionProxyManager(getActivity(), fileStorageLocation);
public void start(){
// Start the Tor Onion Proxy
try {
boolean ok = onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup);
// Now the socket is open but note that it can take some time before the Tor network has everything
// connected and connection requests can fail for spurious reasons (especially when connecting to
// hidden services) so have lots of retry logic.
if (!ok)
// Log.e("TorTest", "Couldn't start Tor!");
return;
}
catch (InterruptedException | IOException e) {
e.printStackTrace();
}发布于 2018-12-17 13:16:44
即使是我也面临着让这个库正常工作的许多问题。它没有明确的文档。因此,我创建了一个示例应用程序来展示如何使用该库,并向该存储库发送了一个拉取请求。PR是被接受的,现在它在该存储库中可用。您可以在此处查看示例应用程序:https://github.com/jehy/Tor-Onion-Proxy-Library/tree/master/SampleTorProxyApp
它不像粘贴给定的示例代码那么简单。首先,读取更新后的README。如果你不能理解它,那么就去看看它是如何在示例应用程序中实现的。看看您应该如何在MainActivity here中使用它。如果您希望将自定义ConnectionSocketFactory和SSLConnectionSocketFactory类与HttpClient一起使用,以便通过Tor从服务器发送数据或向服务器接收数据(如here所示),则需要创建自己的自定义data和data类。
https://stackoverflow.com/questions/48194604
复制相似问题