Soneso / stellar_flutter_sdk

Stellar SDK for flutter - dart, Stellar, Horizon, Soneso
MIT License
71 stars 33 forks source link

feat: Tor support: add optional HttpClient param for proxy/SOCKS/Tor support #92

Closed sneurlax closed 2 months ago

sneurlax commented 2 months ago

Here's an example of how we use this change in Stack Wallet:

HttpClient? _httpClient;
if (prefs.useTor) {
  final ({InternetAddress host, int port}) proxyInfo =
      TorService.sharedInstance.getProxyInfo();

  _httpClient = HttpClient();
  SocksTCPClient.assignToHttpClient(
      _httpClient!, [ProxySettings(proxyInfo.host, proxyInfo.port)]);
} else {
  _httpClient = null;
}

_stellarSdk = stellar.StellarSDK("${currentNode.host}:${currentNode.port}",
    httpClient: _httpClient);

Then we use StellarSDK as normal.

sneurlax commented 2 months ago

Closes #91

christian-rogobete commented 2 months ago

Hello @sneurlax, thank you for adding the optional HttpClient param!