2
0

hsts.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef HEADER_CURL_HSTS_H
  2. #define HEADER_CURL_HSTS_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2020 - 2021, 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. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HSTS)
  26. #include <curl/curl.h>
  27. #include "llist.h"
  28. #ifdef DEBUGBUILD
  29. extern time_t deltatime;
  30. #endif
  31. struct stsentry {
  32. struct Curl_llist_element node;
  33. const char *host;
  34. bool includeSubDomains;
  35. curl_off_t expires; /* the timestamp of this entry's expiry */
  36. };
  37. /* The HSTS cache. Needs to be able to tailmatch host names. */
  38. struct hsts {
  39. struct Curl_llist list;
  40. char *filename;
  41. unsigned int flags;
  42. };
  43. struct hsts *Curl_hsts_init(void);
  44. void Curl_hsts_cleanup(struct hsts **hp);
  45. CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
  46. const char *sts);
  47. struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
  48. bool subdomain);
  49. CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
  50. const char *file);
  51. CURLcode Curl_hsts_loadfile(struct Curl_easy *data,
  52. struct hsts *h, const char *file);
  53. CURLcode Curl_hsts_loadcb(struct Curl_easy *data,
  54. struct hsts *h);
  55. #else
  56. #define Curl_hsts_cleanup(x)
  57. #define Curl_hsts_loadcb(x,y) CURLE_OK
  58. #define Curl_hsts_save(x,y,z)
  59. #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */
  60. #endif /* HEADER_CURL_HSTS_H */