binhex / arch-sabnzbdvpn

Docker build script for Arch Linux base with SABnzbd, Privoxy and OpenVPN
GNU General Public License v3.0
49 stars 9 forks source link

Options error: --proto tcp is ambiguous in this context. Please specify --proto tcp-server or --proto tcp-client #7

Closed adamrbell closed 6 years ago

adamrbell commented 6 years ago

2018-03-11 11:17:12,512 DEBG 'start-script' stdout output: Options error: --proto tcp is ambiguous in this context. Please specify --proto tcp-server or --proto tcp-client Use --help for more information. 2018-03-11 11:17:12,513 DEBG 'start-script' stdout output: [info] OpenVPN started 2018-03-11 11:17:12,513 DEBG 'start-script' stdout output: [debug] Waiting for valid IP address from tunnel... ... ... ...

OpenVPN no longer allow "tcp" as a "proto" option. This first block of code is selecting the correct protocol based on the ovpn config with some nested ifs to cover configs without the proto being declared.

export VPN_PROTOCOL=$(cat "${VPN_CONFIG}" | grep -P -o -m 1 '(?<=^proto\s)[^\r\n]+' | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
    if [[ ! -z "${VPN_PROTOCOL}" ]]; then
        echo "[info] VPN_PROTOCOL defined as '${VPN_PROTOCOL}'" | ts '%Y-%m-%d %H:%M:%.S'
    else
        export VPN_PROTOCOL=$(echo "${vpn_remote_line}" | grep -P -o -m 1 'udp|tcp-client|tcp$' | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
        if [[ ! -z "${VPN_PROTOCOL}" ]]; then
            echo "[info] VPN_PROTOCOL defined as '${VPN_PROTOCOL}'" | ts '%Y-%m-%d %H:%M:%.S'
        else
            echo "[warn] VPN_PROTOCOL not found in ${VPN_CONFIG}, assuming udp" | ts '%Y-%m-%d %H:%M:%.S'
            export VPN_PROTOCOL="udp"
        fi
    fi

Then this block overrides the VPN_PROTOCOL to "tcp" if "tcp-client" is selected. I assume tcp-client is not a valid protocol in iptables so this block protects against an iptables protocol error.

# required for use in iptables
if [[ "${VPN_PROTOCOL}" == "tcp-client" ]]; then
    export VPN_PROTOCOL="tcp"
fi

We therefore have a conflict...unless of course, I've misunderstood this code.

binhex commented 6 years ago

im taking a look at this at the mo, think i have a fix for this but i need to test as ive moved some code around.

binhex commented 6 years ago

ok this is now fixed and tested, please pull down the latest image