Skip to content

Instantly share code, notes, and snippets.

@jimlinntu
Created December 24, 2020 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimlinntu/08e23338c76a0a3c8cac17250f3c76f7 to your computer and use it in GitHub Desktop.
Save jimlinntu/08e23338c76a0a3c8cac17250f3c76f7 to your computer and use it in GitHub Desktop.
OpenVPN client-connect script
#!/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