【问题标题】:Orbot Netcipher connecting to .onion urlsOrbot Netcipher 连接到 .onion url
【发布时间】:2018-09-28 01:55:23
【问题描述】:

所以,我正在尝试让我的应用程序与 .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/}

感谢所有帮助!

【问题讨论】:

  • 请发布您的堆栈跟踪
  • 响应:响应{protocol=http/1.0, code=405, message=Method Not Allowed, url=http://**********.onion/}跨度>
  • Method Not Allowed,
  • 没错,当我通过 orbot 运行代理时,为什么不允许使用 .onion 域?

标签: java android proxy tor orbot


【解决方案1】:

好的,我找到了问题,我会发布答案给其他想知道的人!

改变这个:

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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-05
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多