summaryrefslogtreecommitdiff
path: root/lib/connect.c
Commit message (Collapse)AuthorAgeFilesLines
* Curl_timeleft: change return type to timediff_tbagder/timeleft-timediff_tDaniel Stenberg2017-10-271-5/+5
| | | | | | returning 'time_t' was problematic when that type is unsigned and we check values less than zero to detect "already expired" on several places in the code.
* time: rename Curl_tvnow to Curl_nowDaniel Stenberg2017-10-251-4/+4
| | | | | | | | | | ... since the 'tv' stood for timeval and this function does not return a timeval struct anymore. Also, cleaned up the Curl_timediff*() functions to avoid typecasts and clean up the descriptive comments. Closes #2011
* timediff: return timediff_t from the time diff functionsDaniel Stenberg2017-10-251-4/+4
| | | | | | | | | | | | | | | ... to cater for systems with unsigned time_t variables. - Renamed the functions to curlx_timediff and Curl_timediff_us. - Added overflow protection for both of them in either direction for both 32 bit and 64 bit time_ts - Reprefixed the curlx_time functions to use Curl_* Reported-by: Peter Piekarski Fixes #2004 Closes #2005
* connect: fix race condition with happy eyeballs timeoutAnders Bakken2017-09-291-1/+1
| | | | | | | | | | | The timer should be started after conn->connecttime is set. Otherwise the timer could expire without this condition being true: /* should we try another protocol family? */ if(i == 0 && conn->tempaddr[1] == NULL && curlx_tvdiff(now, conn->connecttime) >= HAPPY_EYEBALLS_TIMEOUT) { Ref: #1928
* code style: use spaces around plusesDaniel Stenberg2017-09-111-1/+1
|
* code style: use spaces around equals signsDaniel Stenberg2017-09-111-4/+4
|
* configure: check for __builtin_available() availability (#1788)Nick Zitzmann2017-08-161-10/+19
| | | | | | | This change does two things: 1. It un-breaks the build in Xcode 9.0. (Xcode 9.0 is currently failing trying to compile connectx() in lib/connect.c.) 2. It finally weak-links the connectx() function, and falls back on connect() when run on older operating systems.
* timeval: struct curltime is a struct timeval replacementDaniel Stenberg2017-07-281-4/+4
| | | | | | | | | ... to make all libcurl internals able to use the same data types for the struct members. The timeval struct differs subtly on several platforms so it makes it cumbersome to use everywhere. Ref: #1652 Closes #1693
* curl_setup_once: Remove ERRNO/SET_ERRNO macrosJay Satiro2017-07-101-12/+8
| | | | | | | | | | | | Prior to this change (SET_)ERRNO mapped to GetLastError/SetLastError for Win32 and regular errno otherwise. I reviewed the code and found no justifiable reason for conflating errno on WIN32 with GetLastError/SetLastError. All Win32 CRTs support errno, and any Win32 multithreaded CRT supports thread-local errno. Fixes https://github.com/curl/curl/issues/895 Closes https://github.com/curl/curl/pull/1589
* configure: remove checks for 5 functions never usedDaniel Stenberg2017-07-041-13/+0
| | | | | | fork, getprotobyname, inet_addr, perror, uname closes #1638
* expire: remove Curl_expire_latest()Daniel Stenberg2017-06-081-1/+1
| | | | | | | | | | | | | | | | | With the introduction of expire IDs and the fact that existing timers can be removed now and thus never expire, the concept with adding a "latest" timer is not working anymore as it risks to not expire at all. So, to be certain the timers actually are in line and will expire, the plain Curl_expire() needs to be used. The _latest() function was added as a sort of shortcut in the past that's quite simply not necessary anymore. Follow-up to 31b39c40cf90 Reported-by: Paul Harris Closes #1555
* multi: assign IDs to all timers and make each timer singletonDaniel Stenberg2017-05-101-3/+3
| | | | | | | A) reduces the timeout lists drastically B) prevents a lot of superfluous loops for timers that expires "in vain" when it has actually already been extended to fire later on
* connect: fix unreferenced parameter warningMarcel Raad2017-03-301-1/+1
| | | | | When CURL_DISABLE_VERBOSE_STRINGS is defined, the reason parameter in Curl_conncontrol is not used as the infof macro expands to nothing.
* Improve code readbilitySylvestre Ledru2017-03-131-2/+1
| | | | | | ... by removing the else branch after a return, break or continue. Closes #1310
* http_proxy: Fix proxy CONNECT hang on pending dataJay Satiro2016-12-191-0/+13
| | | | | | | - Check for pending data before waiting on the socket. Bug: https://github.com/curl/curl/issues/1156 Reported-by: Adam Langley
* Curl_getconnectinfo: avoid checking if the connection is closedIsaac Boukris2016-12-181-18/+27
| | | | | | | | | | It doesn't benefit us much as the connection could get closed at any time, and also by checking we lose the ability to determine if the socket was closed by reading zero bytes. Reported-by: Michael Kaufmann Closes https://github.com/curl/curl/pull/1134
* checksrc: stricter no-space-before-paren enforcementDaniel Stenberg2016-12-131-2/+2
| | | | In order to make the code style more uniform everywhere
* add CURLINFO_SCHEME, CURLINFO_PROTOCOL, and %{scheme}Frank Gevaerts2016-11-251-0/+2
| | | | | | | | | | | | | | Adds access to the effectively used protocol/scheme to both libcurl and curl, both in string and numeric (CURLPROTO_*) form. Note that the string form will be uppercase, as it is just the internal string. As these strings are declared internally as const, and all other strings returned by curl_easy_getinfo() are de-facto const as well, string handling in getinfo.c got const-ified. Closes #1137
* checksrc: white space edits to comply to stricter checksrcDaniel Stenberg2016-11-241-5/+5
|
* checksrc: code style: use 'char *name' styleDaniel Stenberg2016-11-241-3/+3
|
* proxy: Support HTTPS proxy and SOCKS+HTTP(s)Alex Rousskov2016-11-241-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * HTTPS proxies: An HTTPS proxy receives all transactions over an SSL/TLS connection. Once a secure connection with the proxy is established, the user agent uses the proxy as usual, including sending CONNECT requests to instruct the proxy to establish a [usually secure] TCP tunnel with an origin server. HTTPS proxies protect nearly all aspects of user-proxy communications as opposed to HTTP proxies that receive all requests (including CONNECT requests) in vulnerable clear text. With HTTPS proxies, it is possible to have two concurrent _nested_ SSL/TLS sessions: the "outer" one between the user agent and the proxy and the "inner" one between the user agent and the origin server (through the proxy). This change adds supports for such nested sessions as well. A secure connection with a proxy requires its own set of the usual SSL options (their actual descriptions differ and need polishing, see TODO): --proxy-cacert FILE CA certificate to verify peer against --proxy-capath DIR CA directory to verify peer against --proxy-cert CERT[:PASSWD] Client certificate file and password --proxy-cert-type TYPE Certificate file type (DER/PEM/ENG) --proxy-ciphers LIST SSL ciphers to use --proxy-crlfile FILE Get a CRL list in PEM format from the file --proxy-insecure Allow connections to proxies with bad certs --proxy-key KEY Private key file name --proxy-key-type TYPE Private key file type (DER/PEM/ENG) --proxy-pass PASS Pass phrase for the private key --proxy-ssl-allow-beast Allow security flaw to improve interop --proxy-sslv2 Use SSLv2 --proxy-sslv3 Use SSLv3 --proxy-tlsv1 Use TLSv1 --proxy-tlsuser USER TLS username --proxy-tlspassword STRING TLS password --proxy-tlsauthtype STRING TLS authentication type (default SRP) All --proxy-foo options are independent from their --foo counterparts, except --proxy-crlfile which defaults to --crlfile and --proxy-capath which defaults to --capath. Curl now also supports %{proxy_ssl_verify_result} --write-out variable, similar to the existing %{ssl_verify_result} variable. Supported backends: OpenSSL, GnuTLS, and NSS. * A SOCKS proxy + HTTP/HTTPS proxy combination: If both --socks* and --proxy options are given, Curl first connects to the SOCKS proxy and then connects (through SOCKS) to the HTTP or HTTPS proxy. TODO: Update documentation for the new APIs and --proxy-* options. Look for "Added in 7.XXX" marks.
* lib: fix compiler warnings after de4de4e3c7cMarcel Raad2016-11-181-6/+6
| | | | | | | | | Visual C++ now complains about implicitly casting time_t (64-bit) to long (32-bit). Fix this by changing some variables from long to time_t, or explicitly casting to long where the public interface would be affected. Closes #1131
* select: switch to macros in uppercaseDaniel Stenberg2016-10-181-1/+1
| | | | | | | | | | Curl_select_ready() was the former API that was replaced with Curl_select_check() a while back and the former arg setup was provided with a define (in order to leave existing code unmodified). Now we instead offer SOCKET_READABLE and SOCKET_WRITABLE for the most common shortcuts where only one socket is checked. They're also more visibly macros.
* win: fix Universal Windows Platform buildMarcel Raad2016-10-161-3/+0
| | | | | | | | | | | | | | | This fixes a merge error in commit 7f3df80 caused by commit 332e8d6. Additionally, this changes Curl_verify_windows_version for Windows App builds to assume to always be running on the target Windows version. There seems to be no way to determine the Windows version from a UWP app. Neither GetVersion(Ex), nor VerifyVersionInfo, nor the Version Helper functions are supported. Bug: https://github.com/curl/curl/pull/820#issuecomment-250889878 Reported-by: Paul Joyce Closes https://github.com/curl/curl/pull/1048
* connect: fix #ifdefs for debug versions of conn/streamclose() macrosDaniel Stenberg2016-08-301-1/+1
| | | | | | | | CURLDEBUG is for the memory debugging DEBUGBUILD is for the extra debug stuff Pointed-out-by: Steve Holme
* http2: make sure stream errors don't needlessly close the connectionDaniel Stenberg2016-08-281-15/+16
| | | | | | | | With HTTP/2 each transfer is made in an indivial logical stream over the connection, making most previous errors that caused the connection to get forced-closed now instead just kill the stream and not the connection. Fixes #941
* win: Basic support for Universal Windows Platform appsMarco Deckel2016-08-211-0/+3
| | | | Closes #820
* connect: disable TFO on Linux when using SSLJay Satiro2016-07-201-1/+4
| | | | | | - Linux TFO + TLS is not implemented yet. Bug: https://github.com/curl/curl/issues/907
* internals: rename the SessionHandle struct to Curl_easyDaniel Stenberg2016-06-221-12/+12
|
* connect.c: Fixed compilation warning from commit 332e8d6164Steve Holme2016-06-041-1/+2
| | | | connect.c:952:5: warning: suggest explicit braces to avoid ambiguous 'else'
* win32: Used centralised verify windows version functionSteve Holme2016-06-041-32/+4
| | | | Closes #845
* connect: fix invalid "Network is unreachable" errorsAntonio Larrosa2016-05-081-0/+1
| | | | | | | | | | | | | | Sometimes, in systems with both ipv4 and ipv6 addresses but where the network doesn't support ipv6, Curl_is_connected returns an error (intermittently) even if the ipv4 socket connects successfully. This happens because there's a for-loop that iterates on the sockets but the error variable is not resetted when the ipv4 is checked and is ok. This patch fixes this problem by setting error to 0 when checking the second socket and not having a result yet. Fixes #794
* lib: include curl_printf.h as one of the last headersDaniel Stenberg2016-04-291-2/+2
| | | | | | | | | | | | | | | | | | | | curl_printf.h defines printf to curl_mprintf, etc. This can cause problems with external headers which may use __attribute__((format(printf, ...))) markers etc. To avoid that they cause problems with system includes, we include curl_printf.h after any system headers. That makes the three last headers to always be, and we keep them in this order: curl_printf.h curl_memory.h memdebug.h None of them include system headers, they all do funny #defines. Reported-by: David Benjamin Fixes #743
* connect: make sure that rc is initialized in singleipconnect()Kamil Dudka2016-04-191-1/+1
| | | | | | | | | | | | This commit fixes a Clang warning introduced in curl-7_48_0-190-g8f72b13: Error: CLANG_WARNING: lib/connect.c:1120:11: warning: The right operand of '==' is a garbage value 1118| } 1119| 1120|-> if(-1 == rc) 1121| error = SOCKERRNO; 1122| }
* connect: implement TCP Fast Open for LinuxAlessandro Ghedini2016-04-181-2/+4
| | | | Closes #660
* connect: implement TCP Fast Open for OS XAlessandro Ghedini2016-04-181-1/+18
|
* news: CURLOPT_CONNECT_TO and --connect-toMichael Kaufmann2016-04-171-2/+10
| | | | | Makes curl connect to the given host+port instead of the host+port found in the URL.
* connect/ntlm/http: Fixed compilation warnings when verbose strings disabledSteve Holme2016-03-201-3/+9
| | | | warning C4189: 'data': local variable is initialized but not referenced
* URLs: change more http to httpsViktor Szakats2016-02-041-1/+1
|
* URLs: change all http:// URLs to https://Daniel Stenberg2016-02-031-1/+1
|
* getconnectinfo: Don't call recv(2) if socket == -1Anders Bakken2015-11-161-2/+2
| | | | Closes #528
* http2: set TCP_NODELAY unconditionallyDaniel Stenberg2015-09-271-4/+3
| | | | | | For a single-stream download from localhost, we managed to increase transfer speed from 1.6MB/sec to around 400MB/sec, mostly because of this single fix.
* build: fix failures with -Wcast-align and -WerrorTatsuhiro Tsujikawa2015-09-261-2/+2
| | | | Closes #457
* win32: Fix compilation warnings from commit 40c921f8b8Steve Holme2015-08-011-1/+5
| | | | | | | | | | | connect.c:953:5: warning: initializer element is not computable at load time connect.c:953:5: warning: missing initializer for field 'dwMinorVersion' of 'OSVERSIONINFOEX' curl_sspi.c:97:5: warning: initializer element is not computable at load time curl_sspi.c:97:5: warning: missing initializer for field 'szCSDVersion' of 'OSVERSIONINFOEX'
* Windows: Fix VerifyVersionInfo callsJay Satiro2015-07-221-8/+9
| | | | | | | | | | | | | | - Fix the VerifyVersionInfo calls, which we use to test for the OS major version, to also test for the minor version as well as the service pack major and minor versions. MSDN: "If you are testing the major version, you must also test the minor version and the service pack major and minor versions." https://msdn.microsoft.com/en-us/library/windows/desktop/ms725492.aspx Bug: https://github.com/bagder/curl/pull/353#issuecomment-123493098 Reported-by: Marcel Raad <MarcelRaad@users.noreply.github.com>
* CURLOPT_OPENSOCKETFUNCTION: return error at onceDaniel Stenberg2015-06-091-1/+4
| | | | | | | | When CURL_SOCKET_BAD is returned in the callback, it should be treated as an error (CURLE_COULDNT_CONNECT) if no other socket is subsequently created when trying to connect to a server. Bug: http://curl.haxx.se/mail/lib-2015-06/0047.html
* connection cache: avoid Curl_hash_alloc()Daniel Stenberg2015-05-121-2/+2
| | | | | ... by using plain structs instead of pointers for the connection cache, we can avoid several dynamic allocations that weren't necessary.
* curl_memory: make curl_memory.h the second-last header file loadedDan Fandrich2015-03-241-2/+2
| | | | | | | This header file must be included after all header files except memdebug.h, as it does similar memory function redefinitions and can be similarly affected by conflicting definitions in system or dependent library headers.
* curl_easy_recv/send: make them work with the multi interfaceYamada Yasuharu2015-03-231-4/+9
| | | | | By making sure Curl_getconnectinfo() uses the correct connection cache to find the last connection.
* checksrc: use space after commaDaniel Stenberg2015-03-171-2/+2
|