[164] | 1 | /***************************************************************************
|
---|
| 2 | * _ _ ____ _
|
---|
| 3 | * Project ___| | | | _ \| |
|
---|
| 4 | * / __| | | | |_) | |
|
---|
| 5 | * | (__| |_| | _ <| |___
|
---|
| 6 | * \___|\___/|_| \_\_____|
|
---|
| 7 | *
|
---|
| 8 | * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
---|
| 9 | *
|
---|
| 10 | * This software is licensed as described in the file COPYING, which
|
---|
| 11 | * you should have received as part of this distribution. The terms
|
---|
| 12 | * are also available at https://curl.haxx.se/docs/copyright.html.
|
---|
| 13 | *
|
---|
| 14 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
---|
| 15 | * copies of the Software, and permit persons to whom the Software is
|
---|
| 16 | * furnished to do so, under the terms of the COPYING file.
|
---|
| 17 | *
|
---|
| 18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
---|
| 19 | * KIND, either express or implied.
|
---|
| 20 | *
|
---|
| 21 | ***************************************************************************/
|
---|
| 22 |
|
---|
| 23 | #include "curl_setup.h"
|
---|
| 24 |
|
---|
| 25 | #include <curl/curl.h>
|
---|
| 26 | #include "urldata.h"
|
---|
| 27 | #include "vtls/vtls.h"
|
---|
| 28 | #include "http2.h"
|
---|
| 29 | #include "curl_printf.h"
|
---|
| 30 |
|
---|
| 31 | #ifdef USE_ARES
|
---|
| 32 | # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
---|
| 33 | (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
|
---|
| 34 | # define CARES_STATICLIB
|
---|
| 35 | # endif
|
---|
| 36 | # include <ares.h>
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | #ifdef USE_LIBIDN
|
---|
| 40 | #include <stringprep.h>
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
| 43 | #ifdef USE_LIBPSL
|
---|
| 44 | #include <libpsl.h>
|
---|
| 45 | #endif
|
---|
| 46 |
|
---|
| 47 | #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
|
---|
| 48 | #include <iconv.h>
|
---|
| 49 | #endif
|
---|
| 50 |
|
---|
| 51 | #ifdef USE_LIBRTMP
|
---|
| 52 | #include <librtmp/rtmp.h>
|
---|
| 53 | #endif
|
---|
| 54 |
|
---|
| 55 | #ifdef USE_LIBSSH2
|
---|
| 56 | #include <libssh2.h>
|
---|
| 57 | #endif
|
---|
| 58 |
|
---|
| 59 | #ifdef HAVE_LIBSSH2_VERSION
|
---|
| 60 | /* get it run-time if possible */
|
---|
| 61 | #define CURL_LIBSSH2_VERSION libssh2_version(0)
|
---|
| 62 | #else
|
---|
| 63 | /* use build-time if run-time not possible */
|
---|
| 64 | #define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
|
---|
| 65 | #endif
|
---|
| 66 |
|
---|
| 67 | char *curl_version(void)
|
---|
| 68 | {
|
---|
| 69 | static char version[200];
|
---|
| 70 | char *ptr = version;
|
---|
| 71 | size_t len;
|
---|
| 72 | size_t left = sizeof(version);
|
---|
| 73 |
|
---|
| 74 | strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION);
|
---|
| 75 | len = strlen(ptr);
|
---|
| 76 | left -= len;
|
---|
| 77 | ptr += len;
|
---|
| 78 |
|
---|
| 79 | if(left > 1) {
|
---|
| 80 | len = Curl_ssl_version(ptr + 1, left - 1);
|
---|
| 81 |
|
---|
| 82 | if(len > 0) {
|
---|
| 83 | *ptr = ' ';
|
---|
| 84 | left -= ++len;
|
---|
| 85 | ptr += len;
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | #ifdef HAVE_LIBZ
|
---|
| 90 | len = snprintf(ptr, left, " zlib/%s", zlibVersion());
|
---|
| 91 | left -= len;
|
---|
| 92 | ptr += len;
|
---|
| 93 | #endif
|
---|
| 94 | #ifdef USE_ARES
|
---|
| 95 | /* this function is only present in c-ares, not in the original ares */
|
---|
| 96 | len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
|
---|
| 97 | left -= len;
|
---|
| 98 | ptr += len;
|
---|
| 99 | #endif
|
---|
| 100 | #ifdef USE_LIBIDN
|
---|
| 101 | if(stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
|
---|
| 102 | len = snprintf(ptr, left, " libidn/%s", stringprep_check_version(NULL));
|
---|
| 103 | left -= len;
|
---|
| 104 | ptr += len;
|
---|
| 105 | }
|
---|
| 106 | #endif
|
---|
| 107 | #ifdef USE_LIBPSL
|
---|
| 108 | len = snprintf(ptr, left, " libpsl/%s", psl_get_version());
|
---|
| 109 | left -= len;
|
---|
| 110 | ptr += len;
|
---|
| 111 | #endif
|
---|
| 112 | #ifdef USE_WIN32_IDN
|
---|
| 113 | len = snprintf(ptr, left, " WinIDN");
|
---|
| 114 | left -= len;
|
---|
| 115 | ptr += len;
|
---|
| 116 | #endif
|
---|
| 117 | #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
|
---|
| 118 | #ifdef _LIBICONV_VERSION
|
---|
| 119 | len = snprintf(ptr, left, " iconv/%d.%d",
|
---|
| 120 | _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
|
---|
| 121 | #else
|
---|
| 122 | /* version unknown */
|
---|
| 123 | len = snprintf(ptr, left, " iconv");
|
---|
| 124 | #endif /* _LIBICONV_VERSION */
|
---|
| 125 | left -= len;
|
---|
| 126 | ptr += len;
|
---|
| 127 | #endif
|
---|
| 128 | #ifdef USE_LIBSSH2
|
---|
| 129 | len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
|
---|
| 130 | left -= len;
|
---|
| 131 | ptr += len;
|
---|
| 132 | #endif
|
---|
| 133 | #ifdef USE_NGHTTP2
|
---|
| 134 | len = Curl_http2_ver(ptr, left);
|
---|
| 135 | left -= len;
|
---|
| 136 | ptr += len;
|
---|
| 137 | #endif
|
---|
| 138 | #ifdef USE_LIBRTMP
|
---|
| 139 | {
|
---|
| 140 | char suff[2];
|
---|
| 141 | if(RTMP_LIB_VERSION & 0xff) {
|
---|
| 142 | suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
|
---|
| 143 | suff[1] = '\0';
|
---|
| 144 | }
|
---|
| 145 | else
|
---|
| 146 | suff[0] = '\0';
|
---|
| 147 |
|
---|
| 148 | snprintf(ptr, left, " librtmp/%d.%d%s",
|
---|
| 149 | RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
|
---|
| 150 | suff);
|
---|
| 151 | /*
|
---|
| 152 | If another lib version is added below this one, this code would
|
---|
| 153 | also have to do:
|
---|
| 154 |
|
---|
| 155 | len = what snprintf() returned
|
---|
| 156 |
|
---|
| 157 | left -= len;
|
---|
| 158 | ptr += len;
|
---|
| 159 | */
|
---|
| 160 | }
|
---|
| 161 | #endif
|
---|
| 162 |
|
---|
| 163 | return version;
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | /* data for curl_version_info
|
---|
| 167 |
|
---|
| 168 | Keep the list sorted alphabetically. It is also written so that each
|
---|
| 169 | protocol line has its own #if line to make things easier on the eye.
|
---|
| 170 | */
|
---|
| 171 |
|
---|
| 172 | static const char * const protocols[] = {
|
---|
| 173 | #ifndef CURL_DISABLE_DICT
|
---|
| 174 | "dict",
|
---|
| 175 | #endif
|
---|
| 176 | #ifndef CURL_DISABLE_FILE
|
---|
| 177 | "file",
|
---|
| 178 | #endif
|
---|
| 179 | #ifndef CURL_DISABLE_FTP
|
---|
| 180 | "ftp",
|
---|
| 181 | #endif
|
---|
| 182 | #if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)
|
---|
| 183 | "ftps",
|
---|
| 184 | #endif
|
---|
| 185 | #ifndef CURL_DISABLE_GOPHER
|
---|
| 186 | "gopher",
|
---|
| 187 | #endif
|
---|
| 188 | #ifndef CURL_DISABLE_HTTP
|
---|
| 189 | "http",
|
---|
| 190 | #endif
|
---|
| 191 | #if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
|
---|
| 192 | "https",
|
---|
| 193 | #endif
|
---|
| 194 | #ifndef CURL_DISABLE_IMAP
|
---|
| 195 | "imap",
|
---|
| 196 | #endif
|
---|
| 197 | #if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)
|
---|
| 198 | "imaps",
|
---|
| 199 | #endif
|
---|
| 200 | #ifndef CURL_DISABLE_LDAP
|
---|
| 201 | "ldap",
|
---|
| 202 | #if !defined(CURL_DISABLE_LDAPS) && \
|
---|
| 203 | ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
|
---|
| 204 | (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
|
---|
| 205 | "ldaps",
|
---|
| 206 | #endif
|
---|
| 207 | #endif
|
---|
| 208 | #ifndef CURL_DISABLE_POP3
|
---|
| 209 | "pop3",
|
---|
| 210 | #endif
|
---|
| 211 | #if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)
|
---|
| 212 | "pop3s",
|
---|
| 213 | #endif
|
---|
| 214 | #ifdef USE_LIBRTMP
|
---|
| 215 | "rtmp",
|
---|
| 216 | #endif
|
---|
| 217 | #ifndef CURL_DISABLE_RTSP
|
---|
| 218 | "rtsp",
|
---|
| 219 | #endif
|
---|
| 220 | #ifdef USE_LIBSSH2
|
---|
| 221 | "scp",
|
---|
| 222 | #endif
|
---|
| 223 | #ifdef USE_LIBSSH2
|
---|
| 224 | "sftp",
|
---|
| 225 | #endif
|
---|
| 226 | #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
|
---|
| 227 | (CURL_SIZEOF_CURL_OFF_T > 4) && \
|
---|
| 228 | (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO))
|
---|
| 229 | "smb",
|
---|
| 230 | # ifdef USE_SSL
|
---|
| 231 | "smbs",
|
---|
| 232 | # endif
|
---|
| 233 | #endif
|
---|
| 234 | #ifndef CURL_DISABLE_SMTP
|
---|
| 235 | "smtp",
|
---|
| 236 | #endif
|
---|
| 237 | #if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)
|
---|
| 238 | "smtps",
|
---|
| 239 | #endif
|
---|
| 240 | #ifndef CURL_DISABLE_TELNET
|
---|
| 241 | "telnet",
|
---|
| 242 | #endif
|
---|
| 243 | #ifndef CURL_DISABLE_TFTP
|
---|
| 244 | "tftp",
|
---|
| 245 | #endif
|
---|
| 246 |
|
---|
| 247 | NULL
|
---|
| 248 | };
|
---|
| 249 |
|
---|
| 250 | static curl_version_info_data version_info = {
|
---|
| 251 | CURLVERSION_NOW,
|
---|
| 252 | LIBCURL_VERSION,
|
---|
| 253 | LIBCURL_VERSION_NUM,
|
---|
| 254 | OS, /* as found by configure or set by hand at build-time */
|
---|
| 255 | 0 /* features is 0 by default */
|
---|
| 256 | #ifdef ENABLE_IPV6
|
---|
| 257 | | CURL_VERSION_IPV6
|
---|
| 258 | #endif
|
---|
| 259 | #ifdef USE_SSL
|
---|
| 260 | | CURL_VERSION_SSL
|
---|
| 261 | #endif
|
---|
| 262 | #ifdef USE_NTLM
|
---|
| 263 | | CURL_VERSION_NTLM
|
---|
| 264 | #endif
|
---|
| 265 | #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
|
---|
| 266 | defined(NTLM_WB_ENABLED)
|
---|
| 267 | | CURL_VERSION_NTLM_WB
|
---|
| 268 | #endif
|
---|
| 269 | #ifdef USE_SPNEGO
|
---|
| 270 | | CURL_VERSION_SPNEGO
|
---|
| 271 | #endif
|
---|
| 272 | #ifdef USE_KERBEROS5
|
---|
| 273 | | CURL_VERSION_KERBEROS5
|
---|
| 274 | #endif
|
---|
| 275 | #ifdef HAVE_GSSAPI
|
---|
| 276 | | CURL_VERSION_GSSAPI
|
---|
| 277 | #endif
|
---|
| 278 | #ifdef USE_WINDOWS_SSPI
|
---|
| 279 | | CURL_VERSION_SSPI
|
---|
| 280 | #endif
|
---|
| 281 | #ifdef HAVE_LIBZ
|
---|
| 282 | | CURL_VERSION_LIBZ
|
---|
| 283 | #endif
|
---|
| 284 | #ifdef DEBUGBUILD
|
---|
| 285 | | CURL_VERSION_DEBUG
|
---|
| 286 | #endif
|
---|
| 287 | #ifdef CURLDEBUG
|
---|
| 288 | | CURL_VERSION_CURLDEBUG
|
---|
| 289 | #endif
|
---|
| 290 | #ifdef CURLRES_ASYNCH
|
---|
| 291 | | CURL_VERSION_ASYNCHDNS
|
---|
| 292 | #endif
|
---|
| 293 | #if (CURL_SIZEOF_CURL_OFF_T > 4) && \
|
---|
| 294 | ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
|
---|
| 295 | | CURL_VERSION_LARGEFILE
|
---|
| 296 | #endif
|
---|
| 297 | #if defined(CURL_DOES_CONVERSIONS)
|
---|
| 298 | | CURL_VERSION_CONV
|
---|
| 299 | #endif
|
---|
| 300 | #if defined(USE_TLS_SRP)
|
---|
| 301 | | CURL_VERSION_TLSAUTH_SRP
|
---|
| 302 | #endif
|
---|
| 303 | #if defined(USE_NGHTTP2)
|
---|
| 304 | | CURL_VERSION_HTTP2
|
---|
| 305 | #endif
|
---|
| 306 | #if defined(USE_UNIX_SOCKETS)
|
---|
| 307 | | CURL_VERSION_UNIX_SOCKETS
|
---|
| 308 | #endif
|
---|
| 309 | #if defined(USE_LIBPSL)
|
---|
| 310 | | CURL_VERSION_PSL
|
---|
| 311 | #endif
|
---|
| 312 | ,
|
---|
| 313 | NULL, /* ssl_version */
|
---|
| 314 | 0, /* ssl_version_num, this is kept at zero */
|
---|
| 315 | NULL, /* zlib_version */
|
---|
| 316 | protocols,
|
---|
| 317 | NULL, /* c-ares version */
|
---|
| 318 | 0, /* c-ares version numerical */
|
---|
| 319 | NULL, /* libidn version */
|
---|
| 320 | 0, /* iconv version */
|
---|
| 321 | NULL, /* ssh lib version */
|
---|
| 322 | };
|
---|
| 323 |
|
---|
| 324 | curl_version_info_data *curl_version_info(CURLversion stamp)
|
---|
| 325 | {
|
---|
| 326 | #ifdef USE_LIBSSH2
|
---|
| 327 | static char ssh_buffer[80];
|
---|
| 328 | #endif
|
---|
| 329 |
|
---|
| 330 | #ifdef USE_SSL
|
---|
| 331 | static char ssl_buffer[80];
|
---|
| 332 | Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
|
---|
| 333 | version_info.ssl_version = ssl_buffer;
|
---|
| 334 | #endif
|
---|
| 335 |
|
---|
| 336 | #ifdef HAVE_LIBZ
|
---|
| 337 | version_info.libz_version = zlibVersion();
|
---|
| 338 | /* libz left NULL if non-existing */
|
---|
| 339 | #endif
|
---|
| 340 | #ifdef USE_ARES
|
---|
| 341 | {
|
---|
| 342 | int aresnum;
|
---|
| 343 | version_info.ares = ares_version(&aresnum);
|
---|
| 344 | version_info.ares_num = aresnum;
|
---|
| 345 | }
|
---|
| 346 | #endif
|
---|
| 347 | #ifdef USE_LIBIDN
|
---|
| 348 | /* This returns a version string if we use the given version or later,
|
---|
| 349 | otherwise it returns NULL */
|
---|
| 350 | version_info.libidn = stringprep_check_version(LIBIDN_REQUIRED_VERSION);
|
---|
| 351 | if(version_info.libidn)
|
---|
| 352 | version_info.features |= CURL_VERSION_IDN;
|
---|
| 353 | #elif defined(USE_WIN32_IDN)
|
---|
| 354 | version_info.features |= CURL_VERSION_IDN;
|
---|
| 355 | #endif
|
---|
| 356 |
|
---|
| 357 | #if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
|
---|
| 358 | #ifdef _LIBICONV_VERSION
|
---|
| 359 | version_info.iconv_ver_num = _LIBICONV_VERSION;
|
---|
| 360 | #else
|
---|
| 361 | /* version unknown */
|
---|
| 362 | version_info.iconv_ver_num = -1;
|
---|
| 363 | #endif /* _LIBICONV_VERSION */
|
---|
| 364 | #endif
|
---|
| 365 |
|
---|
| 366 | #ifdef USE_LIBSSH2
|
---|
| 367 | snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
|
---|
| 368 | version_info.libssh_version = ssh_buffer;
|
---|
| 369 | #endif
|
---|
| 370 |
|
---|
| 371 | (void)stamp; /* avoid compiler warnings, we don't use this */
|
---|
| 372 |
|
---|
| 373 | return &version_info;
|
---|
| 374 | }
|
---|