diff --git a/Gruntfile.js b/Gruntfile.js index 39833d6..211f036 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,7 +4,9 @@ module.exports = function(grunt) { var SRC_FILES = [ 'src/utils.js', 'src/host_scan.js', - 'src/device_scan.js' + 'src/device_scan.js', + 'src/ip_discovery.js', + 'src/db.js' ]; grunt.loadNpmTasks('grunt-contrib-compress'); @@ -23,9 +25,8 @@ module.exports = function(grunt) { }, uglify: { options: { - compress: true, - mangle: true, - report: 'gzip', + compress: {}, + mangle: {}, banner: '/*! <%= pkg.name %>@<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' }, build: { @@ -49,16 +50,6 @@ module.exports = function(grunt) { spawn: false, } } - }, - compress: { - main: { - options: { - mode: 'gzip' - }, - files: [ - {expand: true, src: 'build/lan.min.js', ext: '.min.js.gz'} - ] - } } }); @@ -67,5 +58,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.registerTask('default', ['jshint', 'jasmine', 'concat', 'uglify', 'compress']); + grunt.registerTask('default', ['jshint', 'jasmine', 'concat', 'uglify']); }; diff --git a/README.md b/README.md index 26e41a9..3a356d6 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Scan the following devices on your network, and print any device matches The `DeviceScan` class is in charge of scanning for responsive hosts and then looking for fingerprintable images, scripts, or stylesheets served by an HTTP service on that host. A fingerprint is a set of criteria for matching a device. There are three types of fingerprints: images, scripts, and stylesheets. - + // image fingerprint { type: 'image', @@ -88,4 +88,4 @@ To have grunt "watch" your filesystem and run specs on change, do: #### Copyright -2006-2014, Rapid7, Inc. +2006-2015, Rapid7, Inc. diff --git a/build/lan.js b/build/lan.js index 2f81a49..9c3d904 100644 --- a/build/lan.js +++ b/build/lan.js @@ -111,7 +111,7 @@ var HostProbe = function(address) { } }; - /* + /* * @param [Number] port the port to check * @return [Boolean] websockets spec disallows connection on port */ @@ -138,6 +138,7 @@ var HostProbe = function(address) { var delta = (new Date()) - startTime; // check if the port has timed out if (delta > HostProbe.TIMEOUT) { + try { socket.close(); } catch(e) {} if (callback) callback('timeout', delta); return; } else if (socket.readyState !== 0) { @@ -167,7 +168,7 @@ var HostProbe = function(address) { } }; - var check_timeout = function() { + var checkTimeout = function() { if (img) { img = null; if (callback) callback('timeout', delta()); @@ -175,7 +176,7 @@ var HostProbe = function(address) { }; // if the request takes to long, report 'timeout' state - clearme = setTimeout(check_timeout, HostProbe.TIMEOUT); + clearme = setTimeout(checkTimeout, HostProbe.TIMEOUT); // trigger the request img.onload = img.onerror = completed; // TODO: ensure this works in IE. img.src = window.location.protocol + '//' + address; @@ -190,11 +191,17 @@ HostProbe.TIMEOUT = 2000; // 2s /* * HostScan constructor function * @param [Array, String] addresses the host:port(s) to scan + * @param [Object] opts the options hash + * @option opts [Number] batchSize the number of requests per batch, defaults to 10 + * @option opts [Number] batchDelay the delay between batches, defaults to 1500 */ -var HostScan = function(addresses) { +var HostScan = function(addresses, opts) { if (!addresses) throw "HostScan requests addresses param."; if (addresses.constructor != Array) addresses = [addresses]; + opts = opts || {}; var responses = []; // used to build responses parameter for 'complete' callback to #start + var batchSize = opts.batchSize || BATCH_SIZE; + var batchDelay = opts.batchDelay || BATCH_DELAY; // starts sending requests to the addresses in #addresses // @param [Object] opts the options hash @@ -208,10 +215,11 @@ var HostScan = function(addresses) { var startTime = new Date(); // sends the probes - var sendProbe = function(i) { - var addrIdx = batchIdx * BATCH_SIZE + i; + var sendProbe = function(i) { + var addrIdx = batchIdx * batchSize + i; if (addrIdx >= addresses.length) return; var addr = addresses[addrIdx]; + var bidx = batchIdx; // local closure setTimeout(function() { var probe = new HostProbe(addr); @@ -225,12 +233,12 @@ var HostScan = function(addresses) { } } }); - }, bidx * BATCH_DELAY); + }, bidx * batchDelay); }; // run the loop - while (batchIdx * BATCH_SIZE < addresses.length) { - for (var k = 0; k < BATCH_SIZE; k++) { + while (batchIdx * batchSize < addresses.length) { + for (var k = 0; k < batchSize; k++) { sendProbe(k); } batchIdx++; @@ -515,7 +523,7 @@ var DeviceFingerprint = function(type, device, fingerprint) { } }; - + /* * Patch toString() for a nice debug display * @return [String] serialized representation @@ -620,3 +628,1864 @@ lan.utils.merge(lan, { }); }).call(window); + +/* + * ip_discovery.js: Attempts to discover your own IP address using HTML5 WebRTC APIs. + * + * @author joev + */ + +(function(){ + +function discoverIps(opts, callback) { + + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + + if (!('waitForNext' in opts)) { + opts.waitForNext = false; // ms + } + + /* + * based heavily on the beef implementation here: + * https://github.com/beefproject/beef/wiki/Module:-Get-Internal-IP-WebRTC + */ + + var RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection || window.RTCPeerConnection; + function run() { + var addrs = { "0.0.0.0": false }; + var pendingTimeout = null; + + // Establish a connection with ICE / relay servers - in this instance: NONE + var rtc = new RTCPeerConnection({iceServers: []}); + rtc.createDataChannel('', {reliable:false}); + + // Upon an ICE candidate being found + // Grep the SDP data for IP address data + rtc.onicecandidate = function (evt) { + if (evt.candidate) grepSDP("a="+evt.candidate.candidate); + }; + + // Create an SDP offer + rtc.createOffer(function (offerDesc) { + grepSDP(offerDesc.sdp); + rtc.setLocalDescription(offerDesc); + }, function (e) { callback("SDP Offer Failed"); }); + + function processIPs(newAddr) { + if (newAddr in addrs) return; + if (!newAddr.match(/^\d+\.\d+\.\d+\.\d+$/)) return; + else addrs[newAddr] = true; + + if (opts.waitForNext) { + if (pendingTimeout) clearTimeout(pendingTimeout); + pendingTimeout = setTimeout(function() { + var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; }); + callback(false, displayAddrs); + }, opts.waitForNext); + } else { + callback(false, newAddr); + } + } + + function grepSDP(sdp) { + var parts, addr, type; + 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 + parts = line.split(' '); // http://tools.ietf.org/html/rfc5245#section-15.1 + addr = parts[4]; + type = parts[7]; + if (type === 'host') processIPs(addr); + } else if (~line.indexOf("c=")) { // http://tools.ietf.org/html/rfc4566#section-5.7 + parts = line.split(' '); + addr = parts[2]; + processIPs(addr); + } + }); + } + } + + if (RTCPeerConnection) { + run(); + } else { + setTimeout(function () { // avoid zalgo's reach + callback("RTCPeerConnection is not supported by this browser"); + }); + } + +} + + +/* + * exports + */ +lan.utils.merge(lan, { + IpDiscovery: { + start: discoverIps + } +}); + +}).call(window); +/* + * devices.js - a database of fingerprints from the web interfaces of + * popular routers and other LAN devices. + * + * MIT license. + * @author joev + */ +(function(){ + +// set up namespaces +this.lan = this.lan || {}; +this.lan.db = this.lan.db || {}; + +// Most of this database came from the jslanscanner project (https://code.google.com/p/jslanscanner). +// Big thanks to Gareth Heyes (thespanner.co.uk) for creating the database +// and allowing me to relicense it under MIT. +// I'm still deciding what to do with this exactly. + +this.lan.db.devices = [ + { + make: "Cisco", + model: "Switch", + fingerprints: [ + { + type: "image", + url: "/images/cisco_logo_header.png", + width: 62, + height: 33 + } + ] + }, + { + make: "2Wire", + model: "1000 Series", + fingerprints:[ + { + type: "image", + url: "/base/web/def/def/images/nav_sl_logo.gif" + } + ] + }, { + make: "Polycom", + model: "Unknown", + fingerprints:[ + { + type: "image", + url: "/images/logo.png", + width: 190, + height: 56 + } + ] + }, { + make: 'Epson', + model: 'EpsonNet WebAssist', + fingerprints: [ + { + type: 'image', + url: '/epsonlogo.gif', + width: 79, + height: 28 + } + ] + }, { + make: 'DLink', + model: 'dgl4100', + fingerprints: [ + { + type: 'image', + url: '/html/images/dgl4100.jpg' + } + ] + }, { + make: 'DLink', + model: 'dgl4300', + fingerprints: [ + { + type: 'image', + url: '/html/images/dgl4300.jpg' + } + ] + }, { + make: 'DLink', + model: 'di524', + fingerprints: [ + { + type: 'image', + url: '/html/images/di524.jpg' + } + ] + }, { + make: "DLink", + model: "di624", + fingerprints:[ + { + type: "image", + url: "/html/images/di624.jpg" + } + ] + }, { + make: "DLink", + model: "di624s", + fingerprints:[ + { + type: "image", + url: "/html/images/di624s.jpg" + } + ] + }, { + make: "DLink", + model: "di724gu", + fingerprints:[ + { + type: "image", + url: "/html/images/di724gu.jpg" + } + ] + }, { + make: "DLink", + model: "dilb604", + fingerprints:[ + { + type: "image", + url: "/html/images/dilb604.jpg" + } + ] + }, { + make: "DLink", + model: "dir130", + fingerprints:[ + { + type: "image", + url: "/html/images/dir130.jpg" + } + ] + }, { + make: "DLink", + model: "dir330", + fingerprints:[ + { + type: "image", + url: "/html/images/dir330.jpg" + } + ] + }, { + make: "DLink", + model: "dir450", + fingerprints:[ + { + type: "image", + url: "/html/images/dir450.jpg" + } + ] + }, { + make: "DLink", + model: "dir451", + fingerprints:[ + { + type: "image", + url: "/html/images/dir451.jpg" + } + ] + }, { + make: "DLink", + model: "dir615", + fingerprints:[ + { + type: "image", + url: "/html/images/dir615.jpg" + } + ] + }, { + make: "DLink", + model: "dir625", + fingerprints:[ + { + type: "image", + url: "/html/images/dir625.jpg" + } + ] + }, { + make: "DLink", + model: "dir635", + fingerprints:[ + { + type: "image", + url: "/html/images/dir635.jpg" + } + ] + }, { + make: "DLink", + model: "dir655", + fingerprints:[ + { + type: "image", + url: "/html/images/dir655.jpg" + } + ] + }, { + make: "DLink", + model: "dir660", + fingerprints:[ + { + type: "image", + url: "/html/images/dir660.jpg" + } + ] + }, { + make: "DLink", + model: "ebr2310", + fingerprints:[ + { + type: "image", + url: "/html/images/ebr2310.jpg" + } + ] + }, { + make: "DLink", + model: "kr1", + fingerprints:[ + { + type: "image", + url: "/html/images/kr1.jpg" + } + ] + }, { + make: "DLink", + model: "tmg5240", + fingerprints:[ + { + type: "image", + url: "/html/images/tmg5240.jpg" + } + ] + }, { + make: "DLink", + model: "wbr1310", + fingerprints:[ + { + type: "image", + url: "/html/images/wbr1310.jpg" + } + ] + }, { + make: "DLink", + model: "wbr2310", + fingerprints:[ + { + type: "image", + url: "/html/images/wbr2310.jpg" + } + ] + }, { + make: "DLink", + model: "dsl604", + fingerprints:[ + { + type: "image", + url: "/html/images/dsl604.jpg" + } + ] + }, { + make: "DLink", + model: "dsl2320b", + fingerprints:[ + { + type: "image", + url: "/html/images/dsl2320b.jpg" + } + ] + }, { + make: "DLink", + model: "dsl2540b", + fingerprints:[ + { + type: "image", + url: "/html/images/dsl2540b.jpg" + } + ] + }, { + make: "DLink", + model: "dsl2640b", + fingerprints:[ + { + type: "image", + url: "/html/images/dsl2640b.jpg" + } + ] + }, { + make: "DLink", + model: "dsl302g", + fingerprints:[ + { + type: "image", + url: "/html/images/dsl302g.jpg" + } + ] + }, { + make: "DLink", + model: "dsl502g", + fingerprints:[ + { + type: "image", + url: "/html/images/dsl502g.jpg" + } + ] + }, { + make: "DLink", + model: "dgl3420", + fingerprints:[ + { + type: "image", + url: "/html/images/dgl3420.jpg" + } + ] + }, { + make: "DLink", + model: "dwl2100ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl2100ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl2130ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl2130ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl2200ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl2200ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl2230ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl2230ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl2700ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl2700ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl3200ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl3200ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl7100ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl7100ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl7130ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl7130ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl7200ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl7200ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl7230ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl7230ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl7700ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl7700ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl8200ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl8200ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwl8220ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwl8220ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwlag132", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlag132.jpg" + } + ] + }, { + make: "DLink", + model: "dwlag530", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlag530.jpg" + } + ] + }, { + make: "DLink", + model: "dwlag660", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlag660.jpg" + } + ] + }, { + make: "DLink", + model: "dwlag700ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlag700ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg120", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg120.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg122", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg122.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg132", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg132.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg510", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg510.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg520", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg520.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg520m", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg520m.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg550", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg550.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg630", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg630.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg650", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg650.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg650m", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg650m.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg680", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg680.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg700ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg700ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg710", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg710.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg730ap", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg730ap.jpg" + } + ] + }, { + make: "DLink", + model: "dwlg820", + fingerprints:[ + { + type: "image", + url: "/html/images/dwlg820.jpg" + } + ] + }, { + make: "DLink", + model: "wda1320", + fingerprints:[ + { + type: "image", + url: "/html/images/wda1320.jpg" + } + ] + }, { + make: "DLink", + model: "wda2320", + fingerprints:[ + { + type: "image", + url: "/html/images/wda2320.jpg" + } + ] + }, { + make: "DLink", + model: "wna1330", + fingerprints:[ + { + type: "image", + url: "/html/images/wna1330.jpg" + } + ] + }, { + make: "DLink", + model: "wna2330", + fingerprints:[ + { + type: "image", + url: "/html/images/wna2330.jpg" + } + ] + }, { + make: "DLink", + model: "wua1340", + fingerprints:[ + { + type: "image", + url: "/html/images/wua1340.jpg" + } + ] + }, { + make: "DLink", + model: "wua2340", + fingerprints:[ + { + type: "image", + url: "/html/images/wua2340.jpg" + } + ] + }, { + make: "DLink", + model: "DSL502T", + fingerprints:[ + { + type: "image", + url: "/html/images/help_p.jpg" + } + ] + }, { + make: "DLink", + model: "DSL524T", + fingerprints:[ + { + type: "image", + url: "/html/images/device.gif" + } + ] + }, { + make: "Linksys", + model: "WRT54GL", + fingerprints:[ + { + type: "image", + url: "/WRT56GL.gif" + } + ] + }, { + make: "Linksys", + model: "WRT54GC", + fingerprints:[ + { + type: "image", + url: "/UI_Linksys.gif" + } + ] + }, { + make: "Linksys", + model: "WRT54G", + fingerprints:[ + { + type: "image", + url: "/WRT54G.gif" + } + ] + }, { + make: "Linksys", + model: "WRT54GS", + fingerprints:[ + { + type: "image", + url: "/UILinksys.gif" + } + ] + }, { + make: 'Linksys', + model: 'WRT100', + auth: 'basic', + fingerprints: [ + { + type: 'image', + url: '/logo.gif', // FIXME! + width: 800, + height: 20 + } + ] + }, { + make: 'Linksys', + model: 'WRT110', + auth: 'basic', + fingerprints: [ + { + type: 'image', + url: '/logo.gif', // FIXME + width: 800, + height: 300 + } + ] + }, { + make: 'Linksys', + model: 'WRT120N', + auth: 'basic', + fingerprints: [ + { + type: 'image', + url: '/logo.gif', // FIXME + width: 800, + height: 300 + } + ] + }, { + make: 'Motorola', + model: 'SURFboard Gateway SBG6580', + auth: 'ip', + fingerprints: [ + { + type: 'image', + url: '/logo_new.gif', + width: 176, + height: 125 + } + ] + }, { + make: "Netgear", + model: "CG814WG", + fingerprints:[ + { + type: "image", + url: "/images/../settingsCG814WG.gif" + } + ] + }, { + make: "Netgear", + model: "CM212", + fingerprints:[ + { + type: "image", + url: "/images/../settingsCM212.gif" + } + ] + }, { + make: "Netgear", + model: "DG632", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG632.gif" + } + ] + }, { + make: "Netgear", + model: "DG632B", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG632B.gif" + } + ] + }, { + make: "Netgear", + model: "DG814", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG814.gif" + } + ] + }, { + make: "Netgear", + model: "DG824M", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG824M.gif" + } + ] + }, { + make: "Netgear", + model: "DG834", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834.gif" + } + ] + }, { + make: "Netgear", + model: "DG834B", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834B.gif" + } + ] + }, { + make: "Netgear", + model: "DG834G", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834G.gif" + } + ] + }, { + make: "Netgear", + model: "DG834GB", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834GB.gif" + } + ] + }, { + make: "Netgear", + model: "DG834GT", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834GT.gif" + } + ] + }, { + make: "Netgear", + model: "DG834GTB", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834GTB.gif" + } + ] + }, { + make: "Netgear", + model: "DG834GV", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834GV.gif" + } + ] + }, { + make: "Netgear", + model: "dg834N", + fingerprints:[ + { + type: "image", + url: "/images/../settingsdg834N.gif" + } + ] + }, { + make: "Netgear", + model: "DG834PN", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDG834PN.gif" + } + ] + }, { + make: "Netgear", + model: "DGFV338", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDGFV338.gif" + } + ] + }, { + make: "Netgear", + model: "DM111P", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDM111P.gif" + } + ] + }, { + make: "Netgear", + model: "DM602", + fingerprints:[ + { + type: "image", + url: "/images/../settingsDM602.gif" + } + ] + }, { + make: "Netgear", + model: "FM114P", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFM114P.gif" + } + ] + }, { + make: "Netgear", + model: "FR114P", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFR114P.gif" + } + ] + }, { + make: "Netgear", + model: "FR114W", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFR114W.gif" + } + ] + }, { + make: "Netgear", + model: "FR314", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFR314.gif" + } + ] + }, { + make: "Netgear", + model: "FR318", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFR318.gif" + } + ] + }, { + make: "Netgear", + model: "FR328S", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFR328S.gif" + } + ] + }, { + make: "Netgear", + model: "FV318", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFV318.gif" + } + ] + }, { + make: "Netgear", + model: "FVG318", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVG318.gif" + } + ] + }, { + make: "Netgear", + model: "FVL328", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVL328.gif" + } + ] + }, { + make: "Netgear", + model: "FVM318", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVM318.gif" + } + ] + }, { + make: "Netgear", + model: "FVS114", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVS114.gif" + } + ] + }, { + make: "Netgear", + model: "FVS124G", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVS124G.gif" + } + ] + }, { + make: "Netgear", + model: "FVS318", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVS318.gif" + } + ] + }, { + make: "Netgear", + model: "FVS328", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVS328.gif" + } + ] + }, { + make: "Netgear", + model: "FVS338", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVS338.gif" + } + ] + }, { + make: "Netgear", + model: "FVX538", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFVX538.gif" + } + ] + }, { + make: "Netgear", + model: "FWAG114", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFWAG114.gif" + } + ] + }, { + make: "Netgear", + model: "FWG114P", + fingerprints:[ + { + type: "image", + url: "/images/../settingsFWG114P.gif" + } + ] + }, { + make: "Netgear", + model: "GA302T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsGA302T.gif" + } + ] + }, { + make: "Netgear", + model: "GA311", + fingerprints:[ + { + type: "image", + url: "/images/../settingsGA311.gif" + } + ] + }, { + make: "Netgear", + model: "GA511", + fingerprints:[ + { + type: "image", + url: "/images/../settingsGA511.gif" + } + ] + }, { + make: "Netgear", + model: "GA620", + fingerprints:[ + { + type: "image", + url: "/images/../settingsGA620.gif" + } + ] + }, { + make: "Netgear", + model: "GA621", + fingerprints:[ + { + type: "image", + url: "/images/../settingsGA621.gif" + } + ] + }, { + make: "Netgear", + model: "GA622T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsGA622T.gif" + } + ] + }, { + make: "Netgear", + model: "HE102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsHE102.gif" + } + ] + }, { + make: "Netgear", + model: "HR314", + fingerprints:[ + { + type: "image", + url: "/images/../settingsHR314.gif" + } + ] + }, { + make: "Netgear", + model: "JFS516", + fingerprints:[ + { + type: "image", + url: "/images/../settingsJFS516.gif" + } + ] + }, { + make: "Netgear", + model: "JFS524", + fingerprints:[ + { + type: "image", + url: "/images/../settingsJFS524.gif" + } + ] + }, { + make: "Netgear", + model: "JFS524F", + fingerprints:[ + { + type: "image", + url: "/images/../settingsJFS524F.gif" + } + ] + }, { + make: "Netgear", + model: "JGS516", + fingerprints:[ + { + type: "image", + url: "/images/../settingsJGS516.gif" + } + ] + }, { + make: "Netgear", + model: "JGS524", + fingerprints:[ + { + type: "image", + url: "/images/../settingsJGS524.gif" + } + ] + }, { + make: "Netgear", + model: "JGS524F", + fingerprints:[ + { + type: "image", + url: "/images/../settingsJGS524F.gif" + } + ] + }, { + make: "Netgear", + model: "KWGR614", + fingerprints:[ + { + type: "image", + url: "/images/../settingsKWGR614.gif" + } + ] + }, { + make: "Netgear", + model: "ME101", + fingerprints:[ + { + type: "image", + url: "/images/../settingsME101.gif" + } + ] + }, { + make: "Netgear", + model: "ME102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsME102.gif" + } + ] + }, { + make: "Netgear", + model: "ME103", + fingerprints:[ + { + type: "image", + url: "/images/../settingsME103.gif" + } + ] + }, { + make: "Netgear", + model: "MR314", + fingerprints:[ + { + type: "image", + url: "/images/../settingsMR314.gif" + } + ] + }, { + make: "Netgear", + model: "MR814", + fingerprints:[ + { + type: "image", + url: "/images/../settingsMR814.gif" + } + ] + }, { + make: "Netgear", + model: "RH340", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRH340.gif" + } + ] + }, { + make: "Netgear", + model: "RH348", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRH348.gif" + } + ] + }, { + make: "Netgear", + model: "RM356", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRM356.gif" + } + ] + }, { + make: "Netgear", + model: "RO318", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRO318.gif" + } + ] + }, { + make: "Netgear", + model: "RP114", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRP114.gif" + } + ] + }, { + make: "Netgear", + model: "RP334", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRP334.gif" + } + ] + }, { + make: "Netgear", + model: "RP614", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRP614.gif" + } + ] + }, { + make: "Netgear", + model: "RT311", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRT311.gif" + } + ] + }, { + make: "Netgear", + model: "RT314", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRT314.gif" + } + ] + }, { + make: "Netgear", + model: "RT328", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRT328.gif" + } + ] + }, { + make: "Netgear", + model: "RT338", + fingerprints:[ + { + type: "image", + url: "/images/../settingsRT338.gif" + } + ] + }, { + make: "Netgear", + model: "WAB102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWAB102.gif" + } + ] + }, { + make: "Netgear", + model: "WAG102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWAG102.gif" + } + ] + }, { + make: "Netgear", + model: "WAG302", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWAG302.gif" + } + ] + }, { + make: "Netgear", + model: "WAGL102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWAGL102.gif" + } + ] + }, { + make: "Netgear", + model: "WAGR614", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWAGR614.gif" + } + ] + }, { + make: "Netgear", + model: "WG102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWG102.gif" + } + ] + }, { + make: "Netgear", + model: "WG111", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWG111.gif" + } + ] + }, { + make: "Netgear", + model: "WG111T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWG111T.gif" + } + ] + }, { + make: "Netgear", + model: "WG302", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWG302.gif" + } + ] + }, { + make: "Netgear", + model: "WG311", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWG311.gif" + } + ] + }, { + make: "Netgear", + model: "WG602", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWG602.gif" + } + ] + }, { + make: "Netgear", + model: "WGE101", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGE101.gif" + } + ] + }, { + make: "Netgear", + model: "WGE111", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGE111.gif" + } + ] + }, { + make: "Netgear", + model: "WGL102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGL102.gif" + } + ] + }, { + make: "Netgear", + model: "WGM124", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGM124.gif" + } + ] + }, { + make: "Netgear", + model: "WGR101", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGR101.gif" + } + ] + }, { + make: "Netgear", + model: "WGR614", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGR614.gif" + } + ] + }, { + make: "Netgear", + model: "WGT624", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGT624.gif" + } + ] + }, { + make: "Netgear", + model: "WGT624SC", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGT624SC.gif" + } + ] + }, { + make: "Netgear", + model: "WGT634U", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGT634U.gif" + } + ] + }, { + make: "Netgear", + model: "WGU624", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGU624.gif" + } + ] + }, { + make: "Netgear", + model: "WGX102", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWGX102.gif" + } + ] + }, { + make: "Netgear", + model: "WN121T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWN121T.gif" + } + ] + }, { + make: "Netgear", + model: "WN311B", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWN311B.gif" + } + ] + }, { + make: "Netgear", + model: "WN311T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWN311T.gif" + } + ] + }, { + make: "Netgear", + model: "WN511B", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWN511B.gif" + } + ] + }, { + make: "Netgear", + model: "WN511T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWN511T.gif" + } + ] + }, { + make: "Netgear", + model: "WN802T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWN802T.gif" + } + ] + }, { + make: "Netgear", + model: "WNR834B", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWNR834B.gif" + } + ] + }, { + make: "Netgear", + model: "WNR834M", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWNR834M.gif" + } + ] + }, { + make: "Netgear", + model: "WNR854T", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWNR854T.gif" + } + ] + }, { + make: "Netgear", + model: "WPN802", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWPN802.gif" + } + ] + }, { + make: "Netgear", + model: "WPN824", + fingerprints:[ + { + type: "image", + url: "/images/../settingsWPN824.gif" + } + ] + }, { + make: "Netgear", + model: "XM128", + fingerprints:[ + { + type: "image", + url: "/images/../settingsXM128.gif" + } + ] + }, { + make: "Sitecom", + model: "WL114", + fingerprints:[ + { + type: "image", + url: "/slogo.gif" + } + ] + }, { + make: "SurfinBird", + model: "313", + fingerprints:[ + { + type: "image", + url: "/images/help_p.gif" + } + ] + }, { + make: "SMC", + model: "7004ABR", + fingerprints:[ + { + type: "image", + url: "/images/logo.gif" + } + ] + }, { + make: "Thomson", + model: "Cable Modem A801", + fingerprints:[ + { + type: "image", + url: "/images/thomson.gif" + } + ] + }, { + make: "Vigor", + model: "2600V", + fingerprints:[ + { + type: "image", + url: "/images/logo1.jpg" + } + ] + }, { + make: "ZyXEL", + model: "Prestige 660H61", + fingerprints:[ + { + type: "image", + url: "/dslroutery/imgshop/full/NETZ1431.jpg" + } + ] + }, { + make: "ZyXEL", + model: "Zywall", + fingerprints:[ + { + type: "image", + url: "/images/Logo.gif" + } + ] + } +]; + +this.lan.db.manufacturers = { + Cisco: { + + }, + Linksys: { + default_addresses: [ + '192.168.0.1', '192.168.1.1' + ] + }, + Dlink: { + default_addresses: [ + '192.168.1.30', + '192.168.1.50' + ] + }, + Motorola: { + default_addresses: [ + '192.168.0.1' + ] + }, + Thomson: { + + } +}; + +}).call(window); diff --git a/build/lan.min.js b/build/lan.min.js index ad4c265..4333e4d 100644 --- a/build/lan.min.js +++ b/build/lan.min.js @@ -1,2 +1,2 @@ -/*! lan-js@0.2.0 2014-12-30 */ -(function(){var a=function(a,b){for(var c in b)a[c]=b[c];return a},b=function(a,b){for(var c=0;cf.TIMEOUT?void(b&&b("timeout",a)):0!==e.readyState?void(b&&b("up",a)):void setTimeout(h,c)};setTimeout(h,c)},this._sendImgRequest=function(b){var c=null,d=new Date,e=new Image,g=function(){return new Date-d},h=function(){return e?(e=null,clearTimeout(c),void(b&&b("up",g()))):void 0},i=function(){e&&(e=null,b&&b("timeout",g()))};c=setTimeout(i,f.TIMEOUT),e.onload=e.onerror=h,e.src=window.location.protocol+"//"+a}};f.TIMEOUT=2e3;var g=function(c){if(!c)throw"HostScan requests addresses param.";c.constructor!=Array&&(c=[c]);var d=[];this.start=function(e){e=e||{};for(var g=0,h=new Date,i=function(i){var j=g*a+i;if(!(j>=c.length)){var k=c[j],l=g;setTimeout(function(){var a=new f(k);a.fire(function(a,b){e.stream&&e.stream(k,a,b),d.push({address:k,state:a,duration:b}),d.length>=c.length&&e.complete&&(e.complete(d,new Date-h),e.complete=null)})},l*b)}};g*aj;j++)i(j);g++}}};g.start=function(a,b){new g(a).start(b)},lan.utils.merge(lan,{HostScan:g,HostProbe:f})}.call(window),function(){var a=function(a){var b=this,c=document.createElement("img");c.setAttribute("style",lan.utils.constants.HIDDEN_STYLE),document.body.appendChild(c);var d=a.url;a.base&&(d=a.base+d),this.fire=function(e){c.onload=function(){a.width||a.height?e(!(a.width&&c.width!==a.width||a.height&&c.height!==a.height),b):e(!0,b),b.cleanup()},c.onerror=function(){e(!1,b),b.cleanup()},c.src=d},this.cleanup=function(){c.onerror=c.onload=null,c&&(c.parentNode&&c.parentNode.removeChild(c),c=null)}},b=function(a){var b=this,c=null,d=null,e=null;e=lan.utils.createIframe(),e.contentDocument.write(""+a.html+""),document.body.appendChild(e),this.fire=function(f){c=f;var g=document.createElement("link");g.setAttribute("href",a.url),e.contentDocument.body.appendChild(g),d=setInterval(b._poll,b.constructor.POLL_INTERVAL)},this.cleanup=function(){e&&(e.parentNode&&e.parentNode.removeChild(e),e=null),d&&(clearInterval(d),d=null),c=null},this._poll=function(){var d=e.contentDocument.getElementById(a.id);if(d){for(var f in styles)if(d.style[f]!==styles[f])return;c&&c(!0,this),b.cleanup()}}};b.POLL_INTERVAL=10;var c=function(a){var b=null,c=this;b=lan.utils.createIframe(),this.fire=function(d){var e=document.createElement("script");e.setAttribute("type","text/javascript"),e.onload=function(){var e=!0;a.expression&&b.contentWindow.eval(a.expression)&&(e=!1),d&&d(e,c),c.cleanup()},e.onerror=function(){d&&d(!1,c),c.cleanup()},e.setAttribute("src",a.url),b.contentDocument.body.appendChild(e)},this.cleanup=function(){b&&(b.parentNode&&b.parentNode.removeChild(b),b=null)}};c.POLL_INTERVAL=10;var d=function(a,b,c){lan.utils.merge(this,c),lan.utils.merge(this,b),this.check=function(b,d){var e=this.constructor.PROBES[a];return e?void new e(lan.utils.merge(c,{base:b.base})).fire(d):(d&&d(!1),console.log("Error: invalid type '"+(a||"")+"'"),!1)},this.toString=function(){return(this.make||"")+" "+(this.model||"")}};d.PROBES={image:a,css:b,js:c};var e=function(a){if(!a)throw"DeviceScan requests addresses param.";a.constructor!=Array&&(a=[a]),this.start=function(b){b=b||{};var c=b.devices||lan.db&&lan.db.devices||[],e=[];lan.utils.each(c,function(a){lan.utils.each(a.fingerprints,function(b){e.push(new d(b.type,a,b))})});var f=new lan.HostScan(a);f.start({stream:function(a,c,d){"up"==c?(b.hostup&&b.hostup(a,c,d),lan.utils.each(e,function(c){c.check({base:"http://"+a},function(d){d&&b.found?b.found(a,c):!d&&b.failed&&b.failed(a,c)})})):b.hostdown&&b.hostdown(a,c,d)},complete:function(a){b.complete&&b.complete(a)}})}};e.start=function(a,b){new e(a).start(b)},lan.utils.merge(lan,{DeviceScan:e,DeviceFingerprint:d})}.call(window); \ No newline at end of file +/*! lan-js@0.2.0 2019-05-28 */ +(function(){var a=function(a,b){for(var c in b)a[c]=b[c];return a},b=function(a,b){for(var c=0;cf.TIMEOUT){try{e.close()}catch(g){}return void(b&&b("timeout",a))}return 0!==e.readyState?void(b&&b("up",a)):void setTimeout(h,c)};setTimeout(h,c)},this._sendImgRequest=function(b){var c=null,d=new Date,e=new Image,g=function(){return new Date-d},h=function(){return e?(e=null,clearTimeout(c),void(b&&b("up",g()))):void 0},i=function(){e&&(e=null,b&&b("timeout",g()))};c=setTimeout(i,f.TIMEOUT),e.onload=e.onerror=h,e.src=window.location.protocol+"//"+a}};f.TIMEOUT=2e3;var g=function(c,d){if(!c)throw"HostScan requests addresses param.";c.constructor!=Array&&(c=[c]),d=d||{};var e=[],g=d.batchSize||a,h=d.batchDelay||b;this.start=function(a){a=a||{};for(var b=0,d=new Date,i=function(i){var j=b*g+i;if(!(j>=c.length)){var k=c[j],l=b;setTimeout(function(){var b=new f(k);b.fire(function(b,f){a.stream&&a.stream(k,b,f),e.push({address:k,state:b,duration:f}),e.length>=c.length&&a.complete&&(a.complete(e,new Date-d),a.complete=null)})},l*h)}};b*gj;j++)i(j);b++}}};g.start=function(a,b){new g(a).start(b)},lan.utils.merge(lan,{HostScan:g,HostProbe:f})}.call(window),function(){var a=function(a){var b=this,c=document.createElement("img");c.setAttribute("style",lan.utils.constants.HIDDEN_STYLE),document.body.appendChild(c);var d=a.url;a.base&&(d=a.base+d),this.fire=function(e){c.onload=function(){a.width||a.height?e(!(a.width&&c.width!==a.width||a.height&&c.height!==a.height),b):e(!0,b),b.cleanup()},c.onerror=function(){e(!1,b),b.cleanup()},c.src=d},this.cleanup=function(){c.onerror=c.onload=null,c&&(c.parentNode&&c.parentNode.removeChild(c),c=null)}},b=function(a){var b=this,c=null,d=null,e=null;e=lan.utils.createIframe(),e.contentDocument.write(""+a.html+""),document.body.appendChild(e),this.fire=function(f){c=f;var g=document.createElement("link");g.setAttribute("href",a.url),e.contentDocument.body.appendChild(g),d=setInterval(b._poll,b.constructor.POLL_INTERVAL)},this.cleanup=function(){e&&(e.parentNode&&e.parentNode.removeChild(e),e=null),d&&(clearInterval(d),d=null),c=null},this._poll=function(){var d=e.contentDocument.getElementById(a.id);if(d){for(var f in styles)if(d.style[f]!==styles[f])return;c&&c(!0,this),b.cleanup()}}};b.POLL_INTERVAL=10;var c=function(a){var b=null,c=this;b=lan.utils.createIframe(),this.fire=function(d){var e=document.createElement("script");e.setAttribute("type","text/javascript"),e.onload=function(){var e=!0;a.expression&&b.contentWindow.eval(a.expression)&&(e=!1),d&&d(e,c),c.cleanup()},e.onerror=function(){d&&d(!1,c),c.cleanup()},e.setAttribute("src",a.url),b.contentDocument.body.appendChild(e)},this.cleanup=function(){b&&(b.parentNode&&b.parentNode.removeChild(b),b=null)}};c.POLL_INTERVAL=10;var d=function(a,b,c){lan.utils.merge(this,c),lan.utils.merge(this,b),this.check=function(b,d){var e=this.constructor.PROBES[a];return e?void new e(lan.utils.merge(c,{base:b.base})).fire(d):(d&&d(!1),console.log("Error: invalid type '"+(a||"")+"'"),!1)},this.toString=function(){return(this.make||"")+" "+(this.model||"")}};d.PROBES={image:a,css:b,js:c};var e=function(a){if(!a)throw"DeviceScan requests addresses param.";a.constructor!=Array&&(a=[a]),this.start=function(b){b=b||{};var c=b.devices||lan.db&&lan.db.devices||[],e=[];lan.utils.each(c,function(a){lan.utils.each(a.fingerprints,function(b){e.push(new d(b.type,a,b))})});var f=new lan.HostScan(a);f.start({stream:function(a,c,d){"up"==c?(b.hostup&&b.hostup(a,c,d),lan.utils.each(e,function(c,d){c.check({base:"http://"+a},function(d){d&&b.found?b.found(a,c):!d&&b.failed&&b.failed(a,c)})})):b.hostdown&&b.hostdown(a,c,d)},complete:function(a){b.complete&&b.complete(a)}})}};e.start=function(a,b){new e(a).start(b)},lan.utils.merge(lan,{DeviceScan:e,DeviceFingerprint:d})}.call(window),function(){function a(a,b){function c(){function c(c){c in f||c.match(/^\d+\.\d+\.\d+\.\d+$/)&&(f[c]=!0,a.waitForNext?(g&&clearTimeout(g),g=setTimeout(function(){var a=Object.keys(f).filter(function(a){return f[a]});b(!1,a)},a.waitForNext)):b(!1,c))}function e(a){var b,d,e;a.split("\r\n").forEach(function(a){~a.indexOf("a=candidate")?(b=a.split(" "),d=b[4],e=b[7],"host"===e&&c(d)):~a.indexOf("c=")&&(b=a.split(" "),d=b[2],c(d))})}var f={"0.0.0.0":!1},g=null,h=new d({iceServers:[]});h.createDataChannel("",{reliable:!1}),h.onicecandidate=function(a){a.candidate&&e("a="+a.candidate.candidate)},h.createOffer(function(a){e(a.sdp),h.setLocalDescription(a)},function(a){b("SDP Offer Failed")})}"function"==typeof a&&(b=a,a={}),"waitForNext"in a||(a.waitForNext=!1);var d=window.webkitRTCPeerConnection||window.mozRTCPeerConnection||window.RTCPeerConnection;d?c():setTimeout(function(){b("RTCPeerConnection is not supported by this browser")})}lan.utils.merge(lan,{IpDiscovery:{start:a}})}.call(window),function(){this.lan=this.lan||{},this.lan.db=this.lan.db||{},this.lan.db.devices=[{make:"Cisco",model:"Switch",fingerprints:[{type:"image",url:"/images/cisco_logo_header.png",width:62,height:33}]},{make:"2Wire",model:"1000 Series",fingerprints:[{type:"image",url:"/base/web/def/def/images/nav_sl_logo.gif"}]},{make:"Polycom",model:"Unknown",fingerprints:[{type:"image",url:"/images/logo.png",width:190,height:56}]},{make:"Epson",model:"EpsonNet WebAssist",fingerprints:[{type:"image",url:"/epsonlogo.gif",width:79,height:28}]},{make:"DLink",model:"dgl4100",fingerprints:[{type:"image",url:"/html/images/dgl4100.jpg"}]},{make:"DLink",model:"dgl4300",fingerprints:[{type:"image",url:"/html/images/dgl4300.jpg"}]},{make:"DLink",model:"di524",fingerprints:[{type:"image",url:"/html/images/di524.jpg"}]},{make:"DLink",model:"di624",fingerprints:[{type:"image",url:"/html/images/di624.jpg"}]},{make:"DLink",model:"di624s",fingerprints:[{type:"image",url:"/html/images/di624s.jpg"}]},{make:"DLink",model:"di724gu",fingerprints:[{type:"image",url:"/html/images/di724gu.jpg"}]},{make:"DLink",model:"dilb604",fingerprints:[{type:"image",url:"/html/images/dilb604.jpg"}]},{make:"DLink",model:"dir130",fingerprints:[{type:"image",url:"/html/images/dir130.jpg"}]},{make:"DLink",model:"dir330",fingerprints:[{type:"image",url:"/html/images/dir330.jpg"}]},{make:"DLink",model:"dir450",fingerprints:[{type:"image",url:"/html/images/dir450.jpg"}]},{make:"DLink",model:"dir451",fingerprints:[{type:"image",url:"/html/images/dir451.jpg"}]},{make:"DLink",model:"dir615",fingerprints:[{type:"image",url:"/html/images/dir615.jpg"}]},{make:"DLink",model:"dir625",fingerprints:[{type:"image",url:"/html/images/dir625.jpg"}]},{make:"DLink",model:"dir635",fingerprints:[{type:"image",url:"/html/images/dir635.jpg"}]},{make:"DLink",model:"dir655",fingerprints:[{type:"image",url:"/html/images/dir655.jpg"}]},{make:"DLink",model:"dir660",fingerprints:[{type:"image",url:"/html/images/dir660.jpg"}]},{make:"DLink",model:"ebr2310",fingerprints:[{type:"image",url:"/html/images/ebr2310.jpg"}]},{make:"DLink",model:"kr1",fingerprints:[{type:"image",url:"/html/images/kr1.jpg"}]},{make:"DLink",model:"tmg5240",fingerprints:[{type:"image",url:"/html/images/tmg5240.jpg"}]},{make:"DLink",model:"wbr1310",fingerprints:[{type:"image",url:"/html/images/wbr1310.jpg"}]},{make:"DLink",model:"wbr2310",fingerprints:[{type:"image",url:"/html/images/wbr2310.jpg"}]},{make:"DLink",model:"dsl604",fingerprints:[{type:"image",url:"/html/images/dsl604.jpg"}]},{make:"DLink",model:"dsl2320b",fingerprints:[{type:"image",url:"/html/images/dsl2320b.jpg"}]},{make:"DLink",model:"dsl2540b",fingerprints:[{type:"image",url:"/html/images/dsl2540b.jpg"}]},{make:"DLink",model:"dsl2640b",fingerprints:[{type:"image",url:"/html/images/dsl2640b.jpg"}]},{make:"DLink",model:"dsl302g",fingerprints:[{type:"image",url:"/html/images/dsl302g.jpg"}]},{make:"DLink",model:"dsl502g",fingerprints:[{type:"image",url:"/html/images/dsl502g.jpg"}]},{make:"DLink",model:"dgl3420",fingerprints:[{type:"image",url:"/html/images/dgl3420.jpg"}]},{make:"DLink",model:"dwl2100ap",fingerprints:[{type:"image",url:"/html/images/dwl2100ap.jpg"}]},{make:"DLink",model:"dwl2130ap",fingerprints:[{type:"image",url:"/html/images/dwl2130ap.jpg"}]},{make:"DLink",model:"dwl2200ap",fingerprints:[{type:"image",url:"/html/images/dwl2200ap.jpg"}]},{make:"DLink",model:"dwl2230ap",fingerprints:[{type:"image",url:"/html/images/dwl2230ap.jpg"}]},{make:"DLink",model:"dwl2700ap",fingerprints:[{type:"image",url:"/html/images/dwl2700ap.jpg"}]},{make:"DLink",model:"dwl3200ap",fingerprints:[{type:"image",url:"/html/images/dwl3200ap.jpg"}]},{make:"DLink",model:"dwl7100ap",fingerprints:[{type:"image",url:"/html/images/dwl7100ap.jpg"}]},{make:"DLink",model:"dwl7130ap",fingerprints:[{type:"image",url:"/html/images/dwl7130ap.jpg"}]},{make:"DLink",model:"dwl7200ap",fingerprints:[{type:"image",url:"/html/images/dwl7200ap.jpg"}]},{make:"DLink",model:"dwl7230ap",fingerprints:[{type:"image",url:"/html/images/dwl7230ap.jpg"}]},{make:"DLink",model:"dwl7700ap",fingerprints:[{type:"image",url:"/html/images/dwl7700ap.jpg"}]},{make:"DLink",model:"dwl8200ap",fingerprints:[{type:"image",url:"/html/images/dwl8200ap.jpg"}]},{make:"DLink",model:"dwl8220ap",fingerprints:[{type:"image",url:"/html/images/dwl8220ap.jpg"}]},{make:"DLink",model:"dwlag132",fingerprints:[{type:"image",url:"/html/images/dwlag132.jpg"}]},{make:"DLink",model:"dwlag530",fingerprints:[{type:"image",url:"/html/images/dwlag530.jpg"}]},{make:"DLink",model:"dwlag660",fingerprints:[{type:"image",url:"/html/images/dwlag660.jpg"}]},{make:"DLink",model:"dwlag700ap",fingerprints:[{type:"image",url:"/html/images/dwlag700ap.jpg"}]},{make:"DLink",model:"dwlg120",fingerprints:[{type:"image",url:"/html/images/dwlg120.jpg"}]},{make:"DLink",model:"dwlg122",fingerprints:[{type:"image",url:"/html/images/dwlg122.jpg"}]},{make:"DLink",model:"dwlg132",fingerprints:[{type:"image",url:"/html/images/dwlg132.jpg"}]},{make:"DLink",model:"dwlg510",fingerprints:[{type:"image",url:"/html/images/dwlg510.jpg"}]},{make:"DLink",model:"dwlg520",fingerprints:[{type:"image",url:"/html/images/dwlg520.jpg"}]},{make:"DLink",model:"dwlg520m",fingerprints:[{type:"image",url:"/html/images/dwlg520m.jpg"}]},{make:"DLink",model:"dwlg550",fingerprints:[{type:"image",url:"/html/images/dwlg550.jpg"}]},{make:"DLink",model:"dwlg630",fingerprints:[{type:"image",url:"/html/images/dwlg630.jpg"}]},{make:"DLink",model:"dwlg650",fingerprints:[{type:"image",url:"/html/images/dwlg650.jpg"}]},{make:"DLink",model:"dwlg650m",fingerprints:[{type:"image",url:"/html/images/dwlg650m.jpg"}]},{make:"DLink",model:"dwlg680",fingerprints:[{type:"image",url:"/html/images/dwlg680.jpg"}]},{make:"DLink",model:"dwlg700ap",fingerprints:[{type:"image",url:"/html/images/dwlg700ap.jpg"}]},{make:"DLink",model:"dwlg710",fingerprints:[{type:"image",url:"/html/images/dwlg710.jpg"}]},{make:"DLink",model:"dwlg730ap",fingerprints:[{type:"image",url:"/html/images/dwlg730ap.jpg"}]},{make:"DLink",model:"dwlg820",fingerprints:[{type:"image",url:"/html/images/dwlg820.jpg"}]},{make:"DLink",model:"wda1320",fingerprints:[{type:"image",url:"/html/images/wda1320.jpg"}]},{make:"DLink",model:"wda2320",fingerprints:[{type:"image",url:"/html/images/wda2320.jpg"}]},{make:"DLink",model:"wna1330",fingerprints:[{type:"image",url:"/html/images/wna1330.jpg"}]},{make:"DLink",model:"wna2330",fingerprints:[{type:"image",url:"/html/images/wna2330.jpg"}]},{make:"DLink",model:"wua1340",fingerprints:[{type:"image",url:"/html/images/wua1340.jpg"}]},{make:"DLink",model:"wua2340",fingerprints:[{type:"image",url:"/html/images/wua2340.jpg"}]},{make:"DLink",model:"DSL502T",fingerprints:[{type:"image",url:"/html/images/help_p.jpg"}]},{make:"DLink",model:"DSL524T",fingerprints:[{type:"image",url:"/html/images/device.gif"}]},{make:"Linksys",model:"WRT54GL",fingerprints:[{type:"image",url:"/WRT56GL.gif"}]},{make:"Linksys",model:"WRT54GC",fingerprints:[{type:"image",url:"/UI_Linksys.gif"}]},{make:"Linksys",model:"WRT54G",fingerprints:[{type:"image",url:"/WRT54G.gif"}]},{make:"Linksys",model:"WRT54GS",fingerprints:[{type:"image",url:"/UILinksys.gif"}]},{make:"Linksys",model:"WRT100",auth:"basic",fingerprints:[{type:"image",url:"/logo.gif",width:800,height:20}]},{make:"Linksys",model:"WRT110",auth:"basic",fingerprints:[{type:"image",url:"/logo.gif",width:800,height:300}]},{make:"Linksys",model:"WRT120N",auth:"basic",fingerprints:[{type:"image",url:"/logo.gif",width:800,height:300}]},{make:"Motorola",model:"SURFboard Gateway SBG6580",auth:"ip",fingerprints:[{type:"image",url:"/logo_new.gif",width:176,height:125}]},{make:"Netgear",model:"CG814WG",fingerprints:[{type:"image",url:"/images/../settingsCG814WG.gif"}]},{make:"Netgear",model:"CM212",fingerprints:[{type:"image",url:"/images/../settingsCM212.gif"}]},{make:"Netgear",model:"DG632",fingerprints:[{type:"image",url:"/images/../settingsDG632.gif"}]},{make:"Netgear",model:"DG632B",fingerprints:[{type:"image",url:"/images/../settingsDG632B.gif"}]},{make:"Netgear",model:"DG814",fingerprints:[{type:"image",url:"/images/../settingsDG814.gif"}]},{make:"Netgear",model:"DG824M",fingerprints:[{type:"image",url:"/images/../settingsDG824M.gif"}]},{make:"Netgear",model:"DG834",fingerprints:[{type:"image",url:"/images/../settingsDG834.gif"}]},{make:"Netgear",model:"DG834B",fingerprints:[{type:"image",url:"/images/../settingsDG834B.gif"}]},{make:"Netgear",model:"DG834G",fingerprints:[{type:"image",url:"/images/../settingsDG834G.gif"}]},{make:"Netgear",model:"DG834GB",fingerprints:[{type:"image",url:"/images/../settingsDG834GB.gif"}]},{make:"Netgear",model:"DG834GT",fingerprints:[{type:"image",url:"/images/../settingsDG834GT.gif"}]},{make:"Netgear",model:"DG834GTB",fingerprints:[{type:"image",url:"/images/../settingsDG834GTB.gif"}]},{make:"Netgear",model:"DG834GV",fingerprints:[{type:"image",url:"/images/../settingsDG834GV.gif"}]},{make:"Netgear",model:"dg834N",fingerprints:[{type:"image",url:"/images/../settingsdg834N.gif"}]},{make:"Netgear",model:"DG834PN",fingerprints:[{type:"image",url:"/images/../settingsDG834PN.gif"}]},{make:"Netgear",model:"DGFV338",fingerprints:[{type:"image",url:"/images/../settingsDGFV338.gif"}]},{make:"Netgear",model:"DM111P",fingerprints:[{type:"image",url:"/images/../settingsDM111P.gif"}]},{make:"Netgear",model:"DM602",fingerprints:[{type:"image",url:"/images/../settingsDM602.gif"}]},{make:"Netgear",model:"FM114P",fingerprints:[{type:"image",url:"/images/../settingsFM114P.gif"}]},{make:"Netgear",model:"FR114P",fingerprints:[{type:"image",url:"/images/../settingsFR114P.gif"}]},{make:"Netgear",model:"FR114W",fingerprints:[{type:"image",url:"/images/../settingsFR114W.gif"}]},{make:"Netgear",model:"FR314",fingerprints:[{type:"image",url:"/images/../settingsFR314.gif"}]},{make:"Netgear",model:"FR318",fingerprints:[{type:"image",url:"/images/../settingsFR318.gif"}]},{make:"Netgear",model:"FR328S",fingerprints:[{type:"image",url:"/images/../settingsFR328S.gif"}]},{make:"Netgear",model:"FV318",fingerprints:[{type:"image",url:"/images/../settingsFV318.gif"}]},{make:"Netgear",model:"FVG318",fingerprints:[{type:"image",url:"/images/../settingsFVG318.gif"}]},{make:"Netgear",model:"FVL328",fingerprints:[{type:"image",url:"/images/../settingsFVL328.gif"}]},{make:"Netgear",model:"FVM318",fingerprints:[{type:"image",url:"/images/../settingsFVM318.gif"}]},{make:"Netgear",model:"FVS114",fingerprints:[{type:"image",url:"/images/../settingsFVS114.gif"}]},{make:"Netgear",model:"FVS124G",fingerprints:[{type:"image",url:"/images/../settingsFVS124G.gif"}]},{make:"Netgear",model:"FVS318",fingerprints:[{type:"image",url:"/images/../settingsFVS318.gif"}]},{make:"Netgear",model:"FVS328",fingerprints:[{type:"image",url:"/images/../settingsFVS328.gif"}]},{make:"Netgear",model:"FVS338",fingerprints:[{type:"image",url:"/images/../settingsFVS338.gif"}]},{make:"Netgear",model:"FVX538",fingerprints:[{type:"image",url:"/images/../settingsFVX538.gif"}]},{make:"Netgear",model:"FWAG114",fingerprints:[{type:"image",url:"/images/../settingsFWAG114.gif"}]},{make:"Netgear",model:"FWG114P",fingerprints:[{type:"image",url:"/images/../settingsFWG114P.gif"}]},{make:"Netgear",model:"GA302T",fingerprints:[{type:"image",url:"/images/../settingsGA302T.gif"}]},{make:"Netgear",model:"GA311",fingerprints:[{type:"image",url:"/images/../settingsGA311.gif"}]},{make:"Netgear",model:"GA511",fingerprints:[{type:"image",url:"/images/../settingsGA511.gif"}]},{make:"Netgear",model:"GA620",fingerprints:[{type:"image",url:"/images/../settingsGA620.gif"}]},{make:"Netgear",model:"GA621",fingerprints:[{type:"image",url:"/images/../settingsGA621.gif"}]},{make:"Netgear",model:"GA622T",fingerprints:[{type:"image",url:"/images/../settingsGA622T.gif"}]},{make:"Netgear",model:"HE102",fingerprints:[{type:"image",url:"/images/../settingsHE102.gif"}]},{make:"Netgear",model:"HR314",fingerprints:[{type:"image",url:"/images/../settingsHR314.gif"}]},{make:"Netgear",model:"JFS516",fingerprints:[{type:"image",url:"/images/../settingsJFS516.gif"}]},{make:"Netgear",model:"JFS524",fingerprints:[{type:"image",url:"/images/../settingsJFS524.gif"}]},{make:"Netgear",model:"JFS524F",fingerprints:[{type:"image",url:"/images/../settingsJFS524F.gif"}]},{make:"Netgear",model:"JGS516",fingerprints:[{type:"image",url:"/images/../settingsJGS516.gif"}]},{make:"Netgear",model:"JGS524",fingerprints:[{type:"image",url:"/images/../settingsJGS524.gif"}]},{make:"Netgear",model:"JGS524F",fingerprints:[{type:"image",url:"/images/../settingsJGS524F.gif"}]},{make:"Netgear",model:"KWGR614",fingerprints:[{type:"image",url:"/images/../settingsKWGR614.gif"}]},{make:"Netgear",model:"ME101",fingerprints:[{type:"image",url:"/images/../settingsME101.gif"}]},{make:"Netgear",model:"ME102",fingerprints:[{type:"image",url:"/images/../settingsME102.gif"}]},{make:"Netgear",model:"ME103",fingerprints:[{type:"image",url:"/images/../settingsME103.gif"}]},{make:"Netgear",model:"MR314",fingerprints:[{type:"image",url:"/images/../settingsMR314.gif"}]},{make:"Netgear",model:"MR814",fingerprints:[{type:"image",url:"/images/../settingsMR814.gif"}]},{make:"Netgear",model:"RH340",fingerprints:[{type:"image",url:"/images/../settingsRH340.gif"}]},{make:"Netgear",model:"RH348",fingerprints:[{type:"image",url:"/images/../settingsRH348.gif"}]},{make:"Netgear",model:"RM356",fingerprints:[{type:"image",url:"/images/../settingsRM356.gif"}]},{make:"Netgear",model:"RO318",fingerprints:[{type:"image",url:"/images/../settingsRO318.gif"}]},{make:"Netgear",model:"RP114",fingerprints:[{type:"image",url:"/images/../settingsRP114.gif"}]},{make:"Netgear",model:"RP334",fingerprints:[{type:"image",url:"/images/../settingsRP334.gif"}]},{make:"Netgear",model:"RP614",fingerprints:[{type:"image",url:"/images/../settingsRP614.gif"}]},{make:"Netgear",model:"RT311",fingerprints:[{type:"image",url:"/images/../settingsRT311.gif"}]},{make:"Netgear",model:"RT314",fingerprints:[{type:"image",url:"/images/../settingsRT314.gif"}]},{make:"Netgear",model:"RT328",fingerprints:[{type:"image",url:"/images/../settingsRT328.gif"}]},{make:"Netgear",model:"RT338",fingerprints:[{type:"image",url:"/images/../settingsRT338.gif"}]},{make:"Netgear",model:"WAB102",fingerprints:[{type:"image",url:"/images/../settingsWAB102.gif"}]},{make:"Netgear",model:"WAG102",fingerprints:[{type:"image",url:"/images/../settingsWAG102.gif"}]},{make:"Netgear",model:"WAG302",fingerprints:[{type:"image",url:"/images/../settingsWAG302.gif"}]},{make:"Netgear",model:"WAGL102",fingerprints:[{type:"image",url:"/images/../settingsWAGL102.gif"}]},{make:"Netgear",model:"WAGR614",fingerprints:[{type:"image",url:"/images/../settingsWAGR614.gif"}]},{make:"Netgear",model:"WG102",fingerprints:[{type:"image",url:"/images/../settingsWG102.gif"}]},{make:"Netgear",model:"WG111",fingerprints:[{type:"image",url:"/images/../settingsWG111.gif"}]},{make:"Netgear",model:"WG111T",fingerprints:[{type:"image",url:"/images/../settingsWG111T.gif"}]},{make:"Netgear",model:"WG302",fingerprints:[{type:"image",url:"/images/../settingsWG302.gif"}]},{make:"Netgear",model:"WG311",fingerprints:[{type:"image",url:"/images/../settingsWG311.gif"}]},{make:"Netgear",model:"WG602",fingerprints:[{type:"image",url:"/images/../settingsWG602.gif"}]},{make:"Netgear",model:"WGE101",fingerprints:[{type:"image",url:"/images/../settingsWGE101.gif"}]},{make:"Netgear",model:"WGE111",fingerprints:[{type:"image",url:"/images/../settingsWGE111.gif"}]},{make:"Netgear",model:"WGL102",fingerprints:[{type:"image",url:"/images/../settingsWGL102.gif"}]},{make:"Netgear",model:"WGM124",fingerprints:[{type:"image",url:"/images/../settingsWGM124.gif"}]},{make:"Netgear",model:"WGR101",fingerprints:[{type:"image",url:"/images/../settingsWGR101.gif"}]},{make:"Netgear",model:"WGR614",fingerprints:[{type:"image",url:"/images/../settingsWGR614.gif"}]},{make:"Netgear",model:"WGT624",fingerprints:[{type:"image",url:"/images/../settingsWGT624.gif"}]},{make:"Netgear",model:"WGT624SC",fingerprints:[{type:"image",url:"/images/../settingsWGT624SC.gif"}]},{make:"Netgear",model:"WGT634U",fingerprints:[{type:"image",url:"/images/../settingsWGT634U.gif"}]},{make:"Netgear",model:"WGU624",fingerprints:[{type:"image",url:"/images/../settingsWGU624.gif"}]},{make:"Netgear",model:"WGX102",fingerprints:[{type:"image",url:"/images/../settingsWGX102.gif"}]},{make:"Netgear",model:"WN121T",fingerprints:[{type:"image",url:"/images/../settingsWN121T.gif"}]},{make:"Netgear",model:"WN311B",fingerprints:[{type:"image",url:"/images/../settingsWN311B.gif"}]},{make:"Netgear",model:"WN311T",fingerprints:[{type:"image",url:"/images/../settingsWN311T.gif"}]},{make:"Netgear",model:"WN511B",fingerprints:[{type:"image",url:"/images/../settingsWN511B.gif"}]},{make:"Netgear",model:"WN511T",fingerprints:[{type:"image",url:"/images/../settingsWN511T.gif"}]},{make:"Netgear",model:"WN802T",fingerprints:[{type:"image",url:"/images/../settingsWN802T.gif"}]},{make:"Netgear",model:"WNR834B",fingerprints:[{type:"image",url:"/images/../settingsWNR834B.gif"}]},{make:"Netgear",model:"WNR834M",fingerprints:[{type:"image",url:"/images/../settingsWNR834M.gif"}]},{make:"Netgear",model:"WNR854T",fingerprints:[{type:"image",url:"/images/../settingsWNR854T.gif"}]},{make:"Netgear",model:"WPN802",fingerprints:[{type:"image",url:"/images/../settingsWPN802.gif"}]},{make:"Netgear",model:"WPN824",fingerprints:[{type:"image",url:"/images/../settingsWPN824.gif"}]},{make:"Netgear",model:"XM128",fingerprints:[{type:"image",url:"/images/../settingsXM128.gif"}]},{make:"Sitecom",model:"WL114",fingerprints:[{type:"image",url:"/slogo.gif"}]},{make:"SurfinBird",model:"313",fingerprints:[{type:"image",url:"/images/help_p.gif"}]},{make:"SMC",model:"7004ABR",fingerprints:[{type:"image",url:"/images/logo.gif"}]},{make:"Thomson",model:"Cable Modem A801",fingerprints:[{type:"image",url:"/images/thomson.gif"}]},{make:"Vigor",model:"2600V",fingerprints:[{type:"image",url:"/images/logo1.jpg"}]},{make:"ZyXEL",model:"Prestige 660H61",fingerprints:[{type:"image",url:"/dslroutery/imgshop/full/NETZ1431.jpg"}]},{make:"ZyXEL",model:"Zywall",fingerprints:[{type:"image",url:"/images/Logo.gif"}]}],this.lan.db.manufacturers={Cisco:{},Linksys:{default_addresses:["192.168.0.1","192.168.1.1"]},Dlink:{default_addresses:["192.168.1.30","192.168.1.50"]},Motorola:{default_addresses:["192.168.0.1"]},Thomson:{}}}.call(window); \ No newline at end of file diff --git a/build/lan.min.js.gz b/build/lan.min.js.gz deleted file mode 100644 index ee32741..0000000 Binary files a/build/lan.min.js.gz and /dev/null differ diff --git a/examples/dashboard.html b/examples/dashboard.html new file mode 100644 index 0000000..138a2ba --- /dev/null +++ b/examples/dashboard.html @@ -0,0 +1,71 @@ + + + + + + + + + + diff --git a/src/db.js b/src/db.js index b75f156..082a95d 100644 --- a/src/db.js +++ b/src/db.js @@ -39,12 +39,14 @@ this.lan.db.devices = [ } ] }, { - make: "Cisco", - model: "2600", + make: "Polycom", + model: "Unknown", fingerprints:[ { type: "image", - url: "/images/logo.png" + url: "/images/logo.png", + width: 190, + height: 56 } ] }, { diff --git a/src/device_scan.js b/src/device_scan.js index af9b6d8..cb78d43 100644 --- a/src/device_scan.js +++ b/src/device_scan.js @@ -214,7 +214,7 @@ var DeviceFingerprint = function(type, device, fingerprint) { } }; - + /* * Patch toString() for a nice debug display * @return [String] serialized representation diff --git a/src/host_scan.js b/src/host_scan.js index 1b7fb44..e0b45c2 100644 --- a/src/host_scan.js +++ b/src/host_scan.js @@ -60,7 +60,7 @@ var HostProbe = function(address) { } }; - /* + /* * @param [Number] port the port to check * @return [Boolean] websockets spec disallows connection on port */ @@ -164,7 +164,7 @@ var HostScan = function(addresses, opts) { var startTime = new Date(); // sends the probes - var sendProbe = function(i) { + var sendProbe = function(i) { var addrIdx = batchIdx * batchSize + i; if (addrIdx >= addresses.length) return; var addr = addresses[addrIdx]; diff --git a/src/ip_discovery.js b/src/ip_discovery.js new file mode 100644 index 0000000..adaa24c --- /dev/null +++ b/src/ip_discovery.js @@ -0,0 +1,101 @@ +/* + * ip_discovery.js: Attempts to discover your own IP address using HTML5 WebRTC APIs. + * + * @author joev + */ + +(function(){ + +function discoverIps(opts, callback) { + + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } + + if (!('waitForNext' in opts)) { + opts.waitForNext = false; // ms + } + + /* + * based heavily on the beef implementation here: + * https://github.com/beefproject/beef/wiki/Module:-Get-Internal-IP-WebRTC + */ + + var RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection || window.RTCPeerConnection; + function run() { + var addrs = { "0.0.0.0": false }; + var pendingTimeout = null; + + // Establish a connection with ICE / relay servers - in this instance: NONE + var rtc = new RTCPeerConnection({iceServers: []}); + rtc.createDataChannel('', {reliable:false}); + + // Upon an ICE candidate being found + // Grep the SDP data for IP address data + rtc.onicecandidate = function (evt) { + if (evt.candidate) grepSDP("a="+evt.candidate.candidate); + }; + + // Create an SDP offer + rtc.createOffer(function (offerDesc) { + grepSDP(offerDesc.sdp); + rtc.setLocalDescription(offerDesc); + }, function (e) { callback("SDP Offer Failed"); }); + + function processIPs(newAddr) { + if (newAddr in addrs) return; + if (!newAddr.match(/^\d+\.\d+\.\d+\.\d+$/)) return; + else addrs[newAddr] = true; + + if (opts.waitForNext) { + if (pendingTimeout) clearTimeout(pendingTimeout); + pendingTimeout = setTimeout(function() { + var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; }); + callback(false, displayAddrs); + }, opts.waitForNext); + } else { + callback(false, newAddr); + } + } + + function grepSDP(sdp) { + var parts, addr, type; + 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 + parts = line.split(' '); // http://tools.ietf.org/html/rfc5245#section-15.1 + addr = parts[4]; + type = parts[7]; + if (type === 'host') processIPs(addr); + } else if (~line.indexOf("c=")) { // http://tools.ietf.org/html/rfc4566#section-5.7 + parts = line.split(' '); + addr = parts[2]; + processIPs(addr); + } + }); + } + } + + if (RTCPeerConnection) { + run(); + } else { + setTimeout(function () { // avoid zalgo's reach + callback("RTCPeerConnection is not supported by this browser"); + }); + } + +} + + +/* + * exports + */ +lan.utils.merge(lan, { + IpDiscovery: { + start: discoverIps + } +}); + +}).call(window); \ No newline at end of file