Created
November 18, 2021 21:07
-
-
Save Oniicode/7320fb778c5a67adcf0966a5ef829dbd to your computer and use it in GitHub Desktop.
Quick and dirty script to check if a web server host is connected to the internet using VPN
This file contains hidden or 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
| <?php | |
| $ip = file_get_contents("https://api.ipify.org/"); | |
| if(!isset($_GET["raw"])) | |
| echo "WAN IP from backend: " . $ip; | |
| else { | |
| echo $ip; | |
| return; | |
| } | |
| ?> | |
| <script> | |
| function httpGet(theUrl) | |
| { | |
| var xmlHttp = new XMLHttpRequest(); | |
| xmlHttp.open( "GET", theUrl, false ); // false for synchronous request | |
| xmlHttp.send( null ); | |
| return xmlHttp.responseText; | |
| } | |
| const ipclient = httpGet("https://api.ipify.org/"); | |
| const ipserver = httpGet("?raw"); | |
| const seemssafe = ipclient != ipserver; | |
| alert("Check: " + seemssafe + "\nIP from browser: " + ipclient + "\nIP from server: " + ipserver); | |
| window.history.back(); | |
| </script> | |
| <a href="/">Back Home</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment