http_proxy_mobile 0.0.4 copy "http_proxy_mobile: ^0.0.4" to clipboard
http_proxy_mobile: ^0.0.4 copied to clipboard

Package for use sniffing your app

http_proxy_mobile #

Flutter package for reversing all requests through the proxy connection to which you are connected in Android and iOS

Getting Started #

1 Step

Include our package in your pubspec.yaml

http_proxy_mobile: ^0.0.4

2 Step

Realize singletone service to use our methods

(if you need you can import another package to set global proxy settings. http_proxy)

import 'dart:io';

import 'package:http_proxy/http_proxy.dart';
import 'package:http_proxy_mobile/http_proxy_mobile.dart';

class ProxyService {
  final HttpProxyMobile _proxySettings = HttpProxyMobile();
  ProxyService();

  // Returned actually proxy connection in Map<Sting,String>
  //  {
  //    'proxyAddress' : '192.168.1.1'
  //    'proxyPort' : '8888'
  //  }
  Future<Map<String, String>?> get _getProxySettings async {
    Map<String, String>? proxy = await _proxySettings.getProxySettings();
    return proxy;
  }

  // Created proxy connection
  Future<void> createProxyConnection() async {
    final proxy = await _getProxySettings;
    if (proxy != null) {
      HttpProxy httpProxy = await HttpProxy.createHttpProxy();
      httpProxy.host = proxy['proxyAddress']; // replace with your server ip
      httpProxy.port = proxy['proxyPort']; // replace with your server port
      HttpOverrides.global = httpProxy;
      print('Proxy Address: ${proxy['proxyAddress']}');
      print('Proxy Port: ${proxy['proxyPort']}');
    } else {
      print('Proxy settings not found.');
    }
  }
}

3 Step

Use method createProxyConnection from ProxyService in code when you need

final proxyService = get<ProxyService>();
await proxyService.createProxyConnection();