hs_stats.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (c) 2016-2018, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_stats.c
  5. * \brief Keeps stats about the activity of our onion service(s).
  6. **/
  7. #include "core/or/or.h"
  8. #include "feature/hs/hs_stats.h"
  9. #include "feature/hs/hs_service.h"
  10. /** Number of v3 INTRODUCE2 cells received */
  11. static uint32_t n_introduce2_v3 = 0;
  12. /** Number of v2 INTRODUCE2 cells received */
  13. static uint32_t n_introduce2_v2 = 0;
  14. /** Number of attempts to make a circuit to a rendezvous point */
  15. static uint32_t n_rendezvous_launches = 0;
  16. /** Note that we received another INTRODUCE2 cell. */
  17. void
  18. hs_stats_note_introduce2_cell(int is_hsv3)
  19. {
  20. if (is_hsv3) {
  21. n_introduce2_v3++;
  22. } else {
  23. n_introduce2_v2++;
  24. }
  25. }
  26. /** Return the number of v3 INTRODUCE2 cells we have received. */
  27. uint32_t
  28. hs_stats_get_n_introduce2_v3_cells(void)
  29. {
  30. return n_introduce2_v3;
  31. }
  32. /** Return the number of v2 INTRODUCE2 cells we have received. */
  33. uint32_t
  34. hs_stats_get_n_introduce2_v2_cells(void)
  35. {
  36. return n_introduce2_v2;
  37. }
  38. /** Note that we attempted to launch another circuit to a rendezvous point. */
  39. void
  40. hs_stats_note_service_rendezvous_launch(void)
  41. {
  42. n_rendezvous_launches++;
  43. }
  44. /** Return the number of rendezvous circuits we have attempted to launch. */
  45. uint32_t
  46. hs_stats_get_n_rendezvous_launches(void)
  47. {
  48. return n_rendezvous_launches;
  49. }