Nytro Posted January 26, 2014 Report Posted January 26, 2014 <body> Your network IP is: <h1 id=list>-</h1> source: <a href="http://net.ipcalf.com/">Make the locals proud.</a><script>// NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;if (RTCPeerConnection) (function () { var rtc = new RTCPeerConnection({iceServers:[]}); if (window.mozRTCPeerConnection) { // FF needs a channel/stream to proceed rtc.createDataChannel('', {reliable:false}); }; rtc.onicecandidate = function (evt) { if (evt.candidate) grepSDP(evt.candidate.candidate); }; rtc.createOffer(function (offerDesc) { grepSDP(offerDesc.sdp); rtc.setLocalDescription(offerDesc); }, function (e) { console.warn("offer failed", e); }); var addrs = Object.create(null); addrs["0.0.0.0"] = false; function updateDisplay(newAddr) { if (newAddr in addrs) return; else addrs[newAddr] = true; var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; }); document.getElementById('list').textContent = displayAddrs.join(" or perhaps ") || "n/a"; } function grepSDP(sdp) { var hosts = []; sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39 if (~line.indexOf("a=candidate")) { // http://tools.ietf.org/html/rfc4566#section-5.13 var parts = line.split(' '), // http://tools.ietf.org/html/rfc5245#section-15.1 addr = parts[4], type = parts[7]; if (type === 'host') updateDisplay(addr); } else if (~line.indexOf("c=")) { // http://tools.ietf.org/html/rfc4566#section-5.7 var parts = line.split(' '), addr = parts[2]; updateDisplay(addr); } }); }})(); else { document.getElementById('list').innerHTML = "<code>ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2 | tail -n1</code>"; document.getElementById('list').nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";}</script></body>Sursa: Edit fiddle - JSFiddle (+Demo) Quote
Nytro Posted January 27, 2014 Author Report Posted January 27, 2014 Da, chiar daca nu merge si pe IE. Quote
WarLord Posted January 27, 2014 Report Posted January 27, 2014 E adresa de la DHCP, nu de la NAT. NAT si DHCP is 2 functii diferite. Quote
aelius Posted January 27, 2014 Report Posted January 27, 2014 (edited) E adresa de la DHCP, nu de la NAT. NAT si DHCP is 2 functii diferite.Hai sa fiu putin carcotas.Adresa IP sa fie functionala are nevoie de NAT. Tu te conectezi la site-ul acela prin NAT pentru ca pe PC-ul tau este configurata o adresa IP locala, asa cum este descrisa in rfc1918.De unde stii ca am sau nu dhcp ? Uite exemplu functional si fara dhcp:PC1: IP Address: 192.168.0.10 Netmask: 255.255.255.0 Gateway: 192.168.0.1PC2 IP Address: 192.168.0.11 Netmask: 255.255.255.0 Gateway: 192.168.0.1Router: LAN IP Address: 192.168.0.1 Netmask 255.255.255.0DHCP este Dynamic Host Configuration Protocol, functioneaza la fel de bine si fara el.Si NAT-ul ala daca stai sa te gandesti, e de doua feluri: DNAT si SNATSi nu, nu sunt functii. Sunt protocoale.Network Address Translation (NAT) is a network protocol used in IPv4 networks that allows multiple devices to connect to a public network using the same public IPv4 address. NAT was originally designed in an attempt to help conserve IPv4 addresses.The Dynamic Host Configuration Protocol (DHCP) is a standardized networking protocol used by servers on an IP network to allocate IP addresses to computers. The purpose of DHCP is to automate the IP address configuration of a computer without a network administrator. Referinte: - http://en.wikipedia.org/wiki/DHCP - http://en.wikipedia.org/wiki/Network_address_translationMultumesc-Cu stima,Gica Contra, retelist de cartier Edited January 27, 2014 by aelius Quote
gabyyy Posted January 27, 2014 Report Posted January 27, 2014 hmmmIP-ul apare doar utilizatorului sau se poate salva si in server intr-un log pentru fiecare utilizator in parte? Quote
WarLord Posted January 27, 2014 Report Posted January 27, 2014 (edited) Aelius, in primul rand, codul de mai sus iti arata o adresa interna primita de la DHCP sau introdusa manual (in exemplul tau), dar totusi nu e o adresa de NAT. Si nu, nu sunt functii. Sunt protocoale. - detin functii, dar sunt protocoale. Am scris eu gresit Adresa IP sa fie functionala are nevoie de NAT. - adresa ta poate sa fie functionala si fara NAT, adica va fi functionala doar in interiorul retelei. Ca sa vezi siteul "acela" care e pe Internet, ai nevoie de functia protocolului NAT. Edited January 27, 2014 by WarLord Pentru o explicatie mai buna. Quote