10ed5851072ff7a4c8ab8021f0baa1dd578feef4 galt Thu Mar 23 22:56:06 2017 -0700 added logProxy=on setting to hg.conf to help confirm that the proxy is actually doing the expected thing. Not meant to be left on in production. refs #19124 diff --git src/lib/net.c src/lib/net.c index a4492d0..5f604f5 100644 --- src/lib/net.c +++ src/lib/net.c @@ -169,31 +169,31 @@ { // Socket selected for write when it is ready int valOpt; socklen_t lon; // But check the socket for any errors lon = sizeof(valOpt); if (getsockopt(sd, SOL_SOCKET, SO_ERROR, (void*) (&valOpt), &lon) < 0) { warn("Error in getsockopt() %d - %s", errno, strerror(errno)); close(sd); return -1; } // Check the value returned... if (valOpt) { - warn("Error in TCP non-blocking connect() %d - %s", valOpt, strerror(valOpt)); + warn("Error in TCP non-blocking connect() %d - %s. Host %s port %d.", valOpt, strerror(valOpt), hostName, port); close(sd); return -1; } break; } else { warn("TCP non-blocking connect() to %s timed-out in select() after %ld milliseconds - Cancelling!", hostName, msTimeout); close(sd); return -1; } } } else { @@ -969,35 +969,37 @@ struct netParsedUrl pxy; netParseUrl(url, &npu); if (!sameString(npu.protocol, "ftp")) errAbort("netGetOpenFtpSockets: url (%s) is not for ftp.", url); boolean noProxy = checkNoProxy(npu.host); char *proxyUrl = getenv("ftp_proxy"); if (noProxy) proxyUrl = NULL; int sd = -1; if (proxyUrl) { netParseUrl(proxyUrl, &pxy); if (!sameString(pxy.protocol, "ftp")) - errAbort("Unknown proxy protocol %s in %s.", pxy.protocol, proxyUrl); + errAbort("Unknown proxy protocol %s in %s. Should be ftp.", pxy.protocol, proxyUrl); char proxyUser[4096]; safef(proxyUser, sizeof proxyUser, "%s@%s:%s", npu.user, npu.host, npu.port); sd = openFtpControlSocket(pxy.host, atoi(pxy.port), proxyUser, npu.password); - verbose(2, "%s as %s via proxy %s\n", url, proxyUser, proxyUrl); + char *logProxy = getenv("log_proxy"); + if (sameOk(logProxy,"on")) + verbose(1, "%s as %s via proxy %s\n", url, proxyUser, proxyUrl); } else { sd = openFtpControlSocket(npu.host, atoi(npu.port), npu.user, npu.password); } if (sd == -1) return -1; struct dyString *rs = NULL; if (!sendFtpCommand(sd, "PASV\r\n", &rs, NULL)) { close(sd); return -1; } @@ -1155,31 +1157,33 @@ /* Parse the URL and connect. */ netParseUrl(url, &npu); boolean noProxy = checkNoProxy(npu.host); char *proxyUrl = getenv("http_proxy"); if (sameString(npu.protocol, "https")) proxyUrl = NULL; if (noProxy) proxyUrl = NULL; if (proxyUrl) { netParseUrl(proxyUrl, &pxy); if (!sameString(pxy.protocol, "http")) errAbort("Unknown proxy protocol %s in %s.", pxy.protocol, proxyUrl); sd = connectNpu(pxy, url, noProxy); - verbose(2, "%s via proxy %s\n", url, proxyUrl); + char *logProxy = getenv("log_proxy"); + if (sameOk(logProxy,"on")) + verbose(1, "%s via proxy %s\n", url, proxyUrl); } else { sd = connectNpu(npu, url, noProxy); } if (sd < 0) return -1; /* Ask remote server for a file. */ char *urlForProxy = NULL; if (proxyUrl) { /* trim off the byterange part at the end of url because proxy does not understand it. */ urlForProxy = cloneString(url); char *x = strrchr(urlForProxy, ';');