or_state_st.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file or_state_t
  8. *
  9. * \brief The or_state_t structure, which represents Tor's state file.
  10. */
  11. #ifndef TOR_OR_STATE_ST_H
  12. #define TOR_OR_STATE_ST_H
  13. #include "lib/cc/torint.h"
  14. struct smartlist_t;
  15. /** Persistent state for an onion router, as saved to disk. */
  16. struct or_state_t {
  17. uint32_t magic_;
  18. /** The time at which we next plan to write the state to the disk. Equal to
  19. * TIME_MAX if there are no savable changes, 0 if there are changes that
  20. * should be saved right away. */
  21. time_t next_write;
  22. /** When was the state last written to disk? */
  23. time_t LastWritten;
  24. /** Fields for accounting bandwidth use. */
  25. time_t AccountingIntervalStart;
  26. uint64_t AccountingBytesReadInInterval;
  27. uint64_t AccountingBytesWrittenInInterval;
  28. int AccountingSecondsActive;
  29. int AccountingSecondsToReachSoftLimit;
  30. time_t AccountingSoftLimitHitAt;
  31. uint64_t AccountingBytesAtSoftLimit;
  32. uint64_t AccountingExpectedUsage;
  33. /** A list of Entry Guard-related configuration lines. (pre-prop271) */
  34. struct config_line_t *EntryGuards;
  35. /** A list of guard-related configuration lines. (post-prop271) */
  36. struct config_line_t *Guard;
  37. struct config_line_t *TransportProxies;
  38. /** Cached revision counters for active hidden services on this host */
  39. struct config_line_t *HidServRevCounter;
  40. /** These fields hold information on the history of bandwidth usage for
  41. * servers. The "Ends" fields hold the time when we last updated the
  42. * bandwidth usage. The "Interval" fields hold the granularity, in seconds,
  43. * of the entries of Values. The "Values" lists hold decimal string
  44. * representations of the number of bytes read or written in each
  45. * interval. The "Maxima" list holds decimal strings describing the highest
  46. * rate achieved during the interval.
  47. */
  48. time_t BWHistoryReadEnds;
  49. int BWHistoryReadInterval;
  50. struct smartlist_t *BWHistoryReadValues;
  51. struct smartlist_t *BWHistoryReadMaxima;
  52. time_t BWHistoryWriteEnds;
  53. int BWHistoryWriteInterval;
  54. struct smartlist_t *BWHistoryWriteValues;
  55. struct smartlist_t *BWHistoryWriteMaxima;
  56. time_t BWHistoryDirReadEnds;
  57. int BWHistoryDirReadInterval;
  58. struct smartlist_t *BWHistoryDirReadValues;
  59. struct smartlist_t *BWHistoryDirReadMaxima;
  60. time_t BWHistoryDirWriteEnds;
  61. int BWHistoryDirWriteInterval;
  62. struct smartlist_t *BWHistoryDirWriteValues;
  63. struct smartlist_t *BWHistoryDirWriteMaxima;
  64. /** Build time histogram */
  65. struct config_line_t * BuildtimeHistogram;
  66. int TotalBuildTimes;
  67. int CircuitBuildAbandonedCount;
  68. /** What version of Tor wrote this state file? */
  69. char *TorVersion;
  70. /** Holds any unrecognized values we found in the state file, in the order
  71. * in which we found them. */
  72. struct config_line_t *ExtraLines;
  73. /** When did we last rotate our onion key? "0" for 'no idea'. */
  74. time_t LastRotatedOnionKey;
  75. /** Number of minutes since the last user-initiated request (as defined by
  76. * the dormant net-status system.) Set to zero if we are dormant. */
  77. int MinutesSinceUserActivity;
  78. /** True if we were dormant when we last wrote the file; false if we
  79. * weren't. "auto" on initial startup. */
  80. int Dormant;
  81. };
  82. #endif