[网络]_获取内外网IP地址
管理员
auto();
console.show();

importClass('java.net.Inet4Address');
importClass('java.net.InetAddress');
importClass('java.net.NetworkInterface');
importClass('java.util.Enumeration');
importClass('java.net.Inet6Address');
//获取内网IP地址
var hostIp = null;
try{
    var nis = NetworkInterface.getNetworkInterfaces();
    var ia = null;
    while (nis.hasMoreElements()) {
        var ni = nis.nextElement();
        var ias = ni.getInetAddresses();
        while (ias.hasMoreElements()) {  
            ia = ias.nextElement();  
            if (ia instanceof Inet6Address) {
                continue;
            }
            var ip = ia.getHostAddress();
            if (!"127.0.0.1".equals(ip)) {
                hostIp = ia.getHostAddress();
                break;
            }
        }
    }
} catch (e) {
    log(e);
}
log(hostIp);

//获取外网ip地址
var getIp_api = http.get('http://pv.sohu.com/cityjson?ie=utf-8');
var InetIP = getIp_api.body.string();
eval(InetIP);
log(returnCitySN.cip);

👍
加上注释标明内网外网会好看点。那么大的默认界面,只有2组IP,好空旷。内外网字样加上2组IP用4行来显示,ip地址向内缩进,字体稍微加粗加黑。无需太多颜色,只用不同粗细和黑度。

管理员

@l1z2o0 只是个示例代码,要这么花哨,也没什么用

@dcrclub[网络]_获取内外网IP地址 中说:

auto();
console.show();

importClass('java.net.Inet4Address');
importClass('java.net.InetAddress');
importClass('java.net.NetworkInterface');
importClass('java.util.Enumeration');
importClass('java.net.Inet6Address');
//获取内网IP地址
var hostIp = null;
try{
    var nis = NetworkInterface.getNetworkInterfaces();
    var ia = null;
    while (nis.hasMoreElements()) {
        var ni = nis.nextElement();
        var ias = ni.getInetAddresses();
        while (ias.hasMoreElements()) {  
            ia = ias.nextElement();  
            if (ia instanceof Inet6Address) {
                continue;
            }
            var ip = ia.getHostAddress();
            if (!"127.0.0.1".equals(ip)) {
                hostIp = ia.getHostAddress();
                break;
            }
        }
    }
} catch (e) {
    log(e);
}
log(hostIp);

//获取外网ip地址
var getIp_api = http.get('http://pv.sohu.com/cityjson?ie=utf-8');
var InetIP = getIp_api.body.string();
eval(InetIP);
log(returnCitySN.cip);

這是把java或android lib改寫成auto.js可用的,是吧? 非是javascript或auto.js的

有没有删除QQ好友的脚本?

auto();
console.show();

importClass('java.net.Inet4Address');
importClass('java.net.InetAddress');
importClass('java.net.NetworkInterface');
importClass('java.util.Enumeration');
importClass('java.net.Inet6Address');
//获取内网IP地址
var hostIp = null;
try{
var nis = NetworkInterface.getNetworkInterfaces();
var ia = null;
while (nis.hasMoreElements()) {
var ni = nis.nextElement();
var ias = ni.getInetAddresses();
while (ias.hasMoreElements()) {
ia = ias.nextElement();
if (ia instanceof Inet6Address) {
continue;
}
var ip = ia.getHostAddress();
if (!"127.0.0.1".equals(ip)) {
hostIp = ia.getHostAddress();
break;
}
}
}
} catch (e) {
log(e);
}
log(hostIp);

//获取外网ip地址
var getIp_api = http.get('http://pv.sohu.com/cityjson?ie=utf-8');
var InetIP = getIp_api.body.string();
eval(InetIP);
log(returnCitySN.cip);

  • 15
    帖子
  • 10887
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待