flutter dio使用proxyman抓包进行网络调试

证书

wifi

手机和电脑连上同一个wifi,并且手机wifi使用代理,代理地址为电脑的ip和proxyman设置的监听端口

代码

dart 复制代码
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'dart:io';

class ProxyUtil {
  static String proxyIP = "";
  static String proxyPort = "9090";

  static Dio useProxy(Dio dio) {
    if (proxyIP == "") return dio;
    dio.httpClientAdapter = IOHttpClientAdapter(
      createHttpClient: () {
        final client = HttpClient();
        client.findProxy = (uri) {
          // Proxy all request to localhost:8888.
          // Be aware, the proxy should went through you running device,
          // not the host platform.
          return 'PROXY $proxyIP:$proxyPort';
        };
        client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
        return client;
      },
    );
    return dio;
  }
}

使用方式

dart 复制代码
Dio dio = Dio();
ProxyUtil.useProxy(dio);

proxyIP为电脑ip

相关推荐
韩曙亮2 分钟前
【错误记录】flutter pub get 执行报错 ( 打开 Windows 开发者模式 )
windows·flutter
键盘上的猫头鹰44 分钟前
【Linux 基础教程(一)】概述、安装与网络配置:VMware + CentOS + NAT + XShell 远程连接
linux·网络·centos
网络研究院1 小时前
管理瘫痪、人员短缺:深度解析 NIST NVD 为什么审不动漏洞了?
网络·安全·漏洞·管理·危机
机汇五金_1 小时前
通信设备防雨箱如何兼顾防护与散热?
网络·python
初中就开始混世的大魔王1 小时前
5 Fast DDS-Discovery
网络·c++·算法·中间件
EasyDSS1 小时前
私有化视频会议系统/企业级融媒体平台EasyDSS优化升级打造轻量化高效视频协作场景
网络·音视频·媒体
z202305081 小时前
RDMA之DCQCN (14)
linux·服务器·网络·人工智能·ai
上海云盾安全满满2 小时前
为什么访问不一样的网站会有快有慢?
网络·安全
小熊officer2 小时前
网络渗透(Network Penetration)
网络·安全·web安全
长河2 小时前
APISIX
java·网络