ProtonVPN / protonvpn-cli

Legacy protonvpn-cli: ProtonVPN Command-Line Tool for Linux and macOS. This has been superseded by https://github.com/ProtonVPN/protonvpn-cli-ng
Other
607 stars 98 forks source link

Avoid overwriting modified DNS upon restore #199

Open elias-pap opened 4 years ago

elias-pap commented 4 years ago

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:

Tamaranch commented 4 years ago

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"

elias-pap commented 4 years ago

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 by cp "/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.

Tamaranch commented 4 years ago

Yes, you're right! :)