Verified Commit be8000b4 authored by Aral Balkan's avatar Aral Balkan
Browse files

Added help and new header and improved readme

parent a790abf7
......@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.0] - 2020-05-03
### Added
- `help` option.
### Fixed
- Improved the readme.
## [1.1.0] - 2020-05-03
### Changed
......
The current command-line interface for using [AzireVPN](https://www.azirevpn.com/)’s excellent [Wireguard](https://www.wireguard.com/) service that I’ve been using since the early days of the beta goes something like this:
# vpn
1. Memorise the codes for [the servers](https://www.azirevpn.com/docs/servers#servers) (which you can find in _/etc/wireguard_ and which look like _azirevpn-se1_ for Sweden and _azirevpn-dk1_ Denmark, etc.)
An elegant command-line interface for AzireVPN’s Wireguard service.
2. `wg-quick up azirevpn-se1` to connect to, say, Sweden.
3. `wg-quick down azirevpn-se1` to disconnect, say, from Sweden.
4. To query your connection status, either run `ifconfig | grep azire` or `sudo wg show`.
That’s not terrible but it’s not exactly elegant.
So today, which I designate as national yak shaving day, I wrote a tiny bash script to make it easier.
## Installation
Save the script, below, to somewhere on your path (like _/usr/local/bin_) and give it execute permissions:
## Install
```sh
chmod +x vpn
git clone https://source.small-tech.org/aral/vpn
cd vpn
sudo cp ./vpn /usr/local/bin/
```
## Usage
## Use
### Connect to the default server
......@@ -59,7 +49,7 @@ Sample output:
```
Location Code
------------ ------------
──────────── ────────────
Spain spain
Norway norway
Netherlands netherlands
......@@ -99,4 +89,18 @@ Sample output:
What I really want to do is to write a little status bar app for it that automatically connects on untrusted networks and does so to the nearest server by default but this should tide me over till then.
Hope you enjoy it!
\ No newline at end of file
Hope you enjoy it!
## Like this? Fund us!
[Small Technology Foundation](https://small-tech.org) is a tiny, independent not-for-profit.
We exist in part thanks to patronage by people like you. If you share [our vision](https://small-tech.org/about/#small-technology) and want to support our work, please [become a patron or donate to us](https://small-tech.org/fund-us) today and help us continue to exist.
## Copyright
© 2020 [Aral Balkan](https://ar.al), [Small Technology Foundation](https://small-tech.org).
## License
[AGPL version 3.0 or later.](https://www.gnu.org/licenses/agpl-3.0.en.html)
......@@ -13,6 +13,19 @@
set -e
version='1.2.0'
# AzireVPN uses purples; so shall we :)
darkPurple='\e[38;5;61m'
lightPurple='\e[38;5;134m'
colorEnd='\e[0m'
echo
echo -e "${darkPurple}╔═══════════════════════════════════════════╗${colorEnd}"
echo -e "${darkPurple}${colorEnd}${lightPurple} vpn v${version} ­– AzireVPN Wireguard interface ${colorEnd}${darkPurple}${colorEnd}"
echo -e "${darkPurple}╚═══════════════════════════════════════════╝${colorEnd}"
echo
action='up'
currentConnection=`ifconfig | grep azirevpn- | cut -c10-12`
......@@ -45,9 +58,34 @@ locationsToServerCodes=(
['us']='us1'
)
function displayLocations () {
echo -e " Currently supported locations and their location codes:"
output=" Location=== Code\n ────────────=== ────────────"
for location in "${!locationsToServerCodes[@]}"
do
output="${output}\n ${serverCodesToLocations[${locationsToServerCodes[${location}]}]}=== $location"
done
echo
echo -e "${output}" | column -t -s ===
}
if [[ $1 == 'help' || $1 == 'h' || $1 == '--help' || $1 == '-h' || $1 == '--help' ]]; then
output=' vpn [location code]===Turn on VPN and connect to default or specified location code.\n'
output="${output} vpn off===Turn VPN off.\n"
output="${output} vpn ls===List supported locations and location codes.\n"
output="${output} vpn ?===Display the current connection status.\n"
output="${output} vpn help===Display this help screen."
echo -e "${output}" | column -t -s ===
echo
displayLocations
exit 0
fi
if [[ $1 == '?' ]]; then
if [[ $currentConnection == '' ]]; then
echo -e "\n ❌ You are not connected to AzireVPN via Wireguard.\n"
echo -e " ❌ You are not connected to AzireVPN via Wireguard.\n"
exit 1
fi
location="${serverCodesToLocations[${currentConnection}]}"
......@@ -56,24 +94,18 @@ if [[ $1 == '?' ]]; then
fi
if [[ $1 == 'ls' ]]; then
output="Location===Code\n------------===------------"
for location in "${!locationsToServerCodes[@]}"
do
output="${output}\n${serverCodesToLocations[${locationsToServerCodes[${location}]}]}===$location"
done
echo
echo -e "$output" | column -t -s ===
displayLocations
exit 0
fi
if [[ $1 == 'off' ]]; then
action='down'
if [[ $currentConnection == '' ]]; then
echo -e "\n ❌ You are not connected to AzireVPN via Wireguard.\n"
echo -e " ❌ You are not connected to AzireVPN via Wireguard.\n"
exit 1
fi
serverCode=$currentConnection
echo -e "\n 👋 Disconnecting from AzireVPN in ${serverCodesToLocations[${currentConnection}]}…"
echo -e " 👋 Disconnecting from AzireVPN in ${serverCodesToLocations[${currentConnection}]}…"
else
location=$1
......@@ -85,13 +117,12 @@ else
if [[ $currentConnection != '' ]]; then
if [[ $currentConnection == $serverCode ]]; then
echo -e "\n 😁👍 You’re already connected to that VPN server.\n"
echo -e " 😁👍 You’re already connected to AzireVPN in ${serverCodesToLocations[${currentConnection}]}.\n"
exit
fi
printf "\n 👋 Disconnecting existing connection…"
printf " 👋 Disconnecting existing connection…"
wg-quick down "azirevpn-${currentConnection}" > /dev/null 2>&1
exit
fi
echo -e "\n 📡 Connecting to AzireVPN in ${serverCodesToLocations[${serverCode}]}…"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment