├── .gitignore ├── LICENSE ├── README.md ├── bin.js ├── example.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | sandbox.js 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Mathias Buus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ls-lan 2 | 3 | List all IPs on the local LAN 4 | 5 | ``` 6 | npm install -g ls-lan 7 | ``` 8 | 9 | ## Usage 10 | 11 | Simply lists all IPs on the local LAN. 12 | Currently only works on macOS, but PR support for other OS'es 13 | 14 | ```sh 15 | ls-lan # Prints a list of IPs found on the local LAN 16 | ``` 17 | 18 | There is a js API available as well 19 | 20 | ```js 21 | const ls = require('ls-lan') 22 | 23 | ls(function (err, ips) { 24 | if (err) throw err 25 | console.log(ips.join('\n')) 26 | }) 27 | ``` 28 | 29 | ## License 30 | 31 | MIT 32 | -------------------------------------------------------------------------------- /bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const ls = require('./') 4 | const { EOL } = require('os') 5 | 6 | ls(function (err, ips) { 7 | if (err) throw err 8 | console.log(ips.join(EOL)) 9 | }) 10 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | const ls = require('./') 2 | 3 | ls(function (err, ips) { 4 | if (err) throw err 5 | console.log(ips) 6 | }) 7 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { exec } = require('child_process') 2 | 3 | module.exports = ls 4 | 5 | function ls (cb) { 6 | exec(`arp -a | sed 's|.*(||' | sed 's|).*||'`, function (err, out) { 7 | if (err) return cb(err) 8 | 9 | const lines = out.trim().split('\n') 10 | cb(null, lines) 11 | }) 12 | } 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ls-lan", 3 | "version": "1.0.0", 4 | "description": "List all IPs on the local LAN", 5 | "main": "index.js", 6 | "dependencies": {}, 7 | "devDependencies": { 8 | "standard": "^12.0.1" 9 | }, 10 | "scripts": { 11 | "test": "standard" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/mafintosh/ls-lan.git" 16 | }, 17 | "bin": { 18 | "ls-lan": "./bin.js" 19 | }, 20 | "author": "Mathias Buus (@mafintosh)", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/mafintosh/ls-lan/issues" 24 | }, 25 | "homepage": "https://github.com/mafintosh/ls-lan" 26 | } 27 | --------------------------------------------------------------------------------