From patchwork Fri Apr 16 01:09:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1743 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director15.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id sFL7BrhweWBkIwAAIUCqbw (envelope-from ) for ; Fri, 16 Apr 2021 07:10:48 -0400 Received: from proxy3.mail.ord1d.rsapps.net ([172.30.191.6]) by director15.mail.ord1d.rsapps.net with LMTP id ENClBrhweWBhPQAAIcMcQg (envelope-from ) for ; Fri, 16 Apr 2021 07:10:48 -0400 Received: from smtp6.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.ord1d.rsapps.net with LMTPS id uHivBrhweWBbKQAA7WKfLA (envelope-from ) for ; Fri, 16 Apr 2021 07:10:48 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp6.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 64df11ca-9ea4-11eb-8c98-52540050e3e0-1-1 Received: from [216.105.38.7] ([216.105.38.7:56648] helo=lists.sourceforge.net) by smtp6.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 79/9E-27661-7B079706; Fri, 16 Apr 2021 07:10:47 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lXMMT-0001AK-3C; Fri, 16 Apr 2021 11:10:09 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXMMR-0001A2-Qd for openvpn-devel@lists.sourceforge.net; Fri, 16 Apr 2021 11:10:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=w3jJrUED9RUbfb4dsqXwXGsWyrcVX6a9IxgJXyUp26A=; b=kw8iMZLojd7TrRm3E67HllglU5 kQXf4jK450pFzVCzVRWsetZ4ttlRFlMa93zlcDZD5Fbw2dN6sZx0GVSTbn4EapdwjdzQL7HxIr4aU SF43lgYZppPj9HLUz0EahTQAZsATeCH6EnRf5TJHvzpaUx3r/kjWljGK5uEEjU6WuX/Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=w3jJrUED9RUbfb4dsqXwXGsWyrcVX6a9IxgJXyUp26A=; b=B XpmnqnzYsr6uu1VNMsjF7XKPdbR88scaLW/dhhZR3JiVBhTBEdKC/2LWmTD8dehpvjK1tP5rl5Sha IysjKi1ZTnPglXwr7q+4mqmLEtqp+XB6zXsmlUz1lboC7ftIpAn43OH1U7psew4cjRGpdxslvXNpX ytl8tTjsK+lcoatQ=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lXMMN-0002oy-3F for openvpn-devel@lists.sourceforge.net; Fri, 16 Apr 2021 11:10:07 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lXMMF-000Mq5-Aj for openvpn-devel@lists.sourceforge.net; Fri, 16 Apr 2021 13:09:55 +0200 Received: (nullmailer pid 1162620 invoked by uid 10006); Fri, 16 Apr 2021 11:09:55 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 16 Apr 2021 13:09:55 +0200 Message-Id: <20210416110955.1162574-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1lXMMN-0002oy-3F Subject: [Openvpn-devel] [PATCH] Add parsing of dhcp-option PROXY_HTTP X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This adds support for setting a HTTP proxy that should be used after connecting to a VPN. The syntax has been picked to have compatibility with OpenVPN3. Otherwise I would have used HTTP-PROXY instead. Since this option requires an additional argument compared to the existing dhcp-option keywords, move checking the number of arguments to the individual keywords. Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- doc/man-sections/vpn-network-options.rst | 6 ++++++ src/openvpn/options.c | 26 ++++++++++++++++-------- src/openvpn/tun.c | 7 +++++++ src/openvpn/tun.h | 4 ++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/doc/man-sections/vpn-network-options.rst b/doc/man-sections/vpn-network-options.rst index 029834aa4..8c1c02dcc 100644 --- a/doc/man-sections/vpn-network-options.rst +++ b/doc/man-sections/vpn-network-options.rst @@ -183,6 +183,12 @@ routing. :code:`DISABLE-NBT` Disable Netbios-over-TCP/IP. + :code: `PROXY_HTTP` ``host`` ``port`` + Sets a HTTP proxy that should be used when connected to the VPN. + + This option currently only works on OpenVPN for Android and requires + Android 10 or later. + --ifconfig args Set TUN/TAP adapter parameters. It requires the *IP address* of the local VPN endpoint. For TUN devices in point-to-point mode, the next argument diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 4bbcf829a..c7e529706 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -7403,22 +7403,22 @@ add_option(struct options *options, } #endif /* ifdef _WIN32 */ #if defined(_WIN32) || defined(TARGET_ANDROID) - else if (streq(p[0], "dhcp-option") && p[1] && !p[3]) + else if (streq(p[0], "dhcp-option") && p[1]) { struct tuntap_options *o = &options->tuntap_options; VERIFY_PERMISSION(OPT_P_IPWIN32); bool ipv6dns = false; if ((streq(p[1], "DOMAIN") || streq(p[1], "ADAPTER_DOMAIN_SUFFIX")) - && p[2]) + && p[2] && !p[3]) { o->domain = p[2]; } - else if (streq(p[1], "NBS") && p[2]) + else if (streq(p[1], "NBS") && p[2] && !p[3]) { o->netbios_scope = p[2]; } - else if (streq(p[1], "NBT") && p[2]) + else if (streq(p[1], "NBT") && p[2] && !p[3]) { int t; t = atoi(p[2]); @@ -7429,7 +7429,8 @@ add_option(struct options *options, } o->netbios_node_type = t; } - else if ((streq(p[1], "DNS") || streq(p[1], "DNS6")) && p[2] && (!strstr(p[2], ":") || ipv6_addr_safe(p[2]))) + else if ((streq(p[1], "DNS") || streq(p[1], "DNS6")) && p[2] && !p[3] + && (!strstr(p[2], ":") || ipv6_addr_safe(p[2]))) { if (strstr(p[2], ":")) { @@ -7442,19 +7443,19 @@ add_option(struct options *options, dhcp_option_address_parse("DNS", p[2], o->dns, &o->dns_len, msglevel); } } - else if (streq(p[1], "WINS") && p[2]) + else if (streq(p[1], "WINS") && p[2] && !p[3]) { dhcp_option_address_parse("WINS", p[2], o->wins, &o->wins_len, msglevel); } - else if (streq(p[1], "NTP") && p[2]) + else if (streq(p[1], "NTP") && p[2] && !p[3]) { dhcp_option_address_parse("NTP", p[2], o->ntp, &o->ntp_len, msglevel); } - else if (streq(p[1], "NBDD") && p[2]) + else if (streq(p[1], "NBDD") && p[2] && !p[3]) { dhcp_option_address_parse("NBDD", p[2], o->nbdd, &o->nbdd_len, msglevel); } - else if (streq(p[1], "DOMAIN-SEARCH") && p[2]) + else if (streq(p[1], "DOMAIN-SEARCH") && p[2] && !p[3]) { if (o->domain_search_list_len < N_SEARCH_LIST_LEN) { @@ -7470,6 +7471,13 @@ add_option(struct options *options, { o->disable_nbt = 1; } +#if defined(TARGET_ANDROID) + else if (streq(p[1], "PROXY_HTTP") && p[3] && !p[4]) + { + o->http_proxy_port = atoi(p[3]); + o->http_proxy = p[2]; + } +#endif else { msg(msglevel, "--dhcp-option: unknown option type '%s' or missing or unknown parameter", p[1]); diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 2385377fc..fa0dca949 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1870,6 +1870,13 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun management_android_control(management, "DNSDOMAIN", tt->options.domain); } + if (tt->options.http_proxy) + { + struct buffer buf = alloc_buf_gc(strlen(tt->options.http_proxy) + 20, &gc); + buf_printf(&buf, "%s %d", tt->options.http_proxy, tt->options.http_proxy_port); + management_android_control(management, "HTTPPROXY", BSTR(&buf)); + } + int android_method = managment_android_persisttun_action(management); /* Android 4.4 workaround */ diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 60ebfdcba..abc3a7154 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -128,6 +128,10 @@ struct tuntap_options { struct in6_addr dns6[N_DHCP_ADDR]; int dns6_len; +#if defined(TARGET_ANDROID) + const char *http_proxy; + int http_proxy_port; +#endif }; #elif defined(TARGET_LINUX)