Created
December 24, 2020 07:02
-
-
Save jimlinntu/08e23338c76a0a3c8cac17250f3c76f7 to your computer and use it in GitHub Desktop.
OpenVPN client-connect script
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
#!/bin/bash | |
allow_ips=("211.75.165.175") | |
function handle_connect { | |
ip=$trusted_ip | |
echo "Current IP: ${ip}" | |
for allow_ip in ${allow_ips[@]}; do | |
if [[ $allow_ip == $ip ]]; then | |
# ip found | |
return 0 | |
fi | |
done | |
# ip not found | |
return 1 | |
} | |
case "$script_type" in | |
client-connect) | |
# if this connection is not valid | |
handle_connect | |
if [[ $? != 0 ]]; then | |
exit 1 | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment