From 2876e75f8aa6b3aae87e8cb642177e6ee2cb1aba Mon Sep 17 00:00:00 2001 From: Szymon Nowak Date: Sun, 13 Apr 2014 19:41:40 +0200 Subject: [PATCH] Fix 'fixed' code for finding local IPs --- .../app/controllers/index_controller.js | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/app/scripts/app/controllers/index_controller.js b/app/scripts/app/controllers/index_controller.js index ee5cee4..345585a 100644 --- a/app/scripts/app/controllers/index_controller.js +++ b/app/scripts/app/controllers/index_controller.js @@ -196,7 +196,6 @@ ShareDrop.App.IndexController = Ember.ArrayController.extend({ }, // Based on http://net.ipcalf.com/ - // SDP offer is used on Firefox, ICE candidate on Chrome _setUserLocalIP: function () { var ips = this.get('you.local_ips'); @@ -210,24 +209,14 @@ ShareDrop.App.IndexController = Ember.ArrayController.extend({ rtc.onicecandidate = function (event) { if (event.candidate) { - var addr = grep(event.candidate.candidate); - if (addr) { - console.log('Local IP found: ', addr); - ips.addObject(addr); - } + grep(event.candidate.candidate); } }; rtc.createOffer( function (offer) { + grep(offer.sdp); rtc.setLocalDescription(offer); - - var addr = grep(offer.sdp); - if (addr && addr !== '0.0.0.0') { - console.log('Local IP found: ', addr); - ips.addObject(addr); - } - }, function (error) { console.warn("Fetching local IP failed", error); @@ -247,13 +236,17 @@ ShareDrop.App.IndexController = Ember.ArrayController.extend({ type = parts[7]; if (type === 'host') { - return addr; + if (addr !== '0.0.0.0') { + ips.addObject(addr); + } } } else if (~line.indexOf("c=")) { parts = line.split(' '); addr = parts[2]; - return addr; + if (addr !== '0.0.0.0') { + ips.addObject(addr); + } } } }