From owner-svn-ports-all@freebsd.org Thu Oct 3 09:24:30 2019 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7498E12F446; Thu, 3 Oct 2019 09:24:30 +0000 (UTC) (envelope-from pi@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46kSJG39pQz3MYN; Thu, 3 Oct 2019 09:24:30 +0000 (UTC) (envelope-from pi@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 502939F80; Thu, 3 Oct 2019 09:24:30 +0000 (UTC) (envelope-from pi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x939OUe1062605; Thu, 3 Oct 2019 09:24:30 GMT (envelope-from pi@FreeBSD.org) Received: (from pi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x939OTI3062601; Thu, 3 Oct 2019 09:24:29 GMT (envelope-from pi@FreeBSD.org) Message-Id: <201910030924.x939OTI3062601@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pi set sender to pi@FreeBSD.org using -f From: Kurt Jaeger Date: Thu, 3 Oct 2019 09:24:29 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r513655 - in head/security: . protonvpn-cli protonvpn-cli/files X-SVN-Group: ports-head X-SVN-Commit-Author: pi X-SVN-Commit-Paths: in head/security: . protonvpn-cli protonvpn-cli/files X-SVN-Commit-Revision: 513655 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 09:24:30 -0000 Author: pi Date: Thu Oct 3 09:24:29 2019 New Revision: 513655 URL: https://svnweb.freebsd.org/changeset/ports/513655 Log: New port: security/protonvpn-cli protonvpn-cli is an user-friendly command-line tool for accessing the swiss-based privacy-focused ProtonVPN VPN service. You need a ProtonVPN account to use it: you can create one at https://protonvpn.com. Free accounts are available, although with limited features: only 3 countries (Netherlands, USA, Japan) are available with the free plan. It can also easily add an extra layer of privacy by activating Tor (needs payed plan). No manual page is provided with protonvpn-cli, but you can get help on usage by running protonvpn-cli -h. Warning: although user is asked about enabling a killswitch or not, no killswitch is available at the moment. WWW: https://protonvpn.com PR: 240841 Submitted by: Lorenzo Salvadore Added: head/security/protonvpn-cli/ head/security/protonvpn-cli/Makefile (contents, props changed) head/security/protonvpn-cli/distinfo (contents, props changed) head/security/protonvpn-cli/files/ head/security/protonvpn-cli/files/patch-protonvpn-cli.sh (contents, props changed) head/security/protonvpn-cli/pkg-descr (contents, props changed) Modified: head/security/Makefile Modified: head/security/Makefile ============================================================================== --- head/security/Makefile Thu Oct 3 08:52:08 2019 (r513654) +++ head/security/Makefile Thu Oct 3 09:24:29 2019 (r513655) @@ -839,6 +839,7 @@ SUBDIR += portsentry SUBDIR += ppars SUBDIR += proftpd-mod_clamav + SUBDIR += protonvpn-cli SUBDIR += proxycheck SUBDIR += proxytunnel SUBDIR += pscan Added: head/security/protonvpn-cli/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/protonvpn-cli/Makefile Thu Oct 3 09:24:29 2019 (r513655) @@ -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 Added: head/security/protonvpn-cli/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/protonvpn-cli/distinfo Thu Oct 3 09:24:29 2019 (r513655) @@ -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 Added: head/security/protonvpn-cli/files/patch-protonvpn-cli.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/protonvpn-cli/files/patch-protonvpn-cli.sh Thu Oct 3 09:24:29 2019 (r513655) @@ -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 <