From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64621 invoked by alias); 26 Jan 2018 16:56:55 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 64481 invoked by uid 89); 26 Jan 2018 16:56:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1621 X-HELO: mx2.mail.elte.hu Received: from mx2.mail.elte.hu (HELO mx2.mail.elte.hu) (157.181.151.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jan 2018 16:56:52 +0000 Received: from mailbox1.caesar.elte.hu ([157.181.151.157]) by mx2.mail.elte.hu with esmtp (Exim) id 1ef7J2-00032Q-1w from for ; Fri, 26 Jan 2018 17:56:50 +0100 Received: (Authenticated sender: szgyg) by mailbox1.caesar.elte.hu with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ef7J1-0003HQ-Ps for cygwin-apps@cygwin.com; Fri, 26 Jan 2018 17:56:47 +0100 From: SZAVAI Gyula To: cygwin-apps@cygwin.com Subject: [PATCH setup 4/5] Add Proxy class Date: Fri, 26 Jan 2018 16:56:00 -0000 Message-Id: <20180126165636.2944-5-szgyg@ludens.elte.hu> In-Reply-To: <20180126165636.2944-1-szgyg@ludens.elte.hu> References: <0dd4274b-fd3a-2857-bdb5-087243444407@dronecode.org.uk> <20180126165636.2944-1-szgyg@ludens.elte.hu> X-ELTE-SpamScore: -6.7 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 3.0 X-ELTE-SpamCheck-Details: score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00,L_AUTH,RP_MATCHES_RCVD autolearn=ham autolearn_force=no SpamAssassin version=3.4.0 -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -5.0 L_AUTH Caesar auth -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.1 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00089.txt.bz2 --- nio-ie5.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/nio-ie5.cc b/nio-ie5.cc index a649233..e1a8e5c 100644 --- a/nio-ie5.cc +++ b/nio-ie5.cc @@ -63,6 +63,65 @@ determine_default_useragent(void) return default_useragent; } + +class Proxy +{ + int method; + std::string host; + int port; + std::string hostport; // host:port + +public: + Proxy (int method, char const *host, int port) + : method(method), + host(host ? host : ""), + port(port), + hostport(std::string(host ? host : "") + ":" + std::to_string(port)) + {}; + + bool operator!= (const Proxy &o) const; + + DWORD type (void) const; + char const *string (void) const; + char const *bypass (void) const; +}; + +bool Proxy::operator!= (const Proxy &o) const +{ + if (method != o.method) return true; + if (method != IDC_NET_PROXY) return false; + if (host != o.host) return true; + if (port != o.port) return true; + return false; +} + +char const *Proxy::string(void) const +{ + if (method == IDC_NET_PROXY) + return hostport.c_str(); + else + return NULL; +} + +char const *Proxy::bypass(void) const +{ + if (method == IDC_NET_PROXY) + return ""; // use "<-loopback>" to do NOT bypass for localhost + else + return NULL; +} + +DWORD Proxy::type (void) const +{ + switch (method) + { + case IDC_NET_PROXY: return INTERNET_OPEN_TYPE_PROXY; + case IDC_NET_PRECONFIG: return INTERNET_OPEN_TYPE_PRECONFIG; + default: return INTERNET_OPEN_TYPE_DIRECT; + } +} + + NetIO_IE5::NetIO_IE5 (char const *_url, bool direct, bool cachable): NetIO (_url) { -- 2.14.3