2017-07-31 37 views

答えて

0

:::1 localhostアドレスです。あなたはそれを正しくしています。代わりに、そのためにjavascriptコードを使用することができます。以下はそのコードです:

var myIP; 
    window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome 
    var pc = new RTCPeerConnection({ iceServers: [] }), noop = function() { }; 
    pc.createDataChannel(""); //create a bogus data channel 
    pc.createOffer(pc.setLocalDescription.bind(pc), noop); // create offer and set local description 
    pc.onicecandidate = function (ice) { //listen for candidate events 
     if (!ice || !ice.candidate || !ice.candidate.candidate) return; 
     myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1]; 
     console.log('my IP: ', myIP); 
     $('#IpAddress').val(myIP); 
     pc.onicecandidate = noop; 
    }; 
+0

助けてくれてありがとう、私はasp.netコアの訪問者のIPv4、IPv6、ネットワークIPとMacアドレスをキャプチャする必要があります。親切にこのことで私を助けることができますか? – sindhol

関連する問題