* [PATCH setup] Send User-Agent even when setup-specific proxy is used
@ 2018-01-18 19:15 SZAVAI Gyula
2018-01-19 14:18 ` Jon Turney
0 siblings, 1 reply; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-18 19:15 UTC (permalink / raw)
To: cygwin-apps
Setup is sending User-Agent header if direct connection or system proxy
is used, but not when direct(legacy) or setup-specific proxy. Fix this.
---
Makefile.am | 2 ++
nio-http.cc | 4 +++
nio-ie5.cc | 53 ++---------------------------
useragent.cc | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
useragent.h | 8 +++++
5 files changed, 125 insertions(+), 51 deletions(-)
create mode 100644 useragent.cc
create mode 100644 useragent.h
diff --git a/Makefile.am b/Makefile.am
index a238d88..3c88020 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -256,6 +256,8 @@ inilint_SOURCES = \
String++.h \
threebar.cc \
threebar.h \
+ useragent.cc \
+ useragent.h \
UserSettings.cc \
UserSettings.h \
win32.cc \
diff --git a/nio-http.cc b/nio-http.cc
index 413ee7f..3f7fd9b 100644
--- a/nio-http.cc
+++ b/nio-http.cc
@@ -29,6 +29,8 @@
#include "netio.h"
#include "nio-http.h"
+#include "useragent.h"
+
#ifndef _strnicmp
#define _strnicmp strncasecmp
#endif
@@ -125,6 +127,8 @@ retry_get:
s->printf ("Proxy-Authorization: Basic %s\r\n",
base64_encode (net_proxy_user, net_proxy_passwd));
+ s->printf ("%s", get_useragent_header());
+
s->printf ("\r\n");
char * l = s->gets ();
diff --git a/nio-ie5.cc b/nio-ie5.cc
index a649233..2e36ac6 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -27,42 +27,12 @@
#include "netio.h"
#include "nio-ie5.h"
#include "LogSingleton.h"
-#include "setup_version.h"
-#include "getopt++/StringOption.h"
+#include "useragent.h"
#include <sstream>
-static StringOption UserAgent ("", '\0', "user-agent", "User agent string for HTTP requests");
-
static HINTERNET internet_direct = 0;
static HINTERNET internet_preconfig = 0;
-const std::string &
-determine_default_useragent(void)
-{
- static std::string default_useragent;
-
- if (!default_useragent.empty())
- return default_useragent;
-
- std::stringstream os;
- os << "Windows NT " << OSMajorVersion() << "." << OSMinorVersion() << "." << OSBuildNumber();
-
- std::string bitness = "Unknown";
-#ifdef __x86_64__
- bitness = "Win64";
-#else
- typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL);
- PFNISWOW64PROCESS pfnIsWow64Process = (PFNISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
- if (pfnIsWow64Process) {
- BOOL bIsWow64 = FALSE;
- if (pfnIsWow64Process(GetCurrentProcess(), &bIsWow64))
- bitness = bIsWow64 ? "WoW64" : "Win32";
- }
-#endif
- default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ")";
- return default_useragent;
-}
-
NetIO_IE5::NetIO_IE5 (char const *_url, bool direct, bool cachable):
NetIO (_url)
{
@@ -78,26 +48,7 @@ NetIO (_url)
{
InternetAttemptConnect (0);
- const char *lpszAgent = determine_default_useragent().c_str();
- if (UserAgent.isPresent())
- {
- const std::string &user_agent = UserAgent;
- if (user_agent.length())
- {
- // override the default user agent string
- lpszAgent = user_agent.c_str();
- Log (LOG_PLAIN) << "User-Agent: header overridden to \"" << lpszAgent << "\"" << endLog;
- }
- else
- {
- // user-agent option is present, but no string is specified means
- // don't add a user-agent header
- lpszAgent = NULL;
- Log (LOG_PLAIN) << "User-Agent: header suppressed " << lpszAgent << endLog;
- }
- }
-
- *internet = InternetOpen (lpszAgent,
+ *internet = InternetOpen (get_useragent(),
direct ? INTERNET_OPEN_TYPE_DIRECT : INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0);
}
diff --git a/useragent.cc b/useragent.cc
new file mode 100644
index 0000000..a871a8b
--- /dev/null
+++ b/useragent.cc
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2000, Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by DJ Delorie <dj@cygnus.com>
+ *
+ */
+
+#include "win32.h"
+
+#include "LogSingleton.h"
+#include "setup_version.h"
+#include "getopt++/StringOption.h"
+#include "useragent.h"
+#include <sstream>
+
+static StringOption UserAgentOption ("", '\0', "user-agent", "User agent string for HTTP requests");
+
+const std::string &
+determine_default_useragent(void)
+{
+ static std::string default_useragent;
+
+ if (!default_useragent.empty())
+ return default_useragent;
+
+ std::stringstream os;
+ os << "Windows NT " << OSMajorVersion() << "." << OSMinorVersion() << "." << OSBuildNumber();
+
+ std::string bitness = "Unknown";
+#ifdef __x86_64__
+ bitness = "Win64";
+#else
+ typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL);
+ PFNISWOW64PROCESS pfnIsWow64Process = (PFNISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
+ if (pfnIsWow64Process) {
+ BOOL bIsWow64 = FALSE;
+ if (pfnIsWow64Process(GetCurrentProcess(), &bIsWow64))
+ bitness = bIsWow64 ? "WoW64" : "Win32";
+ }
+#endif
+ default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ")";
+ return default_useragent;
+}
+
+
+// used in nio_ie5.cc
+const char *
+get_useragent(void)
+{
+ static std::string useragent;
+
+ if (UserAgentOption.isPresent())
+ {
+ useragent = UserAgentOption;
+ if (useragent.length())
+ {
+ // override the default user agent string
+ Log (LOG_PLAIN) << "User-Agent: header overridden to \"" << useragent << "\"" << endLog;
+ return useragent.c_str();
+ }
+ else
+ {
+ // user-agent option is present, but no string is specified means
+ // don't add a user-agent header
+ Log (LOG_PLAIN) << "User-Agent: header suppressed " << endLog;
+ return NULL;
+ }
+ }
+ else
+ {
+ useragent = determine_default_useragent();
+ return useragent.c_str();
+ }
+}
+
+
+// used in nio_http.cc
+const char *
+get_useragent_header(void)
+{
+ static std::string header;
+ static const char *cheader = NULL;
+
+ if (!cheader)
+ {
+ const char *useragent = get_useragent();
+
+ if (useragent)
+ {
+ header = std::string("User-Agent: ") + useragent + "\r\n";
+ }
+ else
+ {
+ header = "";
+ }
+
+ cheader = header.c_str();
+ }
+
+ return cheader;
+}
diff --git a/useragent.h b/useragent.h
new file mode 100644
index 0000000..75fa9b9
--- /dev/null
+++ b/useragent.h
@@ -0,0 +1,8 @@
+
+#ifndef SETUP_USERAGENT_H
+#define SETUP_USERAGENT_H
+
+const char *get_useragent(void);
+const char *get_useragent_header(void);
+
+#endif /* SETUP_USERAGENT_H */
--
2.14.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH setup] Send User-Agent even when setup-specific proxy is used
2018-01-18 19:15 [PATCH setup] Send User-Agent even when setup-specific proxy is used SZAVAI Gyula
@ 2018-01-19 14:18 ` Jon Turney
2018-01-22 19:28 ` szgyg
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
0 siblings, 2 replies; 11+ messages in thread
From: Jon Turney @ 2018-01-19 14:18 UTC (permalink / raw)
To: cygwin-apps; +Cc: SZAVAI Gyula
On 18/01/2018 19:16, SZAVAI Gyula wrote:
> Setup is sending User-Agent header if direct connection or system proxy
> is used, but not when direct(legacy) or setup-specific proxy. Fix this.
Thanks for the patch.
This is fine, as far as it goes. However, I don't think
'direct(legacy)' is actually doing anything useful these days, so I'd
kind of like to remove it (and all the hand-built protocol handling
underneath it), and instead teach NetIO_IE5 how to handle a
setup-specific proxy configuration as well.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH setup] Send User-Agent even when setup-specific proxy is used
2018-01-19 14:18 ` Jon Turney
@ 2018-01-22 19:28 ` szgyg
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
1 sibling, 0 replies; 11+ messages in thread
From: szgyg @ 2018-01-22 19:28 UTC (permalink / raw)
To: cygwin-apps
On Fri, Jan 19, 2018 at 02:18:10PM +0000, Jon Turney wrote:
> On 18/01/2018 19:16, SZAVAI Gyula wrote:
> > Setup is sending User-Agent header if direct connection or system proxy
> > is used, but not when direct(legacy) or setup-specific proxy. Fix this.
> Thanks for the patch.
>
> This is fine, as far as it goes. However, I don't think 'direct(legacy)' is
> actually doing anything useful these days, so I'd kind of like to remove it
> (and all the hand-built protocol handling underneath it), and instead teach
> NetIO_IE5 how to handle a setup-specific proxy configuration as well.
Agree. I'll look into it.
s
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH setup 5/5] Remove NetIO_HTTP
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
` (3 preceding siblings ...)
2018-01-26 16:56 ` [PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG SZAVAI Gyula
@ 2018-01-26 16:56 ` SZAVAI Gyula
2018-01-28 21:47 ` Remove legacy networking code Jon Turney
5 siblings, 0 replies; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-26 16:56 UTC (permalink / raw)
To: cygwin-apps
---
Makefile.am | 2 -
netio.cc | 10 +--
nio-http.cc | 208 ------------------------------------------------------------
nio-http.h | 39 ------------
nio-ie5.cc | 30 ++++-----
nio-ie5.h | 2 +-
6 files changed, 16 insertions(+), 275 deletions(-)
delete mode 100644 nio-http.cc
delete mode 100644 nio-http.h
diff --git a/Makefile.am b/Makefile.am
index f8f5993..cd5648a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -192,8 +192,6 @@ inilint_SOURCES = \
netio.h \
nio-ie5.cc \
nio-ie5.h \
- nio-http.cc \
- nio-http.h \
package_db.cc \
package_db.h \
package_depends.h \
diff --git a/netio.cc b/netio.cc
index d77108b..90fb3df 100644
--- a/netio.cc
+++ b/netio.cc
@@ -29,7 +29,6 @@
#include "state.h"
#include "msg.h"
#include "nio-ie5.h"
-#include "nio-http.h"
#include "dialog.h"
int NetIO::net_method;
@@ -144,14 +143,7 @@ NetIO::open (char const *url, bool cachable)
url = url2.c_str();
}
- if (proto == file)
- rv = new NetIO_IE5 (url, true, false);
- else if (net_method == IDC_NET_PRECONFIG)
- rv = new NetIO_IE5 (url, false, cachable);
- else if (net_method == IDC_NET_PROXY)
- rv = new NetIO_HTTP (url);
- else if (net_method == IDC_NET_DIRECT)
- rv = new NetIO_IE5 (url, true, cachable);
+ rv = new NetIO_IE5 (url, proto == file ? false : cachable);
if (rv && !rv->ok ())
{
diff --git a/nio-http.cc b/nio-http.cc
deleted file mode 100644
index 413ee7f..0000000
--- a/nio-http.cc
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * A copy of the GNU General Public License can be found at
- * http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-/* This file is responsible for implementing all direct HTTP protocol
- channels. It is intentionally simplistic. */
-
-#include "win32.h"
-#include <winsock2.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "resource.h"
-#include "state.h"
-#include "simpsock.h"
-#include "msg.h"
-
-#include "netio.h"
-#include "nio-http.h"
-
-#ifndef _strnicmp
-#define _strnicmp strncasecmp
-#endif
-
-static char six2pr[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
-};
-
-static char *
-base64_encode (char *username, char *password)
-{
- unsigned char *ep;
- char *rp;
- static char *rv = 0;
- if (rv)
- delete[] rv;
- rv = new char[2 * (strlen (username) + strlen (password)) + 5];
-
- char *up = new char[strlen (username) + strlen (password) + 6];
- strcpy (up, username);
- strcat (up, ":");
- strcat (up, password);
- ep = (unsigned char *) up + strlen (up);
- *ep++ = 0;
- *ep++ = 0;
- *ep++ = 0;
-
- char block[4];
-
- rp = rv;
-
- for (ep = (unsigned char *) up; *ep; ep += 3)
- {
- block[0] = six2pr[ep[0] >> 2];
- block[1] = six2pr[((ep[0] << 4) & 0x30) | ((ep[1] >> 4) & 0x0f)];
- block[2] = six2pr[((ep[1] << 2) & 0x3c) | ((ep[2] >> 6) & 0x03)];
- block[3] = six2pr[ep[2] & 0x3f];
-
- if (ep[1] == 0)
- block[2] = block[3] = '=';
- if (ep[2] == 0)
- block[3] = '=';
- memcpy (rp, block, 4);
- rp += 4;
- }
- *rp = 0;
-
- delete[] up;
-
- return rv;
-}
-
-NetIO_HTTP::NetIO_HTTP (char const *Purl):NetIO (Purl)
-{
- std::string url (Purl);
-retry_get:
- if (port == 0)
- port = 80;
-
- if (net_method == IDC_NET_PROXY)
- s = new SimpleSocket (net_proxy_host, net_proxy_port);
- else
- s = new SimpleSocket (host, port);
-
- if (!s->ok ())
- {
- delete s;
- s = NULL;
- return;
- }
-
- if (net_method == IDC_NET_PROXY)
- s->printf ("GET %s HTTP/1.0\r\n", url.c_str ());
- else
- s->printf ("GET %s HTTP/1.0\r\n", path);
-
- // Default HTTP port is 80. Host header can have no port if requested port
- // is the same as the default. Some HTTP servers don't behave as expected
- // when they receive a Host header with the unnecessary default port value.
- if (port == 80)
- s->printf ("Host: %s\r\n", host);
- else
- s->printf ("Host: %s:%d\r\n", host, port);
-
- if (net_user && net_passwd)
- s->printf ("Authorization: Basic %s\r\n",
- base64_encode (net_user, net_passwd));
-
- if (net_proxy_user && net_proxy_passwd)
- s->printf ("Proxy-Authorization: Basic %s\r\n",
- base64_encode (net_proxy_user, net_proxy_passwd));
-
- s->printf ("\r\n");
-
- char * l = s->gets ();
- int code;
- if (!l)
- return;
- sscanf (l, "%*s %d", &code);
- if (code >= 300 && code < 400)
- {
- while ((l = s->gets ()) != 0)
- {
- if (_strnicmp (l, "Location:", 9) == 0)
- {
- char * u = l + 9;
- while (*u == ' ' || *u == '\t')
- u++;
- set_url (u);
- delete s;
- goto retry_get;
- }
- }
- }
- if (code == 401) /* authorization required */
- {
- get_auth (NULL);
- delete s;
- goto retry_get;
- }
- if (code == 407) /* proxy authorization required */
- {
- get_proxy_auth (NULL);
- delete s;
- goto retry_get;
- }
- if (code == 500 /* ftp authentication through proxy required */
- && net_method == IDC_NET_PROXY
- && !url.compare (0, std::string::npos, "ftp://", 6))
- {
- get_ftp_auth (NULL);
- if (net_ftp_user && net_ftp_passwd)
- {
- delete s;
- url = std::string("ftp://") + net_ftp_user + ":"
- + net_ftp_passwd + "@" + url.substr (6);
- goto retry_get;
- }
- }
- if (code >= 300)
- {
- delete s;
- s = NULL;
- return;
- }
-
- // Eat the header, picking out the Content-Length in the process
- while (((l = s->gets ()) != NULL) && (*l != '\0'))
- {
- if (_strnicmp (l, "Content-Length:", 15) == 0)
- sscanf (l, "%*s %d", &file_size);
- }
-}
-
-NetIO_HTTP::~NetIO_HTTP ()
-{
- if (s)
- delete s;
-}
-
-int
-NetIO_HTTP::ok ()
-{
- if (s && s->ok ())
- return 1;
- return 0;
-}
-
-int
-NetIO_HTTP::read (char *buf, int nbytes)
-{
- return s->read (buf, nbytes);
-}
diff --git a/nio-http.h b/nio-http.h
deleted file mode 100644
index d3d5102..0000000
--- a/nio-http.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * A copy of the GNU General Public License can be found at
- * http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-#ifndef SETUP_NIO_HTTP_H
-#define SETUP_NIO_HTTP_H
-
-/* Direct HTTP (with or without proxy) */
-
-class SimpleSocket;
-
-class NetIO_HTTP:public NetIO
-{
- SimpleSocket *s;
-
-public:
- NetIO_HTTP (char const *url);
- virtual ~ NetIO_HTTP ();
-
- /* If !ok() that means the transfer isn't happening. */
- virtual int ok ();
-
- /* Read `nbytes' bytes from the file. Returns zero when the file
- is complete. */
- virtual int read (char *buf, int nbytes);
-};
-
-#endif /* SETUP_NIO_HTTP_H */
diff --git a/nio-ie5.cc b/nio-ie5.cc
index e1a8e5c..f9599e8 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -33,9 +33,6 @@
static StringOption UserAgent ("", '\0', "user-agent", "User agent string for HTTP requests");
-static HINTERNET internet_direct = 0;
-static HINTERNET internet_preconfig = 0;
-
const std::string &
determine_default_useragent(void)
{
@@ -122,20 +119,23 @@ DWORD Proxy::type (void) const
}
-NetIO_IE5::NetIO_IE5 (char const *_url, bool direct, bool cachable):
+static HINTERNET internet = 0;
+static Proxy last_proxy = Proxy(-1, "", -1);
+
+NetIO_IE5::NetIO_IE5 (char const *_url, bool cachable):
NetIO (_url)
{
int resend = 0;
- HINTERNET *internet;
- if (direct)
- internet = &internet_direct;
- else
- internet = &internet_preconfig;
-
- if (*internet == 0)
+ Proxy proxy = Proxy(net_method, net_proxy_host, net_proxy_port);
+ if (proxy != last_proxy)
{
- InternetAttemptConnect (0);
+ last_proxy = proxy;
+
+ if (internet != 0)
+ InternetCloseHandle(internet);
+ else
+ InternetAttemptConnect (0);
const char *lpszAgent = determine_default_useragent().c_str();
if (UserAgent.isPresent())
@@ -156,9 +156,7 @@ NetIO (_url)
}
}
- *internet = InternetOpen (lpszAgent,
- direct ? INTERNET_OPEN_TYPE_DIRECT : INTERNET_OPEN_TYPE_PRECONFIG,
- NULL, NULL, 0);
+ internet = InternetOpen (lpszAgent, proxy.type(), proxy.string(), proxy.bypass(), 0);
}
DWORD flags =
@@ -171,7 +169,7 @@ NetIO (_url)
flags |= INTERNET_FLAG_RESYNCHRONIZE;
}
- connection = InternetOpenUrl (*internet, url, NULL, 0, flags, 0);
+ connection = InternetOpenUrl (internet, url, NULL, 0, flags, 0);
try_again:
diff --git a/nio-ie5.h b/nio-ie5.h
index 9a66e2a..a1ee90d 100644
--- a/nio-ie5.h
+++ b/nio-ie5.h
@@ -22,7 +22,7 @@ class NetIO_IE5:public NetIO
{
HINTERNET connection;
public:
- NetIO_IE5 (char const *url, bool direct, bool cacheable);
+ NetIO_IE5 (char const *url, bool cacheable);
~NetIO_IE5 ();
virtual int ok ();
virtual int read (char *buf, int nbytes);
--
2.14.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH setup 3/5] Remove NetIO_File
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
@ 2018-01-26 16:56 ` SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 1/5] Remove direct(legacy) connection type SZAVAI Gyula
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-26 16:56 UTC (permalink / raw)
To: cygwin-apps
---
Makefile.am | 2 --
netio.cc | 12 +++++++++---
nio-file.cc | 64 -------------------------------------------------------------
nio-file.h | 31 ------------------------------
4 files changed, 9 insertions(+), 100 deletions(-)
delete mode 100644 nio-file.cc
delete mode 100644 nio-file.h
diff --git a/Makefile.am b/Makefile.am
index aca3ccc..f8f5993 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -192,8 +192,6 @@ inilint_SOURCES = \
netio.h \
nio-ie5.cc \
nio-ie5.h \
- nio-file.cc \
- nio-file.h \
nio-http.cc \
nio-http.h \
package_db.cc \
diff --git a/netio.cc b/netio.cc
index 6c357fc..d77108b 100644
--- a/netio.cc
+++ b/netio.cc
@@ -28,7 +28,6 @@
#include "resource.h"
#include "state.h"
#include "msg.h"
-#include "nio-file.h"
#include "nio-ie5.h"
#include "nio-http.h"
#include "dialog.h"
@@ -124,6 +123,7 @@ NetIO *
NetIO::open (char const *url, bool cachable)
{
NetIO *rv = 0;
+ std::string url2;
enum
{ http, https, ftp, ftps, file }
proto;
@@ -135,11 +135,17 @@ NetIO::open (char const *url, bool cachable)
proto = ftp;
else if (strncmp (url, "ftps://", 7) == 0)
proto = ftps;
- else
+ else if (strncmp (url, "file://", 7) == 0)
proto = file;
+ else
+ {
+ proto = file;
+ url2 = (std::string("file://") + url);
+ url = url2.c_str();
+ }
if (proto == file)
- rv = new NetIO_File (url);
+ rv = new NetIO_IE5 (url, true, false);
else if (net_method == IDC_NET_PRECONFIG)
rv = new NetIO_IE5 (url, false, cachable);
else if (net_method == IDC_NET_PROXY)
diff --git a/nio-file.cc b/nio-file.cc
deleted file mode 100644
index fce1b2c..0000000
--- a/nio-file.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2000, Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * A copy of the GNU General Public License can be found at
- * http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-/* The purpose of this file is to manage access to files stored on the
- local disk (i.e. "downloading" setup.ini). Called from netio.cc */
-
-#include "win32.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include "netio.h"
-#include "nio-file.h"
-#include "resource.h"
-#include "msg.h"
-#include "filemanip.h"
-#include "LogSingleton.h"
-
-NetIO_File::NetIO_File (char const *Purl):
-NetIO (Purl)
-{
- fd = nt_fopen (path, "rb");
- if (fd)
- {
- file_size = get_file_size (std::string("file://") + path);
- }
- else
- {
- const char *err = strerror (errno);
- if (!err)
- err = "(unknown error)";
- Log (LOG_BABBLE) << "Can't open " << path << " for reading: " << err << endLog;
- }
-}
-
-NetIO_File::~NetIO_File ()
-{
- if (fd)
- fclose ((FILE *) fd);
-}
-
-int
-NetIO_File::ok ()
-{
- return fd ? 1 : 0;
-}
-
-int
-NetIO_File::read (char *buf, int nbytes)
-{
- return fread (buf, 1, nbytes, (FILE *) fd);
-}
diff --git a/nio-file.h b/nio-file.h
deleted file mode 100644
index fe5e8e0..0000000
--- a/nio-file.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2000, Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * A copy of the GNU General Public License can be found at
- * http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-#ifndef SETUP_NIO_FILE_H
-#define SETUP_NIO_FILE_H
-
-/* see nio-file.cc */
-
-class NetIO_File:public NetIO
-{
-public:
- NetIO_File (char const *url);
- void *fd;
- ~NetIO_File ();
- virtual int ok ();
- virtual int read (char *buf, int nbytes);
-};
-
-#endif /* SETUP_NIO_FILE_H */
--
2.14.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH setup 1/5] Remove direct(legacy) connection type
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 3/5] Remove NetIO_File SZAVAI Gyula
@ 2018-01-26 16:56 ` SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 4/5] Add Proxy class SZAVAI Gyula
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-26 16:56 UTC (permalink / raw)
To: cygwin-apps
---
ConnectionSetting.cc | 5 --
Makefile.am | 2 -
net.cc | 9 +--
netio.cc | 20 ------
nio-ftp.cc | 179 ---------------------------------------------------
nio-ftp.h | 41 ------------
res.rc | 2 -
resource.h | 1 -
8 files changed, 3 insertions(+), 256 deletions(-)
delete mode 100644 nio-ftp.cc
delete mode 100644 nio-ftp.h
diff --git a/ConnectionSetting.cc b/ConnectionSetting.cc
index 1154d94..5baf76c 100644
--- a/ConnectionSetting.cc
+++ b/ConnectionSetting.cc
@@ -49,9 +49,6 @@ ConnectionSetting::~ConnectionSetting ()
sprintf(port_str, "%d", NetIO::net_proxy_port);
UserSettings::instance().set("net-proxy-port", port_str);
break;
- case IDC_NET_DIRECT_LEGACY:
- UserSettings::instance().set("net-method", "Legacy");
- break;
default:
break;
}
@@ -66,8 +63,6 @@ ConnectionSetting::typeFromString(const std::string& aType)
return IDC_NET_IE5;
if (!casecompare(aType, "Proxy"))
return IDC_NET_PROXY;
- if (!casecompare(aType, "Legacy"))
- return IDC_NET_DIRECT_LEGACY;
/* A sanish default */
return IDC_NET_IE5;
diff --git a/Makefile.am b/Makefile.am
index a238d88..aca3ccc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -194,8 +194,6 @@ inilint_SOURCES = \
nio-ie5.h \
nio-file.cc \
nio-file.h \
- nio-ftp.cc \
- nio-ftp.h \
nio-http.cc \
nio-http.h \
package_db.cc \
diff --git a/net.cc b/net.cc
index fa6f1e3..5ff3713 100644
--- a/net.cc
+++ b/net.cc
@@ -37,7 +37,7 @@ extern ThreeBarProgressPage Progress;
static StringOption ProxyOption ("", 'p', "proxy", "HTTP/FTP proxy (host:port)", false);
-static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, IDC_NET_DIRECT_LEGACY, 0 };
+static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
static bool doing_loading = false;
void
@@ -47,8 +47,7 @@ NetPage::CheckIfEnableNext ()
DWORD ButtonFlags = PSWIZB_BACK;
if (NetIO::net_method == IDC_NET_IE5 ||
- NetIO::net_method == IDC_NET_DIRECT ||
- NetIO::net_method == IDC_NET_DIRECT_LEGACY)
+ NetIO::net_method == IDC_NET_DIRECT)
e = 1;
else if (NetIO::net_method == IDC_NET_PROXY)
{
@@ -132,8 +131,7 @@ NetPage::OnInit ()
// Check to see if any radio buttons are selected. If not, select a default.
if (SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_GETCHECK, 0, 0) != BST_CHECKED
- && SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0) != BST_CHECKED
- && SendMessage (GetDlgItem (IDC_NET_DIRECT_LEGACY), BM_GETCHECK, 0, 0) != BST_CHECKED)
+ && SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0) != BST_CHECKED)
SendMessage (GetDlgItem (IDC_NET_IE5), BM_CLICK, 0, 0);
}
@@ -169,7 +167,6 @@ NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
case IDC_NET_IE5:
case IDC_NET_DIRECT:
case IDC_NET_PROXY:
- case IDC_NET_DIRECT_LEGACY:
case IDC_PROXY_HOST:
case IDC_PROXY_PORT:
save_dialog (GetHWND());
diff --git a/netio.cc b/netio.cc
index cf634c1..86bb69a 100644
--- a/netio.cc
+++ b/netio.cc
@@ -31,7 +31,6 @@
#include "nio-file.h"
#include "nio-ie5.h"
#include "nio-http.h"
-#include "nio-ftp.h"
#include "dialog.h"
int NetIO::net_method;
@@ -147,23 +146,6 @@ NetIO::open (char const *url, bool cachable)
rv = new NetIO_HTTP (url);
else if (net_method == IDC_NET_DIRECT)
rv = new NetIO_IE5 (url, true, cachable);
- else if (net_method == IDC_NET_DIRECT_LEGACY)
- {
- switch (proto)
- {
- case http:
- rv = new NetIO_HTTP (url);
- break;
- case ftp:
- rv = new NetIO_FTP (url);
- break;
- case file:
- rv = new NetIO_File (url);
- break;
- default:
- mbox (NULL, "Protocol not handled by legacy URL handler", "Cygwin Setup", MB_OK);
- }
- }
if (rv && !rv->ok ())
{
@@ -304,8 +286,6 @@ NetIO::net_method_name ()
return "Direct";
case IDC_NET_PROXY:
return "Proxy";
- case IDC_NET_DIRECT_LEGACY:
- return "Direct (legacy)";
default:
return "Unknown";
}
diff --git a/nio-ftp.cc b/nio-ftp.cc
deleted file mode 100644
index 65625d5..0000000
--- a/nio-ftp.cc
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * A copy of the GNU General Public License can be found at
- * http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-/* This file is responsible for implementing all direct FTP protocol
- channels. It is intentionally simplistic. */
-
-#include "nio-ftp.h"
-
-#include "LogSingleton.h"
-
-#include "win32.h"
-#include <winsock2.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "resource.h"
-#include "state.h"
-#include "simpsock.h"
-
-static SimpleSocket *cmd = 0;
-static char *cmd_host = 0;
-static int cmd_port = 0;
-
-static char *last_line;
-
-static int
-ftp_line (SimpleSocket * s)
-{
- do
- {
- last_line = s->gets ();
- Log (LOG_BABBLE) << "ftp > " << (last_line ? last_line : "error")
- << endLog;
- }
- while (last_line && (!isdigit (last_line[0]) || last_line[3] != ' '));
- return atoi (last_line ? : "0");
-}
-
-NetIO_FTP::NetIO_FTP (char const *Purl):NetIO (Purl)
-{
- s = 0;
- int
- code;
-
- if (port == 0)
- port = 21;
-
-control_reconnect:
- if ((cmd_host && strcmp (host, cmd_host) != 0) || port != cmd_port)
- {
- if (cmd)
- cmd->printf ("QUIT\r\n");
- delete cmd;
- delete [] cmd_host;
- cmd = 0;
- cmd_host = 0;
- }
-
- if (cmd == 0)
- {
- SimpleSocket *
- c = new SimpleSocket (host, port);
- code = ftp_line (c);
-
- auth_retry:
- if (net_ftp_user)
- c->printf ("USER %s\r\n", net_ftp_user);
- else
- c->printf ("USER anonymous\r\n");
- code = ftp_line (c);
- if (code == 331)
- {
- if (net_ftp_passwd)
- c->printf ("PASS %s\r\n", net_ftp_passwd);
- else
- c->printf ("PASS cygwin-setup@\r\n");
- code = ftp_line (c);
- }
- if (code == 530) /* Authentication failed, retry */
- {
- get_ftp_auth (NULL);
- if (net_ftp_user && net_ftp_passwd)
- goto auth_retry;
- }
-
- if (code < 200 || code >= 300)
- {
- delete
- c;
- return;
- }
-
- cmd = c;
- cmd_host = new char [strlen (host) + 1];
- strcpy (cmd_host, host);
- cmd_port = port;
-
- cmd->printf ("TYPE I\r\n");
- code = ftp_line (cmd);
- }
-
- cmd->printf ("PASV\r\n");
- do
- {
- code = ftp_line (cmd);
- }
- while (code == 226); /* previous RETR */
- if (code == 421) /* Timeout, retry */
- {
- Log (LOG_BABBLE) << "FTP timeout -- reconnecting" << endLog;
- delete [] cmd_host;
- cmd_host = new char[1]; cmd_host[0] = '\0';
- goto control_reconnect;
- }
- if (code != 227)
- return;
-
- char *
- digit = strpbrk (last_line + 3, "0123456789");
- if (!digit)
- return;
-
- int
- i1, i2, i3, i4, p1, p2;
- sscanf (digit, "%d,%d,%d,%d,%d,%d", &i1, &i2, &i3, &i4, &p1, &p2);
- char
- tmp[20];
- sprintf (tmp, "%d.%d.%d.%d", i1, i2, i3, i4);
- s = new SimpleSocket (tmp, p1 * 256 + p2);
-
- cmd->printf ("RETR %s\r\n", path);
- code = ftp_line (cmd);
- if (code != 150 && code != 125)
- {
- delete
- s;
- s = 0;
- return;
- }
-}
-
-NetIO_FTP::~NetIO_FTP ()
-{
- if (s)
- delete s;
-}
-
-int
-NetIO_FTP::ok ()
-{
- if (s && s->ok ())
- return 1;
- return 0;
-}
-
-int
-NetIO_FTP::read (char *buf, int nbytes)
-{
- int rv;
- if (!ok ())
- return 0;
- rv = s->read (buf, nbytes);
- if (rv == 0)
- ftp_line (cmd);
- return rv;
-}
diff --git a/nio-ftp.h b/nio-ftp.h
deleted file mode 100644
index 6944fc1..0000000
--- a/nio-ftp.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * A copy of the GNU General Public License can be found at
- * http://www.gnu.org/
- *
- * Written by DJ Delorie <dj@cygnus.com>
- *
- */
-
-#ifndef SETUP_NIO_FTP_H
-#define SETUP_NIO_FTP_H
-
-#include "netio.h"
-
-/* Direct FTP (without proxy) */
-
-class SimpleSocket;
-
-class NetIO_FTP:public NetIO
-{
- SimpleSocket *s;
-
-public:
- NetIO_FTP (char const *url);
- virtual ~ NetIO_FTP ();
-
- /* If !ok() that means the transfer isn't happening. */
- virtual int ok ();
-
- /* Read `nbytes' bytes from the file. Returns zero when the file
- is complete. */
- virtual int read (char *buf, int nbytes);
-};
-
-#endif /* SETUP_NIO_FTP_H */
diff --git a/res.rc b/res.rc
index 5b7d239..d89dd33 100644
--- a/res.rc
+++ b/res.rc
@@ -163,8 +163,6 @@ BEGIN
BS_AUTORADIOBUTTON | WS_TABSTOP,60,70,73,10
CONTROL "Use HTTP/FTP &Proxy:",IDC_NET_PROXY,"Button",
BS_AUTORADIOBUTTON | WS_TABSTOP,60,85,88,10
- CONTROL "&Direct Connection (legacy)",IDC_NET_DIRECT_LEGACY,"Button",
- BS_AUTORADIOBUTTON | WS_TABSTOP,60,150,94,10
EDITTEXT IDC_PROXY_HOST,120,105,120,12,ES_AUTOHSCROLL |
WS_DISABLED | WS_GROUP
EDITTEXT IDC_PROXY_PORT,120,125,30,12,ES_AUTOHSCROLL |
diff --git a/resource.h b/resource.h
index 70d90ca..59c19da 100644
--- a/resource.h
+++ b/resource.h
@@ -176,6 +176,5 @@
#define IDC_FILE_INUSE_EDIT 590
#define IDC_FILE_INUSE_MSG 591
#define IDC_FILE_INUSE_HELP 592
-#define IDC_NET_DIRECT_LEGACY 593
#define IDC_DOWNLOAD_EDIT 594
#define IDC_CHOOSE_DO_SEARCH 595
--
2.14.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH setup 4/5] Add Proxy class
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 3/5] Remove NetIO_File SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 1/5] Remove direct(legacy) connection type SZAVAI Gyula
@ 2018-01-26 16:56 ` SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG SZAVAI Gyula
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-26 16:56 UTC (permalink / raw)
To: cygwin-apps
---
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Remove legacy networking code
2018-01-19 14:18 ` Jon Turney
2018-01-22 19:28 ` szgyg
@ 2018-01-26 16:56 ` SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 3/5] Remove NetIO_File SZAVAI Gyula
` (5 more replies)
1 sibling, 6 replies; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-26 16:56 UTC (permalink / raw)
To: cygwin-apps
[PATCH setup 1/5] Remove direct(legacy) connection type
[PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG
[PATCH setup 3/5] Remove NetIO_File
[PATCH setup 4/5] Add Proxy class
[PATCH setup 5/5] Remove NetIO_HTTP
ConnectionSetting.cc | 11 ++---
Makefile.am | 6 ---
net.cc | 17 +++----
netio.cc | 42 ++++-------------
nio-file.cc | 64 --------------------------
nio-file.h | 31 -------------
nio-ftp.cc | 179 ------------------------------------------------------------------------
nio-ftp.h | 41 -----------------
nio-http.cc | 208 ------------------------------------------------------------------------------------
nio-http.h | 39 ----------------
nio-ie5.cc | 89 +++++++++++++++++++++++++++++-------
nio-ie5.h | 2 +-
res.rc | 4 +-
resource.h | 3 +-
14 files changed, 96 insertions(+), 640 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
` (2 preceding siblings ...)
2018-01-26 16:56 ` [PATCH setup 4/5] Add Proxy class SZAVAI Gyula
@ 2018-01-26 16:56 ` SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 5/5] Remove NetIO_HTTP SZAVAI Gyula
2018-01-28 21:47 ` Remove legacy networking code Jon Turney
5 siblings, 0 replies; 11+ messages in thread
From: SZAVAI Gyula @ 2018-01-26 16:56 UTC (permalink / raw)
To: cygwin-apps
---
ConnectionSetting.cc | 6 +++---
net.cc | 10 +++++-----
netio.cc | 6 +++---
res.rc | 2 +-
resource.h | 2 +-
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/ConnectionSetting.cc b/ConnectionSetting.cc
index 5baf76c..2370a20 100644
--- a/ConnectionSetting.cc
+++ b/ConnectionSetting.cc
@@ -39,7 +39,7 @@ ConnectionSetting::~ConnectionSetting ()
case IDC_NET_DIRECT:
UserSettings::instance().set("net-method", "Direct");
break;
- case IDC_NET_IE5:
+ case IDC_NET_PRECONFIG:
UserSettings::instance().set("net-method", "IE");
break;
case IDC_NET_PROXY:
@@ -60,10 +60,10 @@ ConnectionSetting::typeFromString(const std::string& aType)
if (!casecompare(aType, "Direct"))
return IDC_NET_DIRECT;
if (!casecompare(aType, "IE"))
- return IDC_NET_IE5;
+ return IDC_NET_PRECONFIG;
if (!casecompare(aType, "Proxy"))
return IDC_NET_PROXY;
/* A sanish default */
- return IDC_NET_IE5;
+ return IDC_NET_PRECONFIG;
}
diff --git a/net.cc b/net.cc
index 5ff3713..ad497ca 100644
--- a/net.cc
+++ b/net.cc
@@ -37,7 +37,7 @@ extern ThreeBarProgressPage Progress;
static StringOption ProxyOption ("", 'p', "proxy", "HTTP/FTP proxy (host:port)", false);
-static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
+static int rb[] = { IDC_NET_PRECONFIG, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
static bool doing_loading = false;
void
@@ -46,7 +46,7 @@ NetPage::CheckIfEnableNext ()
int e = 0, p = 0;
DWORD ButtonFlags = PSWIZB_BACK;
- if (NetIO::net_method == IDC_NET_IE5 ||
+ if (NetIO::net_method == IDC_NET_PRECONFIG ||
NetIO::net_method == IDC_NET_DIRECT)
e = 1;
else if (NetIO::net_method == IDC_NET_PROXY)
@@ -111,7 +111,7 @@ NetPage::OnInit ()
std::string proxyString (ProxyOption);
if (!NetIO::net_method)
- NetIO::net_method = IDC_NET_IE5;
+ NetIO::net_method = IDC_NET_PRECONFIG;
if (proxyString.size ())
{
@@ -132,7 +132,7 @@ NetPage::OnInit ()
// Check to see if any radio buttons are selected. If not, select a default.
if (SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_GETCHECK, 0, 0) != BST_CHECKED
&& SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0) != BST_CHECKED)
- SendMessage (GetDlgItem (IDC_NET_IE5), BM_CLICK, 0, 0);
+ SendMessage (GetDlgItem (IDC_NET_PRECONFIG), BM_CLICK, 0, 0);
}
long
@@ -164,7 +164,7 @@ NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
{
switch (id)
{
- case IDC_NET_IE5:
+ case IDC_NET_PRECONFIG:
case IDC_NET_DIRECT:
case IDC_NET_PROXY:
case IDC_PROXY_HOST:
diff --git a/netio.cc b/netio.cc
index 86bb69a..6c357fc 100644
--- a/netio.cc
+++ b/netio.cc
@@ -140,7 +140,7 @@ NetIO::open (char const *url, bool cachable)
if (proto == file)
rv = new NetIO_File (url);
- else if (net_method == IDC_NET_IE5)
+ else if (net_method == IDC_NET_PRECONFIG)
rv = new NetIO_IE5 (url, false, cachable);
else if (net_method == IDC_NET_PROXY)
rv = new NetIO_HTTP (url);
@@ -280,8 +280,8 @@ NetIO::net_method_name ()
{
switch (net_method)
{
- case IDC_NET_IE5:
- return "IE5";
+ case IDC_NET_PRECONFIG:
+ return "Preconfig";
case IDC_NET_DIRECT:
return "Direct";
case IDC_NET_PROXY:
diff --git a/res.rc b/res.rc
index d89dd33..dfcc4f4 100644
--- a/res.rc
+++ b/res.rc
@@ -157,7 +157,7 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_CHILD | WS_CAPTION | WS_SYSMENU
CAPTION "Cygwin Setup - Select Connection Type"
FONT 8, "MS Shell Dlg"
BEGIN
- CONTROL "Use &System Proxy Settings",IDC_NET_IE5,"Button",
+ CONTROL "Use &System Proxy Settings",IDC_NET_PRECONFIG,"Button",
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,60,55,185,10
CONTROL "&Direct Connection",IDC_NET_DIRECT,"Button",
BS_AUTORADIOBUTTON | WS_TABSTOP,60,70,73,10
diff --git a/resource.h b/resource.h
index 59c19da..12c2b0b 100644
--- a/resource.h
+++ b/resource.h
@@ -98,7 +98,7 @@
#define IDC_SITE_NEXT 508
#define IDC_BACK 509
#define IDC_OTHER_URL 510
-#define IDC_NET_IE5 511
+#define IDC_NET_PRECONFIG 511
#define IDC_NET_DIRECT 512
#define IDC_NET_PROXY 513
#define IDC_PROXY_HOST 514
--
2.14.3
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Remove legacy networking code
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
` (4 preceding siblings ...)
2018-01-26 16:56 ` [PATCH setup 5/5] Remove NetIO_HTTP SZAVAI Gyula
@ 2018-01-28 21:47 ` Jon Turney
2018-02-24 15:33 ` Jon Turney
5 siblings, 1 reply; 11+ messages in thread
From: Jon Turney @ 2018-01-28 21:47 UTC (permalink / raw)
To: cygwin-apps; +Cc: SZAVAI Gyula
On 26/01/2018 16:56, SZAVAI Gyula wrote:
> [PATCH setup 1/5] Remove direct(legacy) connection type
> [PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG
> [PATCH setup 3/5] Remove NetIO_File
> [PATCH setup 4/5] Add Proxy class
> [PATCH setup 5/5] Remove NetIO_HTTP
Thanks, this is great.
A few minor comments:
1/5:
It would be nice if you'd said in the patch commentary what will happen
to existing installations which are configured to use direct(legacy) -
they get converted to preconfig.
3/5:
This changes to wininet handling all file access (converting raw paths
into file:// format URLs)
I had some concerns [1] that this maybe changes the set of malformed
file:// URLs we handle (which is ok, although it would be nice to know
the details), and still doesn't handle correctly formed ones.
[1] https://cygwin.com/ml/cygwin-apps/2017-05/msg00117.html
4/5:
operator!= could probably use a comment along the lines of "it's only
meaningful to compare host:port if IDC_NET_PROXY"
It's unclear to me what Proxy::bypass() is doing. MSDN actually says
"Do not use an empty string", for unclear reasons.
We can also remove simpsock.{cc,h} and linking with winsock, after this
series.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Remove legacy networking code
2018-01-28 21:47 ` Remove legacy networking code Jon Turney
@ 2018-02-24 15:33 ` Jon Turney
0 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2018-02-24 15:33 UTC (permalink / raw)
To: cygwin-apps, SZAVAI Gyula
On 28/01/2018 21:47, Jon Turney wrote:
> On 26/01/2018 16:56, SZAVAI Gyula wrote:
>> [PATCH setup 1/5] Remove direct(legacy) connection type
>> [PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG
>> [PATCH setup 3/5] Remove NetIO_File
>> [PATCH setup 4/5] Add Proxy class
>> [PATCH setup 5/5] Remove NetIO_HTTP
>
> Thanks, this is great.
I applied this patch series to setup, with a few tweaks to address my
comments.
Sorry about the delay and thanks again!
>
> A few minor comments:
>
> 1/5:
>
> It would be nice if you'd said in the patch commentary what will happen
> to existing installations which are configured to use direct(legacy) -
> they get converted to preconfig.
>
> 3/5:
>
> This changes to wininet handling all file access (converting raw paths
> into file:// format URLs)
>
> I had some concerns [1] that this maybe changes the set of malformed
> file:// URLs we handle (which is ok, although it would be nice to know
> the details), and still doesn't handle correctly formed ones.
>
> [1] https://cygwin.com/ml/cygwin-apps/2017-05/msg00117.html
>
> 4/5:
>
> operator!= could probably use a comment along the lines of "it's only
> meaningful to compare host:port if IDC_NET_PROXY"
>
> It's unclear to me what Proxy::bypass() is doing. MSDN actually says
> "Do not use an empty string", for unclear reasons.
>
> We can also remove simpsock.{cc,h} and linking with winsock, after this
> series.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-02-24 15:33 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 19:15 [PATCH setup] Send User-Agent even when setup-specific proxy is used SZAVAI Gyula
2018-01-19 14:18 ` Jon Turney
2018-01-22 19:28 ` szgyg
2018-01-26 16:56 ` Remove legacy networking code SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 3/5] Remove NetIO_File SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 1/5] Remove direct(legacy) connection type SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 4/5] Add Proxy class SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 2/5] Rename IDC_NET_IE5 to IDC_NET_PRECONFIG SZAVAI Gyula
2018-01-26 16:56 ` [PATCH setup 5/5] Remove NetIO_HTTP SZAVAI Gyula
2018-01-28 21:47 ` Remove legacy networking code Jon Turney
2018-02-24 15:33 ` Jon Turney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).