autojs之是否使用了代理抓包

let r = isWifiProxy(context);
if (r) {
  log("有 代理");
} else {
  log("没有 代理");
}

function isWifiProxy(context) {
  importClass(android.os.Build);
  importClass(android.text.TextUtils);
  IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
  let proxyAddress;
  let proxyPort;
  if (IS_ICS_OR_LATER) {
    proxyAddress = java.lang.System.getProperty("http.proxyHost");
    portStr = java.lang.System.getProperty("http.proxyPort");
    proxyPort = java.lang.Integer.parseInt(portStr != null ? portStr : "-1");
  } else {
    proxyAddress = android.net.Proxy.getHost(context);
    proxyPort = android.net.Proxy.getPort(context);
  }
  return !TextUtils.isEmpty(proxyAddress) && proxyPort != -1;
}

// //通知Java您要通过代理进行连接
// System.getProperties().put("proxySet", "true");
// //指定代理所在的服务器
// System.getProperties().put("proxyHost", "myProxyMachineName");
// //指定代理监听的端口
// System.getProperties().put("proxyPort", "85");

// connection = url.openConnection();
// password = "username:password";
// encodedPassword = base64Encode(password);

// connection.setRequestProperty("Proxy-Authorization", encodedPassword);
// props = System.getProperties();
// props.put("http.proxyHost", "192.168.0.150");
// props.put("http.proxyPort", "808");

关注微信公众号, 查看更多教程
AutoJsPro教程
在这里插入图片描述

QQ交流群
747748653

码字不易,但求一赞,江湖再会。

追加isVpn函数

function isVPN() {
  try {
    var niList = java.net.NetworkInterface.getNetworkInterfaces();
    if (niList) {
      var VPN;
      var arry = java.util.Collections.list(niList).toArray();
      for (ary = 0; ary < arry.length; ary++) {
        if (!arry[ary].isUp() || arry[ary].getInterfaceAddresses().size() == 0) {
          continue;
        }
        if (arry[ary].getName().search("tun0") !== -1 || arry[ary].getName().search("ppp0") !== -1) {
          VPN = true;
          return true;
        } else {
          VPN = false;
        }
      }
      return VPN;
    }
  } catch (error) {}
}
log(isVPN());

禁止跳转, 就是禁止vpn抓包

var okHttpClient = new okhttp3.OkHttpClient()
  .newBuilder()
  .followRedirects(false) //禁止自动跳转
  .followSslRedirects(false)
  .build();


检查vpn和禁止跳转的作者是:
作者是掌玩小子粉丝群的Code

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牙叔教程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值