v2.65 - (January 27, 2024) - FIXED: Minor change for AMTM compliance purposes. :) v2.64 - (January 25, 2024) - MAJOR: I have made the difficult decision to sunset VPNMON-R2. After this version is made live, you will be prompted to consider upgrading to VPNMON-R3 when the script starts up. From the Setup Menu, you will see indicators that an in-place upgrade to R3 is available. The upgrade allows you to install VPNMON-R3 and keep VPNMON-R2 in place, or, you can install VPNMON-R3, and uninstall VPNMON-R2. You can continue running R2 as long as you want, but development/support will be shutting down in favor of R3. The R2 script will be removed from AMTM and replaced with R3. As of this version, new installs of VPNMON-R2 v2.64 won't be possible, and will recommend installation of VPNMON-R3. Thank you for all your support and encouragement throughout R2's run. It has been a wild ride! I hope R3 serves your needs and exceeds your expectations! - FIXED: Thanks to @salvo for identifying that the post-mount entry was not getting deleted after a VPNMON-R2 uninstall. Fixed! v2.63 - (November 4, 2023) - FIXED: Thanks to @TITAN and @Ripshod for reporting back about unknown operand errors visible on the display when multiple VPN slots were not being used. This was due to some erroneous code that was not taking into consideration that some of these values may have been null. Much appreciation for @Martinski and @Somewhereovertherainbow for their help and advice on creating a more optimized way of catching this! v2.62 - (October 2, 2023) - ADDED: Thanks to @salvo for suggesting a different approach at displaying and measuring the pings for the current VPN slot and the disconnected slots. I used this same logic any time a ping measurement is done (which is now pinging 3x and getting the average), which should make these values a little more accurate. Please note, the connected VPN slot continues to measure a ping across the tunnel. The disconnected slots measure a ping across the WAN to the specified VPN server. As expected, this method does delay the screen draw of the values across the screen, but annoyance is minimal in favor of more accuracy. ;) - FIXED: Added some more context in the logs when WAN0 and WAN1 receive a new city name. - FIXED: Checking for VPN slot error states (-1), and if any return with this value, then set them back to zero to avoid any on-screen errors. v2.59 - (June 24, 2023) - FIXED: Couple of items relating to ensuring Unbound resolver DNS IP would be correctly reflected on screen if any of the other VPN reset events were triggered. This could at times cause a reset looping issue. - FIXED: Optimizations and bugfixes v2.58 - (May 24, 2023) - ADDED: Building on the Unbound functionality, I've implemented another reset condition, in particular, if the Unbound public DNS Resolver IP is not the same at your public VPN IP. Thanks so much to @Somewhereovertherainbow for his amazing regex and awk skills to pull this query off with a dig command. You will now find a new item under the config menu to enable this feature, on page 2, item 18, and will ask if you want to enable an Unbound out-of-sync reset. In rare conditions (typically for anything messing with your iptables like skynet version updates, and whatnot, your Unbound public IP DNS Resolver may revert to your public WAN IP. This reset will force it to send its encrypted DNS traffic back over the VPN tunnel if it happens to go out-of-sync. If you are OK with your DNS Resolver IP being different than your Public VPN IP, simply don't enable this. - FIXED: Thanks to @Somewhereovertherainbow, he uncovered a more stable, preferred method to run CURL statements. This version of VPNMON-R2 has had all CURL statements modified per these suggestions! Thank you! - FIXED: Optimizations and bugfixes v2.55 - (May 14, 2023) - MAJOR: Added major functionality to integrate more closely with Unbound! Unbound allows you to become your own DNS resolver, so you don't have to rely on other DNS providers (like from your ISP, Google, Quad9, etc.), and helps somewhat with privacy - because who knows what they log on their end, right? ;) The downside with Unbound is that the traffic you generate for your own DNS lookups to root servers or other authoritative servers is not encrypted... which would allow your ISP (or others) to still snoop on your plaintext port 53 DNS queries. So here's the good news -- this Unbound modification (thanks to @Martineau/Swinson) forces all plaintext port 53 traffic that Unbound generates for DNS lookups over your VPN tunnel instead! This means your internet activity is even more secure from your ISP (or others) prying eyes. Please note, this is not an end-all-be-all fix to keep all DNS lookups private, but it certainly helps get you closer. This update will now require that Unbound is installed and running, and will download and/or apply other scripts to the following files: /jffs/scripts/nat-start /jffs/scripts/openvpn-event /jffs/scripts/post-mount /jffs/addons/unbound/unbound_DNS_via_OVPN.sh - NOTE: VPNMON-R2 does not play any role in manipulating Unbound or the associated scripts in any way... it continues to function as it normally does. Except now, as openvpn events fire off as VPN tunnels are disconnected or established, this will allow these scripts to work in harmony with each other to force Unbound traffic over the VPN tunnel. Playing with these scripts and modifications isn't for the feint of heart, and may take some serious troubleshooting skills to get it configured right if something doesn't work straight out of the gate. - ADDED: Per one of @Martineau's old suggestions in the threads, when enabling this feature in the configuration menu, I've also added a command in the POST-MOUNT file that will disable Unbounds's VPN binding upon a router reboot as a fail-safe so that DNS resolutions aren't impacted as they would still be trying to get out over a VPN tunnel that is no longer in existence. v2.53 - (April 25, 2023) - FIXED: Syntax fix that might have been causing a "bad number" bug when using the Lowest Ping setting with 1 or more VPN slots. Thanks to @alisou for the find! v2.52 - (March 27, 2023) - FIXED: Apparently the code that parsed the client slot description field wasn't as solid as I had hoped for, and thanks to @kuki68ster, was able to identify this issue. I have rolled back some of the functionality of pulling hostnames from description fields for those who are using custom entries in the description field. This should hopefully fully restore the ability to get load indications for NordVPN again. v2.51 - (March 26, 2023) - FIXED: Added some backwards capability back in for those who are manually setting their VPN slots, and not utilizing the new method that VPNMON-R2 uses in the VPN slot description field to read part of the NordVPN server hostname in order to do load checks. This will also hopefully add more backward compatibility for VPNMGR as well, since I believe it sets its own description field info for its own purposes. v2.50 - (March 26, 2023) - FIXED: Fixed a recommended servers variable tracking issue in part due to the introduction of AirVPN's similar feature, and getting it to co-exist with NordVPN. Thanks to @kuki68ster for flagging this! v2.49 - (March 26, 2023) - FIXED: Fixed a terminated quoted string error where I forgot to close a sting for one of the new options that writes itself to the config file. Thanks Gesa! v2.48 - (March 25, 2023) - MAJOR: We added another major VPN Provider -- AirVPN -- to the mix of compatible VPN services that play well with APIs, giving us the ability to use these for SuperRandom(r) functionality in the country (or countries) of your choice. Also, provides us with the ability to use the AirVPN Recommended Servers feature, for those who want their servers to stay closer or more optimized for speed. AirVPN gives us the same range of capabilities that NordVPN gives, including reporting on the current server Load, or resetting the connection if the load exceeds your specified amount... Also, the ability to whitelist your AirVPN servers in Skynet so they don't get blocked (as they so frequently do).... so, really happy to get this one added. Note: This assumes you have all (up to) 5 VPN slots configured and working with AirVPN config, using OpenVPN, TLS authentication & encryption - which is pretty much the standard out there. Thanks to @machinist for the ask! - MAJOR: Added the capability to reset your VPN connection or reboot your router using an external file! I find myself in a pickle at times, unable to access my devices on a subnet, and unable to control my router from remote due to a misconfiguration or because the VPN tunnel got borked up, preventing all our devices from getting out to the internet. I wanted to (selfishly) find a way to externally cause the router to reset its VPN connection, and in a worst-case scenario, reboot the router! Well, that is all now possible. Simply host a file off an internet accessible server, having one of the words "RESET", "REBOOT" or "NORMAL" on the first line of the file. With options on the 2nd page in the config, you can specify if you want to enable this feature, what the full URL path to this file is (example: https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/main/event.txt), and what kind of interval you want to use to check on this file. The next time VPNMON-R2 checks the file, it will act on one of these commands! I've added an indicator to the top of the UI if this feature is enabled, showing the interval seconds as well. - MAJOR: Added the capability for VPNMON-R2 to auto-start after a reboot. By popular demand, I'm not sure how many times this was asked, so it's finally in there! Config menu item #16 will ask if you want VPNMON-R2 to auto-start. It inserts the command 'vpnmon-r2.sh -screen' into your /jffs/scripts/post-mount file. An indicator at the top of the UI shows if this feature is enabled, and intact in your post-mount file. If for some reason it's different than what was originally added, it will indicate that there's an issue. - ADDED: A second page of config options! Currently with 14 options, the list is getting too large, and expanded it out onto a second page for future growth! - FIXED: Made some modifications to the NordVPN API calls in order to hopefully provide a faster response for those dealing with bandwidth or other possible throttling limitations in other countries, like Turkey. Thanks to @iTyPsIDg for helping troubleshoot while out there! - FIXED: Minor code improvements and optimizations. v2.41 - (January 22, 2023) - ADDED: Some logic was added to check for parameters within the killmon.cfg to determine whether or not to suppress the KILLMON header on the main UI along with the associated logging that happens. If you have KILLMON installed but not running or enabled, VPNMON-R2 would display warnings that KILLMON is disabled and that rule integrity is compromised. You can now suppress these warnings from within the KILLMON UI v1.04. v2.40 - (December 24, 2022) - MAJOR: Integration with KILLMON, the new IP4/IP6 Kill Switch Monitor and Configurator! If KILLMON is installed, it will show the current status on the main VPNMON-R2 UI, indicating its current IP4/IP6 running status, reboot protection and whether it's kill mode is using (1) Paranoid, (2) IP Range or (3) Single IP scenarios. Also, it will check against the IP4/IP6 iptables to check for KILLMON rules integrity, and will warn you if rules are in a compromised state. If KILLMON is not installed, it will not show any such killswitch indicators in the UI. - ADDED: Created an additional switch called "-failover" for the purposes of providing some more automation for those who need control over VPNMON-R2 during dual-wan failover events, should you need it. I was originally going to remove this functionality after a failed attempt at integrating it with @Ranger802004's dual-wan failover script, but ended up deciding to just keep this functionality around incase it's needed in the future. This function, when called (ie. "vpnmon-r2 -failover"), will stop all VPN connections, and wait in a loop until another "-failover" command is sent its way (in other words, a manual fail-over and fail-back switch), upon which it will try to reconnect its last known good VPN connection. Thanks to both @Stephen Harrington and @Ranger802004 for their beta testing, troubleshooting and efforts on this! v2.36 - (October 29, 2022) - CHANGED: Added some functionality to the -stop command, that when it is resumed, it will attempt to connect to the last known good VPN slot. - FIXED: Omitted to include an event when VPNMON-R2 goes into a loop during the WAN1 VPN exception, and will now write that VPNMON-R2 is in a "STOPPED" state. Thanks for the report, @Stephen Harrington v2.35 - (October 21, 2022) - ADDED: Another commandline parameter "vpnmon-r2 -stop", based on a suggestion from our own @Stephen Harrington! This parameter, much like -pause, will cause VPNMON-R2 to retreat to a loop waiting for a -resume command. The difference here is that unlike with -pause, the -stop command will kill all VPN connections, and will re-establish the VPN once resumed. - ADDED: Another -config menu item #14 - "Allow WAN1 VPN Connections?". This item determines if you want to allow VPN connections across your WAN1 connection in Dual-WAN situations where you have failed over from your primary WAN connection. In the case of WAN1 connections, these are typically USB devices with limited bandwidth and cost, thus trying to limit the amount of traffic going over these devices. If this option is set, and WAN fails over to WAN1, VPNMON-R2 will kill all VPN connetions, loop and wait for WAN0 to become active again before connecting back to your VPN provider. Thanks to @Stephen Harrington for the great suggestion! - CHANGED: Some of the feedback you receive when VPN resets, to include more granular information about VPN slots or PING values on screen and in the logs. Thanks to @salvo for noting this! - CHANGED: Fixed some of the text indents across the board to give it a more uniform look/feel. - FIXED: There was a sleep variable incorrectly misnamed (as "Sleep"), and corrected this in order to prevent any possible "Sleep: Not Found" errors that may pop up as a result. Thanks to @TITAN for finding this mistake! v2.32 - (October 18, 2022) - HOTFIX2: I have backed out this code to determine concurrent sessions for further testing in the next round of betas. v2.32 is the new stable version. v2.31 - (October 18, 2022) - HOTFIX: The logic to determine whether or not a secondary vpnmon-r2 session was already running after executing a concurrent -monitor command wasn't working out correctly. This was fixed. Thanks much to @Stephen Harrington for his keen eye on this! v2.30 - (October 18, 2022) - MAJOR: Another method of picking VPN slots has been introduced to the mix, namely, the "Round Robin" method. Instead of randomly picking slots, VPNMON-R2 will pick the next VPN slot in line. Ex: If you are using VPN Slot #1 and it fails, it will connect to VPN Slot #2, then 3, etc. VPNMON-R2 will keep track of the slot last used, and will survive a reboot, so that it will correctly pick that next slot in line. Under setup->config, please choose option 5 - how you want your VPN slots chosen, select "Round Robin". Thanks @ComputerSteve for asking to include this! - ADDED: Now includes logic to PAUSE, RESUME and inquire about a current STATUS of VPNMON-R2. With thanks to @ComputerSteve for the suggestion. When running the command "vpnmon-r2 -pause", the currently running instance of VPNMON-R2 will enter a "paused" state. While in this paused state, it will not check for any VPN anomalies until it is resumed once again. Entering the command "vpnmon-r2 -resume" will allow the currently running instance to resume normal operations. Last, using the "vpnmon-r2 -status" command gives an indication what state VPNMON-R2 is currently operating in, along with the last known VPN slot being used. - ADDED: Another stats row, containing information regarding the VPN Slot Selection Method, the number of chances it gets (in case it's set for the Lowest PING method), the number of PING retries before reset, and the minimum PING allowable across the VPN tunnel before a reset. - ADDED: A check when executing 'vpnmon-r2 -monitor' to display a warning message if an existing session running vpnmon-r2 is already running under the Screen utility. Please know, that running the -monitor command will not prevent you from running 2 instances of vpnmon-r2 at the same time, but it will warn you that conflict can very likely occur. - CHANGED: When bringing up the setup/config menu from within the UI, the UI will now refresh and use the changes that were made to the config. This prevents you from having to stop and restart the script to accept changes. Been needing to do this for a while, so thanks again to @ComputerSteve for lighting a fire under my butt. ;) - CHANGED: Increased the timeout value for netcat when doing a WAN check from 1s to 3s. This should help alleviate instances of false WAN-down detection during times of high bandwidth utilization. Thanks to @salvo for reporting this! - FIXED: Added a few more references for the VPN status file to be written to during other types of vpnreset events so the status file reflects accurately throughout. - FIXED: Minor code improvements and optimizations. Eliminated some inefficient code from v0.1 that has been nagging my OCD for quite a while. v2.26 - (October 10, 2022) - CHANGED: Added some additional layers of error checking and logic pertaining to VPN provider API calls to help eliminate any errors from showing on the screen when connectivity might possibly be interfering with results being returned, resulting in parse error messages from CURL and JQ being displayed on screen. This behavior was particularly evident in Dual WAN failover situations. HUGE thanks to @Stephen Harrington for his patience and willingness to help test VPNMON-R2 during these failovers! You have helped make this script better and better over time, much thanks to you! :) - FIXED: Minor fixes to the VPN reset functionality to ensure it bypasses the interval timer after a reset. - FIXED: Also, revamped the function that kills VPN slots, ensuring it only kills the slots that are allocated to VPNMON-R2, should you be running other VPN connections on other slots. - FIXED: the -wipe SCREEN command is now being checked earlier before the script determines how it is going to initiate a SCREEN session. v2.24 - (September 30, 2022) - ADDED: Included new "Recommended Server" functionality for NordVPN users! As with the PC/Mobile app, when hitting the "Quick Connect" button, you are taken to the nearest, most fastest servers to your location. This functionality has now been built into VPNMON-R2, allowing you to fill your 1-N VPN slots with a selection of the closest/fastest NordVPN end points. Thanks to @monakh for the great suggestion! Make sure you go into the config menu -> option #6 -> when selecting NordVPN you will have the option to choose this functionality as long as you do not enable "SuperRandom", as it operates completely opposite from using NordVPN's recommended servers function. NOTE: Recommended servers are chosen from the country you have specified as your home country under the config options. - CHANGED: Included JQ as part of the prerequisites needed to be installed when VPNMON-R2 is set up for the first time. This was my error, thinking that the JQ tool was either already installed by default, or came along with an Entware install by default. Now, when going into Setup -> Config, the script will check for the existence of JQ, and will prompt an install if it's not already present under /opt/bin. JQ is necessary for pulling data from the various supported VPN Providers in order to populate VPN host lists for the country you have configured. Added a check when the script starts up to ensure that all prerequisites are in place before running the script. Thanks to @monakh for noticing this behavior with JQ on a fresh install of VPNMON-R2! - CHANGED: The behavior of the (R)eset button no longer waits to initiate a reset until the timer runs out, and begins the reset function process immediately. Same goes going to/from the (S)etup menu, and is now exiting directly back into the main VPNMON-R2 UI loop without waiting. - CHANGED: Revamped the reset conditions screens, which now display on a cleared page, instead of appending the reset output to the main UI. - CHANGED: Joined the reset condition checks together into their own function in order to allow the (R)eset command to work instantaneously, instead of waiting for a cycle to finish. - FIXED: I "may" have repaired the elusive unbound operand error that would occasionally appear on the main UI. v2.22 - (September 21, 2022) - CHANGED: The behavior of the "vpnmon-r2 -screen" command, so that when you execute this commandline parameter, it first will look for orphaned screens and wipe them... then, it will launch VPNMON-R2 into a new screen environment, and connect to it. This skips the original behavior where it drops back to a command prompt, and asks the user to connect to the VPNMON-R2 screen by requiring the user to run the "screen -r vpnmon-r2" command. If a screen session is already running, and you type "vpnmon-r2 -screen", it will then connect to this screen session without requiring any user input. Thanks much to @TITAN for the great suggestion! v2.21 - (September 10, 2022) - CHANGED: Replaced the API provider that translates IP to citynames from ipapi.co to ip-api.com, which seems to much more reliable. I have been encountering issues where the ipapi.co service seemed to be overloaded or blocked at many times, requiring VPNMON-R2 to have to resort to displaying a plain IP. The new API from ip-api.com allows for unlimited usage, as long as you stay below 45 requests per minute, which I *think* we can handle! LOL. Needless to say, they've been around since 2012, and seem to have nice infrastructure around the world. Think we'll stay with this for the time being! - CHANGED: Fixed the way that VPNMON-R2 checks for a lockfile should you run the script with the -reset switch either manually or through a cron job. It is now hyper-aware of this lockfile, and checks for this lockfile throughout the script, as well as during the timer interval. - FIXED: Minor code optimizations and tweaks v2.20 - (August 24, 2022) - MAJOR: VPNMON-R2 now officially supports WeVPN, including SuperRandom(r) and Multi-Country SuperRandom(r) functionality. Please note: WeVPN does not provide server loads (yet), and will incorporate that when it becomes available. Also, they don't provide straight IP addresses for their VPN hosts, which makes it more difficult to make it compatible with Skynet, so these two options are grayed out. - CHANGED: Changed the logic that kills VPN client slots to only kill the number of VPN clients you have configured for VPNMON-R2's purposes, and leaves all others alone in case you are using them for other purposes. Thanks to @IKNOWNOTHING for this great suggestion! - FIXED: Minor code optimizations and tweaks v2.15 - (August 15, 2022) - CHANGED: The order of operations for checkwan, and now occurs directly after the interface tab is drawn. It makes sense to perform this operation here, before the WAN0/1 checks are done, in a more optimized fashion. Also, changed the look/feel of the checkwan/load check notifications to fall more in line with the rest of the theme. - CHANGED: In a dual-WAN scenario, the high ping rule will be disabled should the WAN failover to WAN1, due to the fact that it will most likely be a slower more latent device. In this scenario, this rule would most likely cause continuous resets due to higher ping/latency, and is rightly so ignored in this particular scenario. - FIXED: Minor tweaks and corrections v2.12 - (August 8, 2022) - CHANGED: the color scheme to match that of RTRMON and PWRMON a bit more. Seeing a little more uniformity and standardization between the three helps calm my OCD. ;) - FIXED: realizing that the timezone abbreviation can vary from 1 char to 5 chars across the world, which skews the time to the left/right,so I have built in some logic that adjusts the top line that includes the current line to ensure that it lines up with the subsequent lines underneath. Yep, another OCD- related fix. lol v2.11 - (August 3, 2022) - ADDED: Added a VPN Director rule restart after VPNMON-R2 goes through a reset cycle to help with possible compatibility issues in dual WAN/secondary WAN disconnects. - FIXED: Minor tweaks and corrections v2.1 - (July 22, 2022) - ADDED: Completely reworked the setup/config menus to make the look/feel/act like RTRMON's. The hope was to simplify the process, allowing one to pick and choose settings to configure, instead of having to run down a long laundry list of configuration questions. I have done away with the loading of current config values as "defaults" when hitting the enter button, as it would be fairly easy to scroll up and see what value you had in place if need be. Enter on a blank line now assumes you want the system default. - ADDED: An extra round of VPN client kill commands when the router detects WAN trouble, just to make sure it pre-emptively kills everything incase these VPN clients try to reconnect while the WAN is down. - FIXED: Vastly reworked the logic of the WAN down scenario, and seems to be transitioning much smoother through the various stages of dealing with a lost connection. Definitely game-changing!! v2.01 - (July 17, 2022) * ADDED: New logic to determine if a screen session already is running with the alias 'vpnmon-r2'. If there is a session running, and you execute another "vpnmon-r2 -screen", it will prompt you whether or not you want to just reattach to the already-running session - thanks @Kal1975! * FIXED: Better dual-wan logic for those running @Ranger802004's dual-wan script to eliminitate some error messages when both WAN0 and WAN1 were connected at the same time. Thanks to @JAX1337 and @Stephen Harrington for the heads-up! Huge thanks To @Ranger802004 for further troubleshooting routing compatibility between our two scripts in a Dual-WAN failover/load balancing situation. Please note, this is an interim release until I can dive into Dual-WAN capabilities at a near future date to ensure VPNMON-R2 can effectively handle each situation presented to it. v2.0 - (July 10, 2022) * MAJOR: The VPNON.SH project has been sunset. Instead of maintaining almost 2 identical functions in both VPNMON-R2 and VPNON, I have decided to terminate the VPNON project. All functionality of VPNON will continue to live on in VPNMON-R2. * ADDED: The ability to reset the VPN with a "vpnmon-r2.sh -reset" commandline switch. This gives you the same functionality that VPNON gave you, and are able to use this method to randomly reset your VPN connection using CRON jobs. VPNMON-R2 running in its own SSH or Screen window will be aware of these actions, will pause the UI while the reset is running, and will resume when finished. * ADDED: New indicator showing if one of your pre-configured VPN host slots goes down, and is no longer reachable via ping, and will display the affected VPN slot as OFFLINE. * Configured an alias for VPNMON-R2 which lets you call all functions relating to the script from any location (without having to be in the /jffs/scripts folder or having to call it like /jffs/scripts/vpnmon-r2.sh), now using a command like this: "vpnmon-r2 -log" * FIXED: Made a few more wording changes in the setup menu thanks to the keen eye of @RimRider, and also tweaked the functionality of the menu a bit more. Now, when calling the setup menu from the UI, you will return to the UI when exiting out of the menu. v1.93 - (July 6, 2022) * MAJOR: Very happy to announce that VPNMON-R2 is now being included in AMTM! Many thanks to @thelonelycoder for his consideration and help getting this included! * FIXED: Fixed the logic to dispay the proper router model using some of @thelonelycoder's code which should report back the right info from NVRAM. * CHANGED: As such, did a few more cleanup items to make menu choices less ambiguous, and creating proper exits for items that require an exit vs. going back to a menu. v1.92 - (July 5, 2022) * FIXED: A bug in the setup menu (thanks @kuki68ster), and now checks for the existence of the timeout and screen utilities - if they exist, then it just continues on to the configuration menu, bypassing the need to answer whether you want to install these two utilities. * CHANGED: Resets the terminal colors on exit to play more friendly with other scripts. * ADDED: An easter-egg. Let me know if you find it, and if it gave you a chuckle. ;) v1.91 - (July 4, 2022) * FIXED: Minor wording changes, small bug fixes from some stuff I've noticed while running it to help with further increasing stability. v1.9 - (July 3, 2022) * ADDED: A fourth qualifier variable thanks to @JAX1337 that will reset the VPN connection if the average ping across the tunnel is greater than the specified amount, in the hopes of eliminating a slow connection in favor of something a little faster. Please make sure you run through the config to change the default of 100ms to something you prefer. * ADDED: new functionality thanks to a suggestion from @JAX1337... this option will let you be able to use VPNMON-R2 to reset connections based on best speed/ping to your pre-configured VPN client slots. Going through the "-config", new question 5 will let you choose whether you want it to randomly pick, or use the lowest ping when choosing your VPN servers. In the process, the UI now shows average ping going to each of your configured slots, and will notify you on the bottom of the UI if it has found a better server to connect to. You have the option in question 5a to specify how many chances you would like your current VPN connection to deal with other servers that might have a lower ping, giving your current connection a chance to recover. I have found that if you have other servers configured in your vicinity, there's a chance they will compete with each other, which would be causing your connection to drop and reconnect to the "now" fastest server repeatedly. This configurable counter will help alleviate this behavior. ;) * ADDED: the capability to use a keypress from the main UI to get into the -setup menu using (S), or forcing a reset with the {R} key, and of course being able to gracefully exit using the (E) key. Please note, you can press these keys at any time, but they won't get picked up until the main progress bar starts its interval count. These keypress options are indicated at the top right of the UI at all times. Sounds like an opportunity to build in some Easter Eggs now. :) * CHANGED: Enhanced and simplified some of the setup process when it comes to asking questions about NordVPN, SurfShark and PerfectPrivacy, and assigning variables to each. Also completely revamped the -config process to either let you start from scratch with default values, or use already existing values that you have modified in your current config file. Great suggestion by @iTyPsIDg to prevent you from having to continually modify the same entries over and over when a new version comes out. * CHANGED: reduced the amount of clutter that a reset produces on the screen, and is much less verbose, and looks much cleaner. Using on-screen indicators to show what's currently happening in the script. Will continue to refine these. v1.8 - (June 23, 2022) * ADDED: A new row of VPN stats have been added to include current protocol, port, cryptography, and authentication digest, just to give you more detailed info pertaining to your current VPN connection. * CHANGED: Made some minor changes to the look/feel and layout of the UI, and gave it more of an old-skool DOS folders kind of feel. Please note, I will never be satisfied with the look, and will continue to enhance it when I find something else that's pleasing to the eye. Also, the progress bar will change from green to yellow to red as it gets closer to its interval time. v1.71 - (June 9, 2022) * FIXED: Minor fix on the code that handled resets when VPN server loads exceeded a certain amount. The code was preventing a reset, unless you were a Perfect Privacy VPN user. Fixed! v1.7 - (June 4, 2022) * SIGNIFICANT: Added capabilities for Perfect Privacy VPN services on VPNMON-R2. As with the Surfshark integration, you get to enjoy all the same features that both Surfshark and NordVPN users get to have. You can randomly pick to randomly reconnect one of your VPN slots at a scheduled time, use Perfect Privacy SuperRandom functionality to pick one random server within your country, or from multiple countries to connect to, and optionally updates Skynet to ensure that your connection experience stays whitelisted at all times. Thanks for the suggestion, @Swistheater! * SIGNIFICANT: Added the option to leverage your Entware installation in order to utilize the CoreUtils-Timeout utility. It is recommended to allow VPNMON-R2 to use this utility in order to cut down on (what I'm guessing is) random hardware-level hangups when calling for nvram values specifically on RT-AC86U routers. When running VPNMON-R2, it will detect whether or not you have CoreUtils-Timeout installed, and will use the utility if it's present. If it's not installed, VPNMON-R2 will just operate as normal. You can install this optional utility using the -install switch, and step through option 1. * ADDED: Created a new Install menu that you can access by running 'vpnmon-r2.sh -install'. This option will guide the user through installing the optional Entware CoreUtils-Timeout utility, and prompt the user to go through the config menu. You also have the option to force re-install the Entware Timeout utility, or go through the vpnmon-r2 uninstall process. * FIXED: There was an issue with the Load calculation for Perfect Privacy. Added corrective measures, and should be showing the correct values now! * CHANGED: Some code cleanup and other housekeeping items v1.6 - (May 23, 2022) * SIGNIFICANT: Added capabilities for SurfShark VPN services on VPNMON-R2! This is basically a duplication of the capabilities that NordVPN users got to enjoy. You can randomly connect to one of your VPN slots at a scheduled time, use SurfShark SuperRandom functionality where it will pick random servers for you across your country and configure those in your VPN slots, then randomly connect to one. Also, you can choose up to 3 countries to randomly draw from under SuperRandom mode. Looking for feedback from SurfShark users. :) - thanks for the suggestion @Phk! * ADDED: A log rotation option has been added to the -config, which allows you to specify how large you would like your VPNMON-R2.log file to get before it starts trimming it down. Default will be 1000 lines, which should give you several weeks worth of data to sift through. * CHANGED: Reworked the script -update function to exit to the -config menu, rather than running the script using the -monitor function. The thinking is people would rather run through the -config immediately after due to potentially new functionality that would need to be enabled/disabled. * FIXED: the VPN reset date/time counter wasn't resetting after a WAN failure, and now accurately reflects when the VPN was last reset. v1.5 - (May 20, 2022) * SIGNIFICANT community testing and development has been done on the WAN up/down functionality... VPNMON-R2 is now checking for 2 distinct events -- (1) where the modem is physically off/disconnected, and (2) where the modem is on, but the ISP is down/disconnected. I never knew that the router/NVRAM couldn't tell the difference until @Stephen Harrington and @iTyPsIDg made this observation. But the end results after testing this is that it seems to be able to get past both hurdles now, and successfully re-establish a VPN connection after a major event. Sidenote: I don't think I've brought my internet down this much in the last 10 years total. My family thanks you and is praying this is the gold version! LOL. Sincere thanks to everyone involved on helping troubleshoot this and jumping in to pull apart this code! You all absolutely rock -- @Stephen Harrington, @SomeWhereOverTheRainBow, @dave14305, @iTyPsIDg ... thank you so much! * NEW: Added some extra bonus features and expanded the number of stats to include the WAN state, public- facing VPN IP address, as well as ping stats across the WAN interface(s). Should be dual-WAN capable, and indicate which WAN interface is active. * Crunched the code through shellcheck.net... lots of small changes to formatting of calculations and logic based on its suggestions -- thanks @SomeWhereOverTheRainBow * Added a new parameter called "-uninstall" to the list in order to completely uninstall the script (not that I'm encouraging you to do so, but at least you can now!) Usage: "vpnmon-r2 -uninstall" -- thanks @andywee * Added a new parameter called "-screen", which will kick off VPNMON-R2 using the screen utility so we don't have to type this huge commandline each time. Please note -- requires the "screen" utility to be installed. Usage: "vpnmon-r2.sh -screen" -- thanks @Kal1975 * Added the ability to hit enter on items during the config that were asking for values, and adds default values for fill-in-the-blank and yes/no items -- thanks @chongnt * Added live feedback during the config process to indicate what you just entered, to hopefully catch any typos before getting saved into the config. I thought this would be less messy than showing a huge summary of what all entries would be added to the config at the end of the setup process -- thanks @Kal1975 * Added a WAN connectivity check to the top of the VPN reset function. It will start off by first validating whether or not there's a functional WAN connection before attempting to initiate a VPN connection. * Added a WAN connectivity check during the regular loop to see if the WAN is up or down based on an SSL handshake + verification to 8.8.8.8 (over the WAN connection). If this fails, VPNMON-R2 will fall back to a loop, and keep rechecking until the WAN is re-established, then will re-establish the VPN -- thanks @Kal1975 * Changed the exit VPN city lookup to use the icanhazip.com external/public ip service to help with location accuracy -- thanks @Kal1975 * Some excellent coding suggestions allowed me to eliminate my last [[ ]] wild card match and replace it with a fancy grep statement to attempt to catch an error condition when calling the API to check the city name based on the IP address -- thanks so much @SomeWhereOverTheRainBow/@iTyPsIDg * Added another item to the config menu -- a delayed start-up option -- allowing you to specify how many seconds you would like to delay VPNMON-R2 from running after it starts up. This was added to allow for more compatibility with other potential scripts that are starting up after a router reboot. Please go through the "vpnmon-r2.sh -config" to add this setting -- thanks @Stephen Harrington * Fixed: If the avgping value = null, then display 0 until it fixes itself the next time around * Fixed: Added some modification to the timing involved in calculating the TX/RX values over the VPN tunnel. Due to the time it takes for the WAN to determine connectivity + the NordVPN Load lookup, I'm timing these functions to add their results to the entire calculation, hopefully to display slightly more accurate stats. v1.4 - (May 01, 2022) * The big news today is that VPNMON-R2 is now able to integrate with YazFi! Thanks to @iTyPsIDg for the great suggestion! Using the setup utility (-config switch), you can now specify which of the 3 x 2.4Ghz, 5Ghz and secondary 5Ghz guest networks you want to sync with VPNMON-R2 when it randomly picks a new VPN connection and updates the slot number directly in YazFi. This should make life a lot more bearable for those running multiple guest networks, and wanting to make use of the full power of randomized VPN connections! :) * The other big news is that VPNMON-R2 can now also accept 2 additional NordVPN countries for a total of 3 supported countries to randomly connect to! Also configurable through the setup utility (-config switch), you can now specify which additional (up to) 2 countries you want to add. When VPNMON-R2 goes through it's reset function, it will randomly pick from one of the (up to) 3 countries, optionally whitelist all available NordVPN servers for that country in your Skynet firewall, and optionally make a SuperRandom(r) connection to one out of the many available servers in the specified country! Yes, we have gone international! Thanks goes to @Spud for the excellent suggestion! * Some more code cleanup, optimizations and expanded on the config menu to handle the new YazFi and multiple country questions during setup. v1.3 - (Mar 20, 2022) * Added another row of stats! The latest additions include near-realtime average RX and TX bandwitdh (in Mbps) across the active VPN tunnel. Also, the current total TX and RX bytes for the VPN tunnel is displayed and gradually increments from when the tunnel was initialized (in Gb). Stats for these bandwith figures are interpreted from an OpenVPN status file that is auto generated when the tunnel is initiated. Please understand that these numbers are generated based on the interval time period you have configured, and may not reflect actual real-world amounts. These will give you a good general indicator on what's happening across your VPN. That's my disclaimer. ;) * The ability to enable/disable these stats is available in the configuration utility (vpnmon-r2.sh -config). * I have really taken a liking to the new ASCII art font title for VPNMON-R2, that I have now incorporated it on the top of the main UI. Version number was moved to its right. * I have moved the new version alert to directly below the ASCII art font title, and is more discreet in a red font in letting you know when a new version is available. v1.2 - (Mar 17, 2022) * Added for the capability of VPNMON-R2 to check for a new version on a periodic basis, and will alert you within the interface when a new version becomes available for download. From v1.2 moving forward, the script will provide for the capability to check and alert you for new updates. * Added a new commandline argument to the list of available commands: "sh vpnmon-r2.sh -update" -- this runs the script update utility which downloads and installs the latest version from the github repository. * Minor optimizations and enhancements v1.1 - (Mar 15, 2022) * Added an integrated configuration utility that steps you through all available configurable options to give you the most compatible experience for your setup. This tools makes the experience much more pleasing than having to deal with manually editing (and understanding) the options that were available at the top of the script. The configuration tool is called by using the following command: "sh vpnmon-r2.sh -config" * Introduced the capability to use commandline arguments to perform various functions in the script. Available commands are (1) -h or -help -- to display a quick overview of available commands, (2) -log -- to display the contents of the log file within the NANO text editor, (3) -config -- this runs the configuration utility, and steps you through all available options, and writes your selections to a config file, and (4) -monitor -- this runs VPNMON-R2 under normal monitoring operating conditions to keep an eye on the health of your VPN connection. * Moved all working files (config, log and reset log) to its own dedicated folder named "vpnmon-r2.d" under "/jffs/addons". The main script can still be found under "/jffs/scripts/vpnmon-r2.sh" * Various optimizations and small bug fixes (more like annoyances that bother my OCD). v1.0 - (Feb 26, 2022) * We're at the big v1.0! VPNMON-R2 (and VPNON) have made some huge strides in these 2 short months! ;) * Introducting a new NordVPN Server Load stat! In lieu of showing whether or not Skynet is getting updated on the stats row, it now shows the NordVPN Server Load thanks to a suggestion by @JackYaz. This Load stat is only available if you enable the "UseNordVPN" variable and set it to "1", or if the "NordVPNSuperRandom" variable is set to "1". Otherwise, it will default to showing the Skynet stat based on if "UpdateSkynet" is set to "1". * A great byproduct to now showing this Load stat, is that another VPN reset can occur if it exceeds a certain threshhold. Currently the "NordVPNLoadReset" is set to 50, so if the current NordVPN server you're connected to exceeds a 50% load, it will reset the VPN to look for another server with a lesser load. All these items are totally configurable at the top of the script. v0.9 - (Feb 23, 2022) * Added a row of stats to the bottom of VPNMON-R2's interface, specifically showing the Low and High ping history for the current connection, whether or not Skynet gets updated with NordVPN IPs, and how VPNMON-R2 is currently configured, showing either: (a) "VPNMGR" - VPNMON-R2 is integrated with VPNMGR and using its functionality periodically to update latest NordVPN/PIA/WeVPN server information into your VPN slots, (b) "NordVPN SuperRandom" - VPNMON-R2 is randomly selecting one of hundreds/thousands of NordVPN servers from within the specified country and populating your VPN slots, and (c) "Standard" - VPNMON-R2 is neither using VPNMGR or SuperRandom functionality, and optionally restarting your VPN connections on a random basis based on your set schedule. This is a clean and easy way to see how VPNMON-R2 is configured, and giving you some performance stats along with it. Enjoy! v0.8 - (Feb 20, 2022) * Added the concept of SuperRandom(tm) NordVPN Connections! This mode, when enabled (NordVPNSuperRandom=1) -- if you choose to be so incredibly daring and adventurous -- will fill your VPN client slots with random VPN servers across the country of your choice! Distance, load, and performance be damned!! In the US, the number of available VPN servers is up to around 1920, which fluctuates. This option will bypass VPNMGR functionality to update your VPN slots with its recommendations (based on chosen city, performance and load). Thus -- it is assumed that each of your (up to 5) VPN client slots are fully configured and operational! The SuperRandom(tm) function will only replace the "server address" IP and "description" (in a "NordVPN - City" format), and reinitiate the connection as usual after losing your connection, having multiple connections going, or after a scheduled reset. Enjoy! * The NordVPNCountry variable is now available for you to populate with the country of your choice without having to mess around with the code. These are all available country names to choose from: Albania, Argentina, Australia, Austria, Belgium, Bosnia and Herzegovina, Brazil, Bulgaria, Canada, Chile, Costa Rica, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Georgia, Germany, Greece, Hong Kong, Hungary, Iceland, India, Indonesia, Ireland, Israel, Italy, Japan, Latvia, Lithuania, Luxembourg, Malaysia, Mexico, Moldova, Netherlands, New Zealand, North Macedonia, Norway, Poland, Portugal, Romania, Serbia, Singapore, Slovakia, Slovenia, South Africa, South Korea, Spain, Sweden, Switzerland, Taiwan, Thailand, Turkey, Ukraine, United Arab Emirates, United Kingdom, United States, Vietnam. * Other code optimizations, error catching, and formatting fixes just to make it more pleasing to the eye. ;) v0.7 - (Feb 18, 2022) * Spent a lot of time dealing with a persistent hang issue, and looks to be resolved. I believe the script was running into a race/deadlock type of situation where it would hang during successive NVRAM lookups that were happening too close together calling for the same values. I reduced the number of lookups being done, and works flawlessly now. * Added some debug commands for future debugging needs, thanks to @eibgrad for his expert help and advice on how to accomplish all this. * Added a VPNMON-R2.LOG entry that shows when a city lookup is being done through the API. v0.6 - (Feb 1, 2022) * Added a new API lookup to display the VPN exit nde city/location next to the active VPN connection. This API is free, and guarantees at least 1000 lookups per month. In lieu of doing a lookup each single refresh interval, a location lookup is only done when either the script starts up fresh, when it detects VPNON doing a reset, or if VPNMON-R2 initiates a reset. So, hopefuly not more than 1x or 2x/day, or 30x/60x/month, well below the cut-off. So here is a disclaimer... lookups are based on your VPN's IP address, and we all know how wrong an IP location lookup can be at times when ISP's move IP ranges around, so please understand if it's not displaying the correct city at times. So far, it's been pretty darn near 100% correct for me. * Enhanced the alert entries in the logs a bit more to make them stand out when we're dealing with a connection failure, or multiple connections. VPN failures are now surrounded with asterisks during DEFCON5 level events. * Moved the refresh interval indicator to the top row next to the scheduled reset time. * Some cosmetics color change enhancements to the output screen and cleaned up the code to make it look more uniform. Need to work on variable naming uniformity next, as that's *ALL* over the place still. Give me time! * Replaced the spinner with a decent looking progress bar... spinner was looking long-in-the-tooth. Enjoy! ;) v0.5 - (Jan 23, 2022) Wow, where to start... * VPNMON.SH was heavily overhauled into VPNMON-R2.SH to incorporate my other script, VPNON.SH, so that it could act standalone, without needing to call a second script. VPNON has now turned into a function within the script. * Speaking of which -- I learned lots about functions ;) ... In doing so, I cleaned up some of the inefficient code, namely, how it checks for each individual VPN connection. Now, it basically loops from 1 through N and calls the function that checks the VPN connection without having to make so much duplication in the code itself. * Speaking of functions, I turned the spinner into a function as well. Cleaner and more optimized code is wonderful! * I wanted to display the last time VPN was reset, so that it saved this point-in-time each time you restarted VPNMON-R2 instead of resetting to 0d 0h 0m, etc. I built functionality that saves the exact time to a file called /jffs/scripts/vpnmon-rst.log, from where it reads and populates this time on screen each time a reset occurs. * VPNMON-R2 is now also able to perform a regularly scheduled VPN reset without the need to run VPNON.SH through a CRU job. This is completely configurable, and now also displays your configured reset time on screen. * Also being displayed on screen, is the interval (in seconds) in which it loops to check the validity of your VPN connections. * Overall, spruced up the look and feel of the visual in your SSH window to show pertinent information without cluttering up the screen. Hope you like it! * Above all, I wanted to make this script flexible enough for those who aren't running VPNMGR, using NordVPN or making use of the Skynet Firewall, so options have been built-in to bypass this functionality to make it usable in any VPN usage scenario. ------------------------------------- VPNMON.SH was deprecated on Jan 22, 2022) v0.8 - (Jan 20, 2022) * Added a timer to show the last time that the VPN was reset, or, when vpnmon.sh was restarted last, whichever happened most recently. * Also, added a spinner to indicate that the script is still active. Various optimizations and code clean-up. v0.7 - (Jan 15, 2022) * Added the avg ping time next to the "Ping is Alive" indicator, which shows avg time in ms across the active VPN tunnel to the ping host specified. v0.6 - (Jan 14, 2022) * Added logging capabilities. Major events (resets/connection issues/etc) are logged to a file named "vpnmon-on.log" in the /jffs/scripts folder by default. This capability can be disabled by changing the value to "/dev/null". PSA: though it doesn't do a crazy amount of logging, over time it will get larger and larger and will eventually impact the total space available in /jffs. Recommend keeping an eye on this, and wiping the "vpnmon-on.log" on occasion. Will consider adding a more automated log purging feature in the future. ;) v0.5 - Initial release of VPNMON.SH (Jan 12, 2022)