Skip to content

Commit

Permalink
Merge pull request #43 from IBM/saikumar1607-202406101342
Browse files Browse the repository at this point in the history
remove ip package dependency
  • Loading branch information
ibm-cloud-appconfiguration authored Jun 10, 2024
2 parents 5cf6810 + 037631d commit 3b20cf6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "package-lock.json|^.secrets.baseline$",
"lines": null
},
"generated_at": "2024-05-23T05:57:58Z",
"generated_at": "2024-06-10T13:44:36Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down
32 changes: 24 additions & 8 deletions lib/configurations/internal/Connectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Module to check the internet connectivity.
* @module Connectivity
*/
const internetAvailable = require('internet-available');
const dnsSocket = require('dns-socket');

/**
* It returns a promise that is fulfilled if there's internet, otherwise if there's no internet
Expand All @@ -29,14 +29,30 @@ const internetAvailable = require('internet-available');
*/
module.exports.checkInternet = function isConnected() {
return new Promise((resolve) => {
internetAvailable({

const socket = dnsSocket({
timeout: 5000,
retries: 2,
domainName: 'cloud.ibm.com',
}).then(() => {
resolve(true);
}).catch(() => {
resolve(false);
retries: 2
});

socket.query({
questions: [{
type: 'A',
name: 'cloud.ibm.com'
}]
}, 53, '8.8.8.8');

socket.on('response', () => {
socket.destroy(() => {
resolve(true);
});
});

socket.on('timeout', () => {
socket.destroy(() => {
resolve(false);
});
});

});
};
82 changes: 35 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ibm-appconfiguration-node-sdk",
"version": "0.7.5",
"version": "0.7.6",
"description": "IBM Cloud App Configuration Node.js SDK",
"main": "./lib/AppConfiguration.js",
"scripts": {
Expand All @@ -17,9 +17,9 @@
},
"dependencies": {
"chalk": "^4.1.0",
"dns-socket": "^4.2.2",
"events": "^3.2.0",
"ibm-cloud-sdk-core": "^4.3.1",
"internet-available": "^1.0.0",
"murmurhash": "^2.0.0",
"path": "^0.12.7",
"websocket": "^1.0.33"
Expand Down

0 comments on commit 3b20cf6

Please sign in to comment.