--- protonvpn-cli/Makefile (nonexistent) +++ protonvpn-cli/Makefile (working copy) @@ -0,0 +1,46 @@ +# $FreeBSD$ + +PORTNAME= protonvpn-cli +DISTVERSIONPREFIX= v +DISTVERSION= 1.1.2 +CATEGORIES= security net net-vpn + +MAINTAINER= phascolarctos@protonmail.ch +COMMENT= ProtonVPN Command line tool + +LICENSE= MIT GPLv3 +LICENSE_COMB= multi +LICENSE_FILE_MIT= ${WRKSRC}/license.md +LICENSE_DISTFILES_MIT= ${DISTFILES:M*protonvpn-cli*} +LICENSE_DISTFILES_GPLv3= ${DISTFILES:M*scripts*} + +RUN_DEPENDS= bash:shells/bash \ + openvpn:security/openvpn \ + wget:ftp/wget + +USES= python + +USE_GITHUB= yes +GH_ACCOUNT= ProtonVPN +GH_PROJECT= scripts:updateResolvConf +GH_TAGNAME= d5d0be1:updateResolvConf + +NO_ARCH= yes +NO_BUILD= yes + +PLIST_FILES= bin/protonvpn-cli \ + bin/pvpn \ + etc/openvpn/update-resolv-conf + +post-patch: + ${REINPLACE_CMD} s,\$$python,${PYTHON_CMD},g ${WRKSRC}/protonvpn-cli.sh + ${REINPLACE_CMD} s,wget,wget\ --no-check-certificate,g ${WRKSRC}/protonvpn-cli.sh + ${REINPLACE_CMD} s,%%LOCALBASE%%,${LOCALBASE},g ${WRKSRC}/protonvpn-cli.sh + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/protonvpn-cli.sh ${STAGEDIR}${PREFIX}/bin/protonvpn-cli + ${LN} -s ./protonvpn-cli ${STAGEDIR}${PREFIX}/bin/pvpn + ${MKDIR} ${STAGEDIR}${PREFIX}/etc/openvpn + ${INSTALL_SCRIPT} ${WRKSRC_updateResolvConf}/update-resolv-conf.sh ${STAGEDIR}${PREFIX}/etc/openvpn/update-resolv-conf + +.include --- protonvpn-cli/distinfo (nonexistent) +++ protonvpn-cli/distinfo (working copy) @@ -0,0 +1,5 @@ +TIMESTAMP = 1569487609 +SHA256 (ProtonVPN-protonvpn-cli-v1.1.2_GH0.tar.gz) = d58b2a9acca5eb0c81c07ba7021d40bb3230f871ec9537b5546cbe0268bb0d7f +SIZE (ProtonVPN-protonvpn-cli-v1.1.2_GH0.tar.gz) = 14602 +SHA256 (ProtonVPN-scripts-d5d0be1_GH0.tar.gz) = 146ebce132a9d8f03523eaea43e8d50a020caf4b87e1f48f025dd71a68c99aed +SIZE (ProtonVPN-scripts-d5d0be1_GH0.tar.gz) = 1328 --- protonvpn-cli/files/patch-protonvpn-cli.sh (nonexistent) +++ protonvpn-cli/files/patch-protonvpn-cli.sh (working copy) @@ -0,0 +1,282 @@ +--- protonvpn-cli.sh.orig 2018-11-05 20:42:22 UTC ++++ protonvpn-cli.sh +@@ -17,63 +17,6 @@ if [[ ("$UID" != 0) && ("$1" != "ip") && ("$1" != "-ip + exit 1 + fi + +-function check_requirements() { +- if [[ -z $(which openvpn) ]]; then +- echo "[!] Error: openvpn is not installed. Install \`openvpn\` package to continue." +- exit 1 +- fi +- +- if [[ ! -z $(which python) ]]; then +- python=$(which python) +- elif [[ ! -z $(which python3) ]]; then +- python=$(which python3) +- elif [[ ! -z $(which python2) ]]; then +- python=$(which python2) +- fi +- +- if [[ -z "$python" ]]; then +- echo "[!] Error: python is not installed. Install \`python\` package to continue." +- exit 1 +- fi +- +- if [[ -z $(which dialog) ]]; then +- echo "[!] Error: dialog is not installed. Install \`dialog\` package to continue." +- exit 1 +- fi +- if [[ -z $(which wget) ]]; then +- echo "[!] Error: wget is not installed. Install \`wget\` package to continue." +- exit 1 +- fi +- +- if [[ -z $(which sysctl) && ( $(detect_platform_type) != "Mac" ) ]]; then +- echo "[!] Error: sysctl is not installed. Install \`sysctl\` package to continue." +- exit 1 +- fi +- +- if [[ $(detect_platform_type) == "Linux" ]]; then +- if [[ ( -z $(which iptables) ) || ( -z $(which iptables-save) ) || ( -z $(which iptables-restore) ) ]]; then +- echo "[!] Error: iptables is not installed. Install \`iptables\` package to continue." +- exit 1 +- fi +- fi +- +- sha512sum_func +- if [[ -z "$sha512sum_tool" ]]; then +- echo "[!] Error: sha512sum is not installed. Install \`sha512sum\` package to continue." +- exit 1 +- fi +- +- if [[ (! -x "/etc/openvpn/update-resolv-conf") && ( $(detect_platform_type) != "MacOS") ]]; then +- echo "[!] Error: update-resolv-conf is not installed." +- read -p "Would you like protonvpn-cli to install update-resolv-conf? (y/N): " "user_confirm" +- if [[ "$user_confirm" == "y" || "$user_confirm" == "Y" ]]; then +- install_update_resolv_conf +- else +- exit 1 +- fi +- fi +-} +- + function get_home() { + if [[ -z "$SUDO_USER" ]]; then + CURRENT_USER="$(whoami)" +@@ -100,25 +43,6 @@ function get_protonvpn_cli_home() { + echo "$(get_home)/.protonvpn-cli" + } + +-function install_update_resolv_conf() { +- if [[ ("$UID" != 0) ]]; then +- echo "[!] Error: Installation requires root access." +- exit 1 +- fi +- echo "[*] Installing update-resolv-conf..." +- mkdir -p "/etc/openvpn/" +- file_sha512sum="81cf5ed20ec2a2f47f970bb0185fffb3e719181240f2ca3187dbee1f4d102ce63ab048ffee9daa6b68c96ac59d1d86ad4de2b1cfaf77f1b1f1918d143e96a588" +- wget "https://raw.githubusercontent.com/ProtonVPN/scripts/master/update-resolv-conf.sh" -O "/etc/openvpn/update-resolv-conf" +- if [[ ($? == 0) && ($($sha512sum_tool "/etc/openvpn/update-resolv-conf" | cut -d " " -f1) == "$file_sha512sum") ]]; then +- chmod +x "/etc/openvpn/update-resolv-conf" +- echo "[*] Done." +- else +- echo "[!] Error installing update-resolv-conf." +- rm -f "/etc/openvpn/update-resolv-conf" 2> /dev/null +- exit 1 +- fi +-} +- + function check_ip() { + counter=0 + ip="" +@@ -222,15 +146,7 @@ function init_cli() { + } + + function detect_platform_type() { +- unameOut="$(uname -s)" +- case "${unameOut}" in +- Linux*) platform=Linux;; +- Darwin*) platform=MacOS;; +- CYGWIN*) platform=Linux;; +- MINGW*) platform=Linux;; +- *) platform=Linux +- esac +- echo "$platform" ++ echo "FreeBSD" + } + + function manage_ipv6() { +@@ -501,7 +417,8 @@ function openvpn_connect() { + --header 'Accept: application/vnd.protonmail.v1+json' \ + -o /dev/null \ + --timeout 10 --tries 1 -q -O "$openvpn_config" \ +- "https://api.protonmail.ch/vpn/config?Platform=$(detect_platform_type)&LogicalID=$config_id&Protocol=$selected_protocol" ++ "https://api.protonmail.ch/vpn/config?Platform=Linux&LogicalID=$config_id&Protocol=$selected_protocol" && \ ++ sed -i '' s,/etc/openvpn/update-resolv-conf,%%LOCALBASE%%/etc/openvpn/update-resolv-conf, "$openvpn_config" + + echo "Connecting..." + +@@ -573,102 +490,6 @@ function openvpn_connect() { + exit $status_exit + } + +-function update_cli() { +- check_if_internet_is_working_normally +- +- cli_path="/usr/local/bin/protonvpn-cli" +- if [[ ! -f "$cli_path" ]]; then +- echo "[!] Error: protonvpn-cli does not seem to be installed." +- exit 1 +- fi +- echo "[#] Checking for update..." +- current_local_hashsum=$($sha512sum_tool "$cli_path" | cut -d " " -f1) +- remote_=$(wget --timeout 6 -o /dev/null -q -O - 'https://raw.githubusercontent.com/ProtonVPN/protonvpn-cli/master/protonvpn-cli.sh') +- if [[ $? != 0 ]]; then +- echo "[!] Error: There is an error updating protonvpn-cli." +- exit 1 +- fi +- remote_hashsum=$(echo "$remote_" | $sha512sum_tool | cut -d ' ' -f1) +- +- if [[ "$current_local_hashsum" == "$remote_hashsum" ]]; then +- echo "[*] protonvpn-cli is up-to-date!" +- exit 0 +- else +- echo "[#] A new update is available." +- echo "[#] Updating..." +- wget -q --timeout 20 -O "$cli_path" 'https://raw.githubusercontent.com/ProtonVPN/protonvpn-cli/master/protonvpn-cli.sh' +- if [[ $? == 0 ]]; then +- echo "[#] protonvpn-cli has been updated successfully." +- exit 0 +- else +- echo "[!] Error: There is an error updating protonvpn-cli." +- exit 1 +- fi +- fi +-} +- +-function install_cli() { +- mkdir -p "/usr/bin/" "/usr/local/bin/" +- cli="$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")" +- errors_counter=0 +- cp "$cli" "/usr/local/bin/protonvpn-cli" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- ln -s -f "/usr/local/bin/protonvpn-cli" "/usr/local/bin/pvpn" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- ln -s -f "/usr/local/bin/protonvpn-cli" "/usr/bin/protonvpn-cli" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- ln -s -f "/usr/local/bin/protonvpn-cli" "/usr/bin/pvpn" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- chown "$USER:$(id -gn $USER)" "/usr/local/bin/protonvpn-cli" "/usr/local/bin/pvpn" "/usr/bin/protonvpn-cli" "/usr/bin/pvpn" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- chmod 0755 "/usr/local/bin/protonvpn-cli" "/usr/local/bin/pvpn" "/usr/bin/protonvpn-cli" "/usr/bin/pvpn" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- if [[ ($errors_counter == 0) || ( ! -z $(which protonvpn-cli) ) ]]; then +- echo "[*] Done." +- exit 0 +- else +- echo "[!] Error: There was an error in installing protonvpn-cli." +- exit 1 +- fi +-} +- +-function uninstall_cli() { +- +- if [[ $(is_openvpn_currently_running) == true ]]; then +- echo "[!] OpenVPN is currently running." +- echo "[!] Session will be disconnected." +- openvpn_disconnect quiet dont_exit +- if [[ $(is_openvpn_currently_running) == true ]]; then # Checking if OpenVPN is still active. +- echo "[!] Error disconnecting OpenVPN." +- echo "[!] Please disconnect manually and try the uninstallation again." +- exit 1 +- else +- echo "[#] Disconnected." +- fi +- fi +- +- errors_counter=0 +- rm -f "/usr/local/bin/protonvpn-cli" "/usr/local/bin/pvpn" "/usr/bin/protonvpn-cli" "/usr/bin/pvpn" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- rm -rf "$(get_protonvpn_cli_home)/" &> /dev/null +- if [[ $? != 0 ]]; then errors_counter=$((errors_counter+1)); fi +- +- if [[ ($errors_counter == 0) || ( $(which protonvpn-cli) == "" ) ]]; then +- echo "[*] Done." +- exit 0 +- else +- echo "[!] Error: There was an error in uninstalling protonvpn-cli." +- exit 1 +- fi +-} +- + function print_console_status() { + current_ip="$(check_ip)" + if [[ $(is_openvpn_currently_running) == true ]]; then +@@ -1246,6 +1067,18 @@ function get_countries_server_list() { + response_cache_path="$(get_protonvpn_cli_home)/.response_cache" + tier=$(cat "$(get_protonvpn_cli_home)/protonvpn_tier") + ++ country_id=$1 ++ if [[ $tier -eq 0 ]] ++ then ++ if [[ $1 -eq 1 ]] ++ then ++ country_id=6 ++ elif [[ $1 -eq 2 ]] ++ then ++ country_id=7 ++ fi ++ fi ++ + output=`$python <