我正在尝试将meek集成到android应用程序中。这里有一个示例演示如何实例化传输:
https://github.com/guardianproject/AndroidPluggableTransports/blob/master/sample/src/main/java/info/pluggeabletransports/sample/SampleClientActivity.java
问题是我从那里做什么。假设我有一个使用okhttp3的应用程序。当应用程序只与okhttp3交互时,是否有办法协调两者并使用okhttp3作为底层传输机制?
对于如何实例化传输以及每个选项的含义,我也很矛盾。在上面提供的链接中,传输实例如下:
private void initMeekTransport() {
new MeekTransport().register();
Properties options = new Properties();
String remoteAddress = "185.152.65.180:9001";// a public Tor guard to test
options.put(MeekTransport.OPTION_URL,"https://meek.azureedge.net/"); //the public Tor Meek endpoint
options.put(MeekTransport.OPTION_FRONT, "ajax.aspnetcdn.com"); //the domain fronting address to use
options.put(MeekTransport.OPTION_KEY, "97700DFE9F483596DDA6264C4D7DF7641E1E39CE"); //the key that is needed for this endpoint
init(DispatchConstants.PT_TRANSPORTS_MEEK, remoteAddress, options);
}
但是,在自述文件中(
https://github.com/guardianproject/AndroidPluggableTransports
,建议的方法是:
Properties options = new Properties();
String bridgeAddress = "https://meek.actualdomain.com";
options.put(MeekTransport.OPTION_FRONT,"www.somefrontabledomain.com");
options.put(MeekTransport.OPTION_KEY,"18800CFE9F483596DDA6264C4D7DF7331E1E39CE");
init("meek", bridgeAddress, options);
Transport transport = Dispatcher.get().getTransport(this, PT_TRANSPORTS_MEEK, options);
if (transport != null)
{
Connection conn = transport.connect(bridgeAddress);
//now use the connection, either as a proxy, or to read and write bytes directly
if (conn.getLocalAddress() != null && conn.getLocalPort() != -1)
setSocksProxy (conn.getLocalAddress(), conn.getLocalPort());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write("GET https://somewebsite.org/TheProject.html HTTP/1.0".getBytes());
conn.write(baos.toByteArray());
byte[] buffer = new byte[1024*64];
int read = conn.read(buffer,0,buffer.length);
String response = new String(buffer);
}
在后一种方法中,网桥地址被传递给init()方法。在第一种方法中,当网桥地址作为选项传递时,它是传递给in it()方法的远程地址。哪种方法是正确的?
此外,我希望对option_url、option_front和option_key有一些评论。这些信息都是从哪里来的?如果我不想使用这些默认信息,我该如何设置一个“温和的端点”,例如不使用默认的TorOne?CDN有什么特别需要做的吗?如何使用亚马逊或谷歌而不是aspnetcdn?
如你所见,我相当困惑。