Skip to content

Commit 0b50acd

Browse files
author
K.C.Ashish Kumar
committed
Enhancements to update the externalIP endpoint
1 parent 31e0141 commit 0b50acd

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ console.log(listOfIP);
3737
3838
let externalIP = require("@kcak11/myip/external");
3939
externalIP().then((data) => {
40-
console.log("External IP: " + data);
40+
console.log("External IP: " + data.myip);
41+
console.log("Country: " + data.country);
4142
});
4243
```
4344

4445
Output:
4546
```
4647
["xyz.pqr.a.b","xyz.pq.abc.def"]
4748
External IP: XXX.YY.ZZ.AAA
49+
Country: CC
4850
```
4951

5052
## License: [MIT License](https://mit-license.kcak11.com)
51-
© 2019 [kcak11.com](https://www.kcak11.com "Ashish's Web")
53+
© 2020 [kcak11.com](https://www.kcak11.com "Ashish's Web")

cli/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ require('../utils/io').blockInput();
5252
};
5353

5454
externalip().then((data)=>{
55-
let externalIP = chalk.bold(data);
55+
let externalIP = chalk.bold(data.myip);
56+
let country = chalk.bold(data.country);
5657
print(chalk.red.bgWhite(` ${formatter("External(public) IP: " + externalIP, {
5758
suffixPadding: true,
5859
length: BOX_SIZE + 1,
59-
extraPadding: externalIP.length - data.length
60+
extraPadding: externalIP.length - data.myip.length
61+
})}`));
62+
print(chalk.red.bgWhite(` ${formatter("Country: " + country, {
63+
suffixPadding: true,
64+
length: BOX_SIZE + 1,
65+
extraPadding: country.length - data.country.length
6066
})}`));
6167
print(EMPTY_LINE);
6268
endProg();

exec/external.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* Author: @kcak11
44
*
55
* The external IP information is fetched from:
6-
* https://whatismyipaddress.com (Thanks for the API)
6+
* https://cors.kcak11.com/?myip=yes
77
**/
88

99
const axios = require('axios');
1010

1111
module.exports = function(action) {
12-
let promise = axios.get("https://ipv4bot.whatismyipaddress.com/");
12+
let promise = axios.get("https://cors.kcak11.com/?myip=yes");
1313
return new Promise((resolve, reject)=>{
1414
promise.then((response)=>{
1515
resolve(response.data);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kcak11/myip",
3-
"version": "3.1.0",
3+
"version": "4.0.0",
44
"description": "A Utility to fetch IP Addresses",
55
"main": "./exec/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)