Open wanliyunyan opened 1 week ago
To clarify:
yes,I use Xray as my local SOCKS server. I only use socks client from this package,and start Xray to listen on port 10808.
@override
void initState() {
super.initState();
loadingWebView();
}
Future<void> loadingWebView() async {
final client = HttpClient();
SocksTCPClient.assignToHttpClient(
client, [ProxySettings(InternetAddress("127.0.0.1"), 10808)] // to connect local Xray socks5 server
);
try {
var url = Uri.parse("https://www.baidu.com/");
HttpClientRequest httpRequest = await client.getUrl(url);
HttpClientResponse httpResponse = await httpRequest.close();
String responseBody = await httpResponse.transform(utf8.decoder).join();
print('Response: $responseBody');
} catch (e) {
print('error: $e');
} finally {
client.close();
}
}
The local Xray server works well with hev-socks5-tunnel.
curl -x socks5h://127.0.0.1:10808 https://www.baidu.com also works well
final client = HttpClient()
..findProxy = (_) {
return 'PROXY localhost:10808';
}; // also works well
Oh I see the issue now. Can you run your code using lookup branch?
socks5_proxy:
git:
url: git://github.com/lacticwhale/socks_dart.git
ref: lookup
And add tryLookup: true
here:
SocksTCPClient.assignToHttpClient(
client, [ProxySettings(InternetAddress("127.0.0.1"), 10808)], // to connect local Xray socks5 server
tryLookup: true,
);
If it helped I will polish this feature and put into next release.
socks5_proxy:
git:
url: https://github.com/lacticwhale/socks_dart.git
ref: lookup
works well,thank you
Ok I will do a better interface and release update soon.
The problem was that some socks5 proxy don't do DNS lookup, they usually noted as socks5h.
I have a bold idea to use it together with Xray.Route WebView traffic to port 10808, start Xray to listen on port 10808. When WebView accesses http://**, Xray reports an error: 'rejected proxy/socks: failed to read address > common/protocol: invalid domain name: **' Do you know what the problem might be? I'm sure the Xray configuration is correct because it works fine when I use hev-socks5-tunnel.I set up a SOCKS5 server using https://github.com/Lozy/danted, and this Flutter code also works fine.