-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from fairdataihub/detect-firewall
feat: detect network interference between SODA and server and SODA and pennsieve
- Loading branch information
Showing
8 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
- main | ||
- staging | ||
- pre-staging | ||
- detect-firewall | ||
|
||
jobs: | ||
deploy-on-windows: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import axios from "axios"; | ||
import { clientError } from "../others/http-error-handler/error-handler"; | ||
|
||
/** | ||
* This function checks if the client is blocked by an external firewall. | ||
* Assumptions: The client is connected to the internet. | ||
* Returns: true if the client is blocked by an external firewall, false otherwise. | ||
*/ | ||
export const clientBlockedByExternalFirewall = async (url) => { | ||
// 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 { | ||
await axios.get(url); | ||
return false; | ||
} catch (error) { | ||
clientError(error); | ||
if (!error.response) { | ||
// the request was made but no response was received. May be a firewall issue or the client | ||
// may just need to wait to try again later. | ||
return true; | ||
} | ||
|
||
// there is not a firewall issue if we get an actual repsonse from the server | ||
return false; | ||
} | ||
}; | ||
|
||
let docsUrl = "https://docs.sodaforsparc.io/how-to/how-to-resolve-network-issues"; | ||
const copyClientIdToClipboard = () => { | ||
window.electron.ipcRenderer.invoke("clipboard-write", docsUrl, "clipboard"); | ||
}; | ||
|
||
const commonHTML = `<p style="text-align:left;">Please refer to the SODA documentation page on resolving this issue by either clicking <a href="https://docs.sodaforsparc.io/how-to/how-to-resolve-network-issues" target="_blank">here</a> or by copying the url to the documentation page with the copy icon below.</p> | ||
<div style="display:flex; margin:auto;"> | ||
<p style="margin-right: 10px;">${docsUrl}</p> | ||
<div><i class="fas fa-copy" id="copy-icon-firewall-docs" click=${copyClientIdToClipboard()}></i></div> | ||
</div>`; | ||
|
||
export const blockedMessage = ` | ||
<p style="text-align:left;">SODA is unable to reach Pennsieve. | ||
If this issue persists it is possible that your network is blocking access to Pennsieve from SODA. | ||
</p> | ||
${commonHTML}`; | ||
|
||
export const hostFirewallMessage = `<p text-align:left;>SODA is unable to communicate with its server. | ||
If this issue persists it is possible that your network is blocking access. | ||
</p> | ||
${commonHTML}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters