Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 12, 2020
1 parent 78c75ae commit da7616b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const {parse, parseCIDR} = require('ipaddr.js');
function findIp(gateway) {
const gatewayIp = parse(gateway);

// Look for the matching interface in all local interfaces
for (const addrs of Object.values(networkInterfaces())) {
for (const addr of addrs) {
const prefix = parse(addr.netmask).prefixLengthFromSubnetMask();
const net = parseCIDR(`${addr.address}/${prefix}`);
// Look for the matching interface in all local interfaces.
for (const addresses of Object.values(networkInterfaces())) {
for (const address of addresses) {
const prefix = parse(address.netmask).prefixLengthFromSubnetMask();
const net = parseCIDR(`${address.address}/${prefix}`);

if (net[0] && net[0].kind() === gatewayIp.kind() && gatewayIp.match(net)) {
return net[0].toString();
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"description": "Get your internal IP address",
"license": "MIT",
"repository": "sindresorhus/internal-ip",
"funding": "https://github.com/sindresorhus/internal-ip?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=10"
Expand Down Expand Up @@ -37,7 +38,7 @@
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.9.0",
"tsd": "^0.11.0",
"xo": "^0.25.3"
}
}
4 changes: 0 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

> Get your internal IP address

## Install

```
$ npm install internal-ip
```


## Usage

```js
Expand All @@ -34,14 +32,12 @@ The module returns the address of the internet-facing interface, as determined f

The module relies on operating systems tools. On Linux and Android, the `ip` command must be available, which depending on distribution might not be installed by default. It is usually provided by the `iproute2` package.


## Related

- [internal-ip-cli](https://github.com/sindresorhus/internal-ip-cli) - CLI for this module
- [public-ip](https://github.com/sindresorhus/public-ip) - Get your public IP address
- [default-gateway](https://github.com/silverwind/default-gateway) - Get your default gateway address


---

<div align="center">
Expand Down

0 comments on commit da7616b

Please sign in to comment.