hsts.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef HEADER_CURL_HSTS_H
  2. #define HEADER_CURL_HSTS_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include "curl_setup.h"
  27. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HSTS)
  28. #include <curl/curl.h>
  29. #include "llist.h"
  30. #ifdef DEBUGBUILD
  31. extern time_t deltatime;
  32. #endif
  33. struct stsentry {
  34. struct Curl_llist_element node;
  35. const char *host;
  36. bool includeSubDomains;
  37. curl_off_t expires; /* the timestamp of this entry's expiry */
  38. };
  39. /* The HSTS cache. Needs to be able to tailmatch host names. */
  40. struct hsts {
  41. struct Curl_llist list;
  42. char *filename;
  43. unsigned int flags;
  44. };
  45. struct hsts *Curl_hsts_init(void);
  46. void Curl_hsts_cleanup(struct hsts **hp);
  47. CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
  48. const char *sts);
  49. struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
  50. bool subdomain);
  51. CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
  52. const char *file);
  53. CURLcode Curl_hsts_loadfile(struct Curl_easy *data,
  54. struct hsts *h, const char *file);
  55. CURLcode Curl_hsts_loadcb(struct Curl_easy *data,
  56. struct hsts *h);
  57. void Curl_hsts_loadfiles(struct Curl_easy *data);
  58. #else
  59. #define Curl_hsts_cleanup(x)
  60. #define Curl_hsts_loadcb(x,y) CURLE_OK
  61. #define Curl_hsts_save(x,y,z)
  62. #define Curl_hsts_loadfiles(x)
  63. #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */
  64. #endif /* HEADER_CURL_HSTS_H */