Skip to content

Commit

Permalink
feat: check for internet connectivity in firewall check
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronm-2112 committed Oct 10, 2024
1 parent efddf38 commit ba37848
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/renderer/src/scripts/check-firewall/checkFirewall.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ import axios from "axios";
* Returns: true if the client is blocked by an external firewall, false otherwise.
*/
export const clientBlockedByExternalFirewall = async (url) => {

// if the user doesnt have an internet connection they are not blocked by a firewall
// A simplification but we check for internet elsewhere so this is okay here.
let internetConnection = navigator.onLine;
if (!internetConnection) {
return false;
}

// check that the client can make an api request to Pennsieve's public API
//make an axios request to this public endpoint: https://api.pennsieve.io/discover/datasets
//if the request fails, the client is blocked by an external firewall
try {
console.log("Checking");
await axios.get(url);
return true;
return false;
} catch (error) {
return true;
}
Expand Down

0 comments on commit ba37848

Please sign in to comment.