altsvc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 2019 - 2022, 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.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. * The Alt-Svc: header is defined in RFC 7838:
  24. * https://datatracker.ietf.org/doc/html/rfc7838
  25. */
  26. #include "curl_setup.h"
  27. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
  28. #include <curl/curl.h>
  29. #include "urldata.h"
  30. #include "altsvc.h"
  31. #include "curl_get_line.h"
  32. #include "strcase.h"
  33. #include "parsedate.h"
  34. #include "sendf.h"
  35. #include "warnless.h"
  36. #include "rand.h"
  37. #include "rename.h"
  38. /* The last 3 #include files should be in this order */
  39. #include "curl_printf.h"
  40. #include "curl_memory.h"
  41. #include "memdebug.h"
  42. #define MAX_ALTSVC_LINE 4095
  43. #define MAX_ALTSVC_DATELENSTR "64"
  44. #define MAX_ALTSVC_DATELEN 64
  45. #define MAX_ALTSVC_HOSTLENSTR "512"
  46. #define MAX_ALTSVC_HOSTLEN 512
  47. #define MAX_ALTSVC_ALPNLENSTR "10"
  48. #define MAX_ALTSVC_ALPNLEN 10
  49. #if defined(USE_QUICHE) && !defined(UNITTESTS)
  50. #define H3VERSION "h3-29"
  51. #elif defined(USE_NGTCP2) && !defined(UNITTESTS)
  52. #define H3VERSION "h3-29"
  53. #elif defined(USE_MSH3) && !defined(UNITTESTS)
  54. #define H3VERSION "h3-29"
  55. #else
  56. #define H3VERSION "h3"
  57. #endif
  58. static enum alpnid alpn2alpnid(char *name)
  59. {
  60. if(strcasecompare(name, "h1"))
  61. return ALPN_h1;
  62. if(strcasecompare(name, "h2"))
  63. return ALPN_h2;
  64. if(strcasecompare(name, H3VERSION))
  65. return ALPN_h3;
  66. return ALPN_none; /* unknown, probably rubbish input */
  67. }
  68. /* Given the ALPN ID, return the name */
  69. const char *Curl_alpnid2str(enum alpnid id)
  70. {
  71. switch(id) {
  72. case ALPN_h1:
  73. return "h1";
  74. case ALPN_h2:
  75. return "h2";
  76. case ALPN_h3:
  77. return H3VERSION;
  78. default:
  79. return ""; /* bad */
  80. }
  81. }
  82. static void altsvc_free(struct altsvc *as)
  83. {
  84. free(as->src.host);
  85. free(as->dst.host);
  86. free(as);
  87. }
  88. static struct altsvc *altsvc_createid(const char *srchost,
  89. const char *dsthost,
  90. enum alpnid srcalpnid,
  91. enum alpnid dstalpnid,
  92. unsigned int srcport,
  93. unsigned int dstport)
  94. {
  95. struct altsvc *as = calloc(sizeof(struct altsvc), 1);
  96. size_t hlen;
  97. if(!as)
  98. return NULL;
  99. hlen = strlen(srchost);
  100. DEBUGASSERT(hlen);
  101. as->src.host = strdup(srchost);
  102. if(!as->src.host)
  103. goto error;
  104. if(hlen && (srchost[hlen - 1] == '.'))
  105. /* strip off trailing any dot */
  106. as->src.host[--hlen] = 0;
  107. as->dst.host = strdup(dsthost);
  108. if(!as->dst.host)
  109. goto error;
  110. as->src.alpnid = srcalpnid;
  111. as->dst.alpnid = dstalpnid;
  112. as->src.port = curlx_ultous(srcport);
  113. as->dst.port = curlx_ultous(dstport);
  114. return as;
  115. error:
  116. altsvc_free(as);
  117. return NULL;
  118. }
  119. static struct altsvc *altsvc_create(char *srchost,
  120. char *dsthost,
  121. char *srcalpn,
  122. char *dstalpn,
  123. unsigned int srcport,
  124. unsigned int dstport)
  125. {
  126. enum alpnid dstalpnid = alpn2alpnid(dstalpn);
  127. enum alpnid srcalpnid = alpn2alpnid(srcalpn);
  128. if(!srcalpnid || !dstalpnid)
  129. return NULL;
  130. return altsvc_createid(srchost, dsthost, srcalpnid, dstalpnid,
  131. srcport, dstport);
  132. }
  133. /* only returns SERIOUS errors */
  134. static CURLcode altsvc_add(struct altsvcinfo *asi, char *line)
  135. {
  136. /* Example line:
  137. h2 example.com 443 h3 shiny.example.com 8443 "20191231 10:00:00" 1
  138. */
  139. char srchost[MAX_ALTSVC_HOSTLEN + 1];
  140. char dsthost[MAX_ALTSVC_HOSTLEN + 1];
  141. char srcalpn[MAX_ALTSVC_ALPNLEN + 1];
  142. char dstalpn[MAX_ALTSVC_ALPNLEN + 1];
  143. char date[MAX_ALTSVC_DATELEN + 1];
  144. unsigned int srcport;
  145. unsigned int dstport;
  146. unsigned int prio;
  147. unsigned int persist;
  148. int rc;
  149. rc = sscanf(line,
  150. "%" MAX_ALTSVC_ALPNLENSTR "s %" MAX_ALTSVC_HOSTLENSTR "s %u "
  151. "%" MAX_ALTSVC_ALPNLENSTR "s %" MAX_ALTSVC_HOSTLENSTR "s %u "
  152. "\"%" MAX_ALTSVC_DATELENSTR "[^\"]\" %u %u",
  153. srcalpn, srchost, &srcport,
  154. dstalpn, dsthost, &dstport,
  155. date, &persist, &prio);
  156. if(9 == rc) {
  157. struct altsvc *as;
  158. time_t expires = Curl_getdate_capped(date);
  159. as = altsvc_create(srchost, dsthost, srcalpn, dstalpn, srcport, dstport);
  160. if(as) {
  161. as->expires = expires;
  162. as->prio = prio;
  163. as->persist = persist ? 1 : 0;
  164. Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
  165. }
  166. }
  167. return CURLE_OK;
  168. }
  169. /*
  170. * Load alt-svc entries from the given file. The text based line-oriented file
  171. * format is documented here:
  172. * https://github.com/curl/curl/wiki/QUIC-implementation
  173. *
  174. * This function only returns error on major problems that prevents alt-svc
  175. * handling to work completely. It will ignore individual syntactical errors
  176. * etc.
  177. */
  178. static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
  179. {
  180. CURLcode result = CURLE_OK;
  181. char *line = NULL;
  182. FILE *fp;
  183. /* we need a private copy of the file name so that the altsvc cache file
  184. name survives an easy handle reset */
  185. free(asi->filename);
  186. asi->filename = strdup(file);
  187. if(!asi->filename)
  188. return CURLE_OUT_OF_MEMORY;
  189. fp = fopen(file, FOPEN_READTEXT);
  190. if(fp) {
  191. line = malloc(MAX_ALTSVC_LINE);
  192. if(!line)
  193. goto fail;
  194. while(Curl_get_line(line, MAX_ALTSVC_LINE, fp)) {
  195. char *lineptr = line;
  196. while(*lineptr && ISBLANK(*lineptr))
  197. lineptr++;
  198. if(*lineptr == '#')
  199. /* skip commented lines */
  200. continue;
  201. altsvc_add(asi, lineptr);
  202. }
  203. free(line); /* free the line buffer */
  204. fclose(fp);
  205. }
  206. return result;
  207. fail:
  208. Curl_safefree(asi->filename);
  209. free(line);
  210. fclose(fp);
  211. return CURLE_OUT_OF_MEMORY;
  212. }
  213. /*
  214. * Write this single altsvc entry to a single output line
  215. */
  216. static CURLcode altsvc_out(struct altsvc *as, FILE *fp)
  217. {
  218. struct tm stamp;
  219. CURLcode result = Curl_gmtime(as->expires, &stamp);
  220. if(result)
  221. return result;
  222. fprintf(fp,
  223. "%s %s %u "
  224. "%s %s %u "
  225. "\"%d%02d%02d "
  226. "%02d:%02d:%02d\" "
  227. "%u %d\n",
  228. Curl_alpnid2str(as->src.alpnid), as->src.host, as->src.port,
  229. Curl_alpnid2str(as->dst.alpnid), as->dst.host, as->dst.port,
  230. stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
  231. stamp.tm_hour, stamp.tm_min, stamp.tm_sec,
  232. as->persist, as->prio);
  233. return CURLE_OK;
  234. }
  235. /* ---- library-wide functions below ---- */
  236. /*
  237. * Curl_altsvc_init() creates a new altsvc cache.
  238. * It returns the new instance or NULL if something goes wrong.
  239. */
  240. struct altsvcinfo *Curl_altsvc_init(void)
  241. {
  242. struct altsvcinfo *asi = calloc(sizeof(struct altsvcinfo), 1);
  243. if(!asi)
  244. return NULL;
  245. Curl_llist_init(&asi->list, NULL);
  246. /* set default behavior */
  247. asi->flags = CURLALTSVC_H1
  248. #ifdef USE_HTTP2
  249. | CURLALTSVC_H2
  250. #endif
  251. #ifdef ENABLE_QUIC
  252. | CURLALTSVC_H3
  253. #endif
  254. ;
  255. return asi;
  256. }
  257. /*
  258. * Curl_altsvc_load() loads alt-svc from file.
  259. */
  260. CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file)
  261. {
  262. CURLcode result;
  263. DEBUGASSERT(asi);
  264. result = altsvc_load(asi, file);
  265. return result;
  266. }
  267. /*
  268. * Curl_altsvc_ctrl() passes on the external bitmask.
  269. */
  270. CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl)
  271. {
  272. DEBUGASSERT(asi);
  273. if(!ctrl)
  274. /* unexpected */
  275. return CURLE_BAD_FUNCTION_ARGUMENT;
  276. asi->flags = ctrl;
  277. return CURLE_OK;
  278. }
  279. /*
  280. * Curl_altsvc_cleanup() frees an altsvc cache instance and all associated
  281. * resources.
  282. */
  283. void Curl_altsvc_cleanup(struct altsvcinfo **altsvcp)
  284. {
  285. struct Curl_llist_element *e;
  286. struct Curl_llist_element *n;
  287. if(*altsvcp) {
  288. struct altsvcinfo *altsvc = *altsvcp;
  289. for(e = altsvc->list.head; e; e = n) {
  290. struct altsvc *as = e->ptr;
  291. n = e->next;
  292. altsvc_free(as);
  293. }
  294. free(altsvc->filename);
  295. free(altsvc);
  296. *altsvcp = NULL; /* clear the pointer */
  297. }
  298. }
  299. /*
  300. * Curl_altsvc_save() writes the altsvc cache to a file.
  301. */
  302. CURLcode Curl_altsvc_save(struct Curl_easy *data,
  303. struct altsvcinfo *altsvc, const char *file)
  304. {
  305. struct Curl_llist_element *e;
  306. struct Curl_llist_element *n;
  307. CURLcode result = CURLE_OK;
  308. FILE *out;
  309. char *tempstore;
  310. unsigned char randsuffix[9];
  311. if(!altsvc)
  312. /* no cache activated */
  313. return CURLE_OK;
  314. /* if not new name is given, use the one we stored from the load */
  315. if(!file && altsvc->filename)
  316. file = altsvc->filename;
  317. if((altsvc->flags & CURLALTSVC_READONLYFILE) || !file || !file[0])
  318. /* marked as read-only, no file or zero length file name */
  319. return CURLE_OK;
  320. if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
  321. return CURLE_FAILED_INIT;
  322. tempstore = aprintf("%s.%s.tmp", file, randsuffix);
  323. if(!tempstore)
  324. return CURLE_OUT_OF_MEMORY;
  325. out = fopen(tempstore, FOPEN_WRITETEXT);
  326. if(!out)
  327. result = CURLE_WRITE_ERROR;
  328. else {
  329. fputs("# Your alt-svc cache. https://curl.se/docs/alt-svc.html\n"
  330. "# This file was generated by libcurl! Edit at your own risk.\n",
  331. out);
  332. for(e = altsvc->list.head; e; e = n) {
  333. struct altsvc *as = e->ptr;
  334. n = e->next;
  335. result = altsvc_out(as, out);
  336. if(result)
  337. break;
  338. }
  339. fclose(out);
  340. if(!result && Curl_rename(tempstore, file))
  341. result = CURLE_WRITE_ERROR;
  342. if(result)
  343. unlink(tempstore);
  344. }
  345. free(tempstore);
  346. return result;
  347. }
  348. static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen)
  349. {
  350. size_t len;
  351. const char *protop;
  352. const char *p = *ptr;
  353. while(*p && ISBLANK(*p))
  354. p++;
  355. protop = p;
  356. while(*p && !ISBLANK(*p) && (*p != ';') && (*p != '='))
  357. p++;
  358. len = p - protop;
  359. *ptr = p;
  360. if(!len || (len >= buflen))
  361. return CURLE_BAD_FUNCTION_ARGUMENT;
  362. memcpy(alpnbuf, protop, len);
  363. alpnbuf[len] = 0;
  364. return CURLE_OK;
  365. }
  366. /* hostcompare() returns true if 'host' matches 'check'. The first host
  367. * argument may have a trailing dot present that will be ignored.
  368. */
  369. static bool hostcompare(const char *host, const char *check)
  370. {
  371. size_t hlen = strlen(host);
  372. size_t clen = strlen(check);
  373. if(hlen && (host[hlen - 1] == '.'))
  374. hlen--;
  375. if(hlen != clen)
  376. /* they can't match if they have different lengths */
  377. return FALSE;
  378. return strncasecompare(host, check, hlen);
  379. }
  380. /* altsvc_flush() removes all alternatives for this source origin from the
  381. list */
  382. static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid,
  383. const char *srchost, unsigned short srcport)
  384. {
  385. struct Curl_llist_element *e;
  386. struct Curl_llist_element *n;
  387. for(e = asi->list.head; e; e = n) {
  388. struct altsvc *as = e->ptr;
  389. n = e->next;
  390. if((srcalpnid == as->src.alpnid) &&
  391. (srcport == as->src.port) &&
  392. hostcompare(srchost, as->src.host)) {
  393. Curl_llist_remove(&asi->list, e, NULL);
  394. altsvc_free(as);
  395. }
  396. }
  397. }
  398. #ifdef DEBUGBUILD
  399. /* to play well with debug builds, we can *set* a fixed time this will
  400. return */
  401. static time_t debugtime(void *unused)
  402. {
  403. char *timestr = getenv("CURL_TIME");
  404. (void)unused;
  405. if(timestr) {
  406. unsigned long val = strtol(timestr, NULL, 10);
  407. return (time_t)val;
  408. }
  409. return time(NULL);
  410. }
  411. #define time(x) debugtime(x)
  412. #endif
  413. #define ISNEWLINE(x) (((x) == '\n') || (x) == '\r')
  414. /*
  415. * Curl_altsvc_parse() takes an incoming alt-svc response header and stores
  416. * the data correctly in the cache.
  417. *
  418. * 'value' points to the header *value*. That's contents to the right of the
  419. * header name.
  420. *
  421. * Currently this function rejects invalid data without returning an error.
  422. * Invalid host name, port number will result in the specific alternative
  423. * being rejected. Unknown protocols are skipped.
  424. */
  425. CURLcode Curl_altsvc_parse(struct Curl_easy *data,
  426. struct altsvcinfo *asi, const char *value,
  427. enum alpnid srcalpnid, const char *srchost,
  428. unsigned short srcport)
  429. {
  430. const char *p = value;
  431. size_t len;
  432. char namebuf[MAX_ALTSVC_HOSTLEN] = "";
  433. char alpnbuf[MAX_ALTSVC_ALPNLEN] = "";
  434. struct altsvc *as;
  435. unsigned short dstport = srcport; /* the same by default */
  436. CURLcode result = getalnum(&p, alpnbuf, sizeof(alpnbuf));
  437. #ifdef CURL_DISABLE_VERBOSE_STRINGS
  438. (void)data;
  439. #endif
  440. if(result) {
  441. infof(data, "Excessive alt-svc header, ignoring.");
  442. return CURLE_OK;
  443. }
  444. DEBUGASSERT(asi);
  445. /* Flush all cached alternatives for this source origin, if any */
  446. altsvc_flush(asi, srcalpnid, srchost, srcport);
  447. /* "clear" is a magic keyword */
  448. if(strcasecompare(alpnbuf, "clear")) {
  449. return CURLE_OK;
  450. }
  451. do {
  452. if(*p == '=') {
  453. /* [protocol]="[host][:port]" */
  454. enum alpnid dstalpnid = alpn2alpnid(alpnbuf); /* the same by default */
  455. p++;
  456. if(*p == '\"') {
  457. const char *dsthost = "";
  458. const char *value_ptr;
  459. char option[32];
  460. unsigned long num;
  461. char *end_ptr;
  462. bool quoted = FALSE;
  463. time_t maxage = 24 * 3600; /* default is 24 hours */
  464. bool persist = FALSE;
  465. p++;
  466. if(*p != ':') {
  467. /* host name starts here */
  468. const char *hostp = p;
  469. while(*p && (ISALNUM(*p) || (*p == '.') || (*p == '-')))
  470. p++;
  471. len = p - hostp;
  472. if(!len || (len >= MAX_ALTSVC_HOSTLEN)) {
  473. infof(data, "Excessive alt-svc host name, ignoring.");
  474. dstalpnid = ALPN_none;
  475. }
  476. else {
  477. memcpy(namebuf, hostp, len);
  478. namebuf[len] = 0;
  479. dsthost = namebuf;
  480. }
  481. }
  482. else {
  483. /* no destination name, use source host */
  484. dsthost = srchost;
  485. }
  486. if(*p == ':') {
  487. /* a port number */
  488. unsigned long port = strtoul(++p, &end_ptr, 10);
  489. if(port > USHRT_MAX || end_ptr == p || *end_ptr != '\"') {
  490. infof(data, "Unknown alt-svc port number, ignoring.");
  491. dstalpnid = ALPN_none;
  492. }
  493. p = end_ptr;
  494. dstport = curlx_ultous(port);
  495. }
  496. if(*p++ != '\"')
  497. break;
  498. /* Handle the optional 'ma' and 'persist' flags. Unknown flags
  499. are skipped. */
  500. for(;;) {
  501. while(ISBLANK(*p))
  502. p++;
  503. if(*p != ';')
  504. break;
  505. p++; /* pass the semicolon */
  506. if(!*p || ISNEWLINE(*p))
  507. break;
  508. result = getalnum(&p, option, sizeof(option));
  509. if(result) {
  510. /* skip option if name is too long */
  511. option[0] = '\0';
  512. }
  513. while(*p && ISBLANK(*p))
  514. p++;
  515. if(*p != '=')
  516. return CURLE_OK;
  517. p++;
  518. while(*p && ISBLANK(*p))
  519. p++;
  520. if(!*p)
  521. return CURLE_OK;
  522. if(*p == '\"') {
  523. /* quoted value */
  524. p++;
  525. quoted = TRUE;
  526. }
  527. value_ptr = p;
  528. if(quoted) {
  529. while(*p && *p != '\"')
  530. p++;
  531. if(!*p++)
  532. return CURLE_OK;
  533. }
  534. else {
  535. while(*p && !ISBLANK(*p) && *p!= ';' && *p != ',')
  536. p++;
  537. }
  538. num = strtoul(value_ptr, &end_ptr, 10);
  539. if((end_ptr != value_ptr) && (num < ULONG_MAX)) {
  540. if(strcasecompare("ma", option))
  541. maxage = num;
  542. else if(strcasecompare("persist", option) && (num == 1))
  543. persist = TRUE;
  544. }
  545. }
  546. if(dstalpnid) {
  547. as = altsvc_createid(srchost, dsthost,
  548. srcalpnid, dstalpnid,
  549. srcport, dstport);
  550. if(as) {
  551. /* The expires time also needs to take the Age: value (if any) into
  552. account. [See RFC 7838 section 3.1] */
  553. as->expires = maxage + time(NULL);
  554. as->persist = persist;
  555. Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
  556. infof(data, "Added alt-svc: %s:%d over %s", dsthost, dstport,
  557. Curl_alpnid2str(dstalpnid));
  558. }
  559. }
  560. else {
  561. infof(data, "Unknown alt-svc protocol \"%s\", skipping.",
  562. alpnbuf);
  563. }
  564. }
  565. else
  566. break;
  567. /* after the double quote there can be a comma if there's another
  568. string or a semicolon if no more */
  569. if(*p == ',') {
  570. /* comma means another alternative is presented */
  571. p++;
  572. result = getalnum(&p, alpnbuf, sizeof(alpnbuf));
  573. if(result)
  574. break;
  575. }
  576. }
  577. else
  578. break;
  579. } while(*p && (*p != ';') && (*p != '\n') && (*p != '\r'));
  580. return CURLE_OK;
  581. }
  582. /*
  583. * Return TRUE on a match
  584. */
  585. bool Curl_altsvc_lookup(struct altsvcinfo *asi,
  586. enum alpnid srcalpnid, const char *srchost,
  587. int srcport,
  588. struct altsvc **dstentry,
  589. const int versions) /* one or more bits */
  590. {
  591. struct Curl_llist_element *e;
  592. struct Curl_llist_element *n;
  593. time_t now = time(NULL);
  594. DEBUGASSERT(asi);
  595. DEBUGASSERT(srchost);
  596. DEBUGASSERT(dstentry);
  597. for(e = asi->list.head; e; e = n) {
  598. struct altsvc *as = e->ptr;
  599. n = e->next;
  600. if(as->expires < now) {
  601. /* an expired entry, remove */
  602. Curl_llist_remove(&asi->list, e, NULL);
  603. altsvc_free(as);
  604. continue;
  605. }
  606. if((as->src.alpnid == srcalpnid) &&
  607. hostcompare(srchost, as->src.host) &&
  608. (as->src.port == srcport) &&
  609. (versions & as->dst.alpnid)) {
  610. /* match */
  611. *dstentry = as;
  612. return TRUE;
  613. }
  614. }
  615. return FALSE;
  616. }
  617. #endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */