protonvpn-cli
protonvpn-cli copied to clipboard
Avoid overwriting modified DNS upon restore
In openvpn_disconnect(), "modify_dns revert_to_backup" is called to restore DNS to the value backed-up by openvpn_connect(). However, DNS might change after the backup and before a --disconnect is issued. In that case, --disconnect causes a needless overwrite of DNS with an old value, that might as well break the internet connection.
Use case:
- Client connects to protonvpn.
- Client changes access point. Internet connection breaks.
- Client issues a --disconnect to restore internet connection.
- Internet connection remains broken due to DNS overwrite. New --connect attempts will fail.
There is a mistake at line 370 (Custom DNS). To avoid this and make the code more readable, both echo -e… should be replaced by cp "/etc/resolv.conf" "$(get_protonvpn_cli_home)/.resolv.conf.protonvpn_applied_backup"
There is a mistake at line 370 (Custom DNS).
Thanks for pointing that out.
To avoid this and make the code more readable, both
echo -e…should be replaced bycp "/etc/resolv.conf" "$(get_protonvpn_cli_home)/.resolv.conf.protonvpn_applied_backup"
Not really, because someone might change the resolv.conf in between (although it is quite unlikely to happen). I guess tee is the best/cleaner solution.
Yes, you're right! :)