function statusListener() {
if (xmlhttp.readyState == 1) {
document.getElementById('myipviewer_spanel').label = "loading...";
}
if (xmlhttp.readyState == 4) {
var data = xmlhttp.responseText;
//Get IP
var pos = data.indexOf( "<h1", 0 );
var pos2 = data.indexOf( "</h1>", 0 );
if (pos > 1){
var IPAddress = data.substring( pos + 46, pos2 ).replace(/^\s*|\s*$/g,"");
}
if (IPAddress != ''){
document.getElementById('myipviewer_spanel').label = IPAddress.replace(/^\s*|\s*$/g,"");
}else{
document.getElementById('myipviewer_spanel').label = "Undefined";
}
//Get Location
var pos = data.indexOf( "My country is", 0 );
var pos2 = data.indexOf( "</h2>", 0 );
if (pos > 1){
var Country = data.substring( pos + 13, pos2 ).replace(/^\s*|\s*$/g,"");
}
if (Country != ''){
document.getElementById('myipviewer_popup_country').label = "Country: "+Country.replace(/^\s*|\s*$/g,"");
}else{
document.getElementById('myipviewer_popup_country').label = "Undefined";
}
//Get Date
now = new Date();
hour = now.getHours();
min = now.getMinutes();
sec = now.getSeconds();
if (sec < 10){
sec = "0"+sec;
}
if (min < 10){
min = "0"+min;
}
if (hour > 12){
hour = hour-12;
}
//Output Update Time
document.getElementById('myipviewer_spanel').setAttribute("tooltiptext", "Last updated: " + hour + ":" + min + ":" + sec);
//Set Auto-update Time
setTimeout("myipviewer_update()", 600000); //10 Mins
}
}
}
function myipviewer_copyip2clip() {
const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
gClipboardHelper.copyString(document.getElementById('myipviewer_spanel').label);
}
function moreInfo() {
gBrowser.selectedTab = gBrowser.addTab("http://ip-address.domaintools.com/");
}
function pasteIP() {
var IPAddress = document.getElementById('myipviewer_spanel').label;
insertString(document.commandDispatcher.focusedElement, IPAddress);
}
Pinging www.cache.split.netease.com [202.108.9.31] with 32 bytes of data:
Reply from 202.108.9.31: bytes=32 time=917ms TTL=52
Route: 218.24.97.250
Ping statistics for 202.108.9.31:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 917ms, Maximum = 917ms, Average = 917ms
ip Route: 218.24.97.250 这个就是我的外网IP
可以试试
-------------------------------------------------------------------
试了这种方法,得到的Route是一个内网的ip地址。
Pinging www.cache.split.netease.com [202.108.9.31] with 32 bytes of data:
Reply from 202.108.9.31: bytes=32 time=917ms TTL=52
Route: 218.24.97.250
Ping statistics for 202.108.9.31:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 917ms, Maximum = 917ms, Average = 917ms