Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove ip package dependency #43

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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