获取本地客户端真实IP的探讨?
webrtc\u0026lt;SCRIPT\u0026gt;\tfunction Myaddress(ip)\t{\t\tdocument.getElementById(\u0026#39;id\u0026#39;).innerHTML=ip;\t}; \tfunction getIpByActiveObject() //IE window 2000 server xp\t{\t\t//var wshNetwork = new ActiveXObject("WScript.Network"); \t\t//alert(wshNetwork.ComputerName);\t\tvar ip=new ActiveXObject("rcbdyctl.Setting").GetIPAddress;//无效代码\t\tdocument.getElementById(\u0026#39;active\u0026#39;).innerHTML=ip;\t\t}\tfunction getIP_webrtc()\t{\t\t// NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23 \tvar RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;\t\tif (RTCPeerConnection)\t\t{ \t\t (function (){\t\t\tvar rtc = new RTCPeerConnection({iceServers:});\t\t\tif (window.mozRTCPeerConnection) \t\t\t{ // FF needs a channel/stream to proceed\t\t\t\t rtc.createDataChannel(\u0026#39;\u0026#39;, {reliable:false});\t\t\t};\t\t\trtc.onicecandidate = function (evt){\t\t\t\tif (evt.candidate) grepSDP(evt.candidate.candidate);\t\t\t };\t\t\trtc.createOffer(function (offerDesc) {\t\t\t\t//alert(1);\t\t\t\tgrepSDP(offerDesc.sdp);\t\t\t\trtc.setLocalDescription(offerDesc);\t\t\t}, function (e) { console.warn("offer failed", e); });\t\t\t//alert(1111);\t\t\tvar addrs = Object.create(null);\t\t\taddrs = false;\t\t\tfunction updateDisplay(newAddr) {\t\t\t\tif (newAddr in addrs) return;\t\t\t\telse addrs = true;\t\t\t\tvar displayAddrs = Object.keys(addrs).filter(function (k) { return addrs; });\t\t\t document.getElementById(\u0026#39;list\u0026#39;).textContent = displayAddrs.join(" or perhaps ") || "n/a";\t\t\t }\t\t\t\t\tfunction grepSDP(sdp) \t\t\t{\t\t\t\tvar hosts = ;\t\t\t\tsdp.split(\u0026#39;\\r\\u0026#39;).forEach(function (line) { \t\t\t\t\t if (~line.indexOf("a=candidate")) \t\t\t\t\t { \t\t\t\t\t\t var parts = line.split(\u0026#39; \u0026#39;); \t\t\t\t\t\t var addr = parts;\t\t\t\t\t\t var type = parts;\t\t\t\t\t\tif (type === \u0026#39;host\u0026#39;) updateDisplay(addr);\t\t\t\t\t } \t\t\t\t\t else if (~line.indexOf("c=")) \t\t\t\t\t { \t\t\t\t\t\t var parts = line.split(\u0026#39; \u0026#39;),\t\t\t\t\t\t\taddr = parts;\t\t\t\t\t\t updateDisplay(addr);\t\t\t\t\t }\t\t\t\t});//end forEach\t\t\t }//end grepSDP\t\t })();//end fuction \t\t}//if\t\telse {\t\t\tdocument.getElementById(\u0026#39;list\u0026#39;).innerHTML = "\u0026lt;code\u0026gt;ifconfig | grep inet | grep -v inet6 | cut -d\\" \\" -f2 | tail -n1\u0026lt;/code\u0026gt;";\t\t\tdocument.getElementById(\u0026#39;list\u0026#39;).nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";\t\t }}\u0026lt;/script\u0026gt;
自己看着改吧!
推荐阅读
- win7中本地连接跟无线网卡同时使用时是怎么样的模式
- 电商的初级产品经理怎样快速获取需求
- 为啥微信没有为安卓平板推出客户端
- Foxmail、Outlook等邮件客户端,哪个综合体验更好,与网页邮箱相比又怎样
- Git删除的本地仓可以恢复吗
- tcp通讯时,发送30多个1024的包到客户端,中间有包的大小不对,为啥
- Evernote 本地笔记有哪些应用技巧
- 从这张电脑桌面截图能获取使用者多少信息
- 怎样获取每日全球注册的域名或者怎样通过dns服务器获取每日在dns上新增的解析域名
- YY 语音客户端为啥一直没有出 Mac 版本