连接到 .onion url 的 Orbot Netcipher
Orbot Netcipher connecting to .onion urls
因此,我试图让我的应用程序与 .onion 域一起使用,但我得到的只是一个 405 错误响应。我已经尝试了所有方法,当我尝试时我的代码似乎有效 http://check.torproject.org
它说它已连接。
https://github.com/guardianproject/NetCipher
我的 gradle 包含这些依赖项。
compile 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1'
compile 'info.guardianproject.netcipher:netcipher-okhttp3:2.0.0-alpha1'
compile 'com.squareup.okhttp3:okhttp:3.4.2'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
我运行此代码用于启动 orbot 并将应用程序连接到它。
OrbotHelper.get(activity).statusTimeout(60000).addStatusCallback(new StatusCallback(){
@Override
public void onEnabled(Intent intent){
new StrongBuild();
}
@Override
public void onStarting(){
}
@Override
public void onStopping(){
}
@Override
public void onDisabled(){
}
@Override
public void onStatusTimeout(){
}
@Override
public void onNotYetInstalled(){
}
}).init();
这是 StrongBuild 文件。
import android.util.Log;
import javax.net.ssl.TrustManager;
import info.guardianproject.netcipher.client.StrongBuilder;
import info.guardianproject.netcipher.client.StrongOkHttpClientBuilder;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class StrongBuild implements StrongBuilder.Callback<OkHttpClient> {
public StrongBuild(){
Log.e("info", "Starting Strong Builder");
try{
StrongOkHttpClientBuilder.
forMaxSecurity(activity).
//withTrustManagers(new TrustManager[] { new MyTrustManager() }).
withTorValidation().
withBestProxy().
build(StrongBuild.this);
}catch(Exception e){
e.printStackTrace();
Log.e("info", "ERROR");
}
}
@Override
public void onConnected(final OkHttpClient okHttpClient){
Log.e("info" , "CONNECTED Strong Builder");
new Thread(new Runnable(){
@Override
public void run(){
try{
Request request = new Request.Builder().url("http://******.onion/").build();
Response response = okHttpClient.newCall(request).execute();
Log.e("info", "RESPONSE: "+response.toString());
Log.e("info", response.body().string());
}catch(Exception e){
e.printStackTrace();
Log.e("info", "ERROR - ATTEMPTING CONNECTION TO ONION DOMAIN");
}
}
}).start();
}
@Override
public void onConnectionException(Exception e){
Log.e("info" , "Exception");
}
@Override
public void onTimeout(){
Log.e("info" , "Timeout");
}
@Override
public void onInvalid(){
Log.e("info" , "Invalid");
}
}
堆栈跟踪:
RESPONSE: Response{protocol=http/1.0, code=405, message=Method Not Allowed, url=http://********.onion/}
感谢所有帮助!
好的,我想通了这个问题,我会post回答其他想知道的人!
改变这个:
StrongOkHttpClientBuilder.
forMaxSecurity(activity).
//withTrustManagers(new TrustManager[] { new MyTrustManager() }).
withTorValidation().
withBestProxy().
build(StrongBuild.this);
为此:
StrongOkHttpClientBuilder.
forMaxSecurity(activity).
withTrustManagers(new TrustManager[] { new MyTrustManager() }).
withTorValidation().
withSocksProxy().
withHttpProxy().
build(StrongBuild.this);
因此,我试图让我的应用程序与 .onion 域一起使用,但我得到的只是一个 405 错误响应。我已经尝试了所有方法,当我尝试时我的代码似乎有效 http://check.torproject.org
它说它已连接。
https://github.com/guardianproject/NetCipher
我的 gradle 包含这些依赖项。
compile 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1'
compile 'info.guardianproject.netcipher:netcipher-okhttp3:2.0.0-alpha1'
compile 'com.squareup.okhttp3:okhttp:3.4.2'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
我运行此代码用于启动 orbot 并将应用程序连接到它。
OrbotHelper.get(activity).statusTimeout(60000).addStatusCallback(new StatusCallback(){
@Override
public void onEnabled(Intent intent){
new StrongBuild();
}
@Override
public void onStarting(){
}
@Override
public void onStopping(){
}
@Override
public void onDisabled(){
}
@Override
public void onStatusTimeout(){
}
@Override
public void onNotYetInstalled(){
}
}).init();
这是 StrongBuild 文件。
import android.util.Log;
import javax.net.ssl.TrustManager;
import info.guardianproject.netcipher.client.StrongBuilder;
import info.guardianproject.netcipher.client.StrongOkHttpClientBuilder;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class StrongBuild implements StrongBuilder.Callback<OkHttpClient> {
public StrongBuild(){
Log.e("info", "Starting Strong Builder");
try{
StrongOkHttpClientBuilder.
forMaxSecurity(activity).
//withTrustManagers(new TrustManager[] { new MyTrustManager() }).
withTorValidation().
withBestProxy().
build(StrongBuild.this);
}catch(Exception e){
e.printStackTrace();
Log.e("info", "ERROR");
}
}
@Override
public void onConnected(final OkHttpClient okHttpClient){
Log.e("info" , "CONNECTED Strong Builder");
new Thread(new Runnable(){
@Override
public void run(){
try{
Request request = new Request.Builder().url("http://******.onion/").build();
Response response = okHttpClient.newCall(request).execute();
Log.e("info", "RESPONSE: "+response.toString());
Log.e("info", response.body().string());
}catch(Exception e){
e.printStackTrace();
Log.e("info", "ERROR - ATTEMPTING CONNECTION TO ONION DOMAIN");
}
}
}).start();
}
@Override
public void onConnectionException(Exception e){
Log.e("info" , "Exception");
}
@Override
public void onTimeout(){
Log.e("info" , "Timeout");
}
@Override
public void onInvalid(){
Log.e("info" , "Invalid");
}
}
堆栈跟踪:
RESPONSE: Response{protocol=http/1.0, code=405, message=Method Not Allowed, url=http://********.onion/}
感谢所有帮助!
好的,我想通了这个问题,我会post回答其他想知道的人!
改变这个:
StrongOkHttpClientBuilder.
forMaxSecurity(activity).
//withTrustManagers(new TrustManager[] { new MyTrustManager() }).
withTorValidation().
withBestProxy().
build(StrongBuild.this);
为此:
StrongOkHttpClientBuilder.
forMaxSecurity(activity).
withTrustManagers(new TrustManager[] { new MyTrustManager() }).
withTorValidation().
withSocksProxy().
withHttpProxy().
build(StrongBuild.this);