or_state_st.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. struct config_suite_t;
  16. /** Persistent state for an onion router, as saved to disk. */
  17. struct or_state_t {
  18. uint32_t magic_;
  19. /** The time at which we next plan to write the state to the disk. Equal to
  20. * TIME_MAX if there are no savable changes, 0 if there are changes that
  21. * should be saved right away. */
  22. time_t next_write;
  23. /** When was the state last written to disk? */
  24. time_t LastWritten;
  25. /** Fields for accounting bandwidth use. */
  26. time_t AccountingIntervalStart;
  27. uint64_t AccountingBytesReadInInterval;
  28. uint64_t AccountingBytesWrittenInInterval;
  29. int AccountingSecondsActive;
  30. int AccountingSecondsToReachSoftLimit;
  31. time_t AccountingSoftLimitHitAt;
  32. uint64_t AccountingBytesAtSoftLimit;
  33. uint64_t AccountingExpectedUsage;
  34. /** A list of Entry Guard-related configuration lines. (pre-prop271) */
  35. struct config_line_t *EntryGuards;
  36. /** A list of guard-related configuration lines. (post-prop271) */
  37. struct config_line_t *Guard;
  38. struct config_line_t *TransportProxies;
  39. /** Cached revision counters for active hidden services on this host */
  40. struct config_line_t *HidServRevCounter;
  41. /** These fields hold information on the history of bandwidth usage for
  42. * servers. The "Ends" fields hold the time when we last updated the
  43. * bandwidth usage. The "Interval" fields hold the granularity, in seconds,
  44. * of the entries of Values. The "Values" lists hold decimal string
  45. * representations of the number of bytes read or written in each
  46. * interval. The "Maxima" list holds decimal strings describing the highest
  47. * rate achieved during the interval.
  48. */
  49. time_t BWHistoryReadEnds;
  50. int BWHistoryReadInterval;
  51. struct smartlist_t *BWHistoryReadValues;
  52. struct smartlist_t *BWHistoryReadMaxima;
  53. time_t BWHistoryWriteEnds;
  54. int BWHistoryWriteInterval;
  55. struct smartlist_t *BWHistoryWriteValues;
  56. struct smartlist_t *BWHistoryWriteMaxima;
  57. time_t BWHistoryDirReadEnds;
  58. int BWHistoryDirReadInterval;
  59. struct smartlist_t *BWHistoryDirReadValues;
  60. struct smartlist_t *BWHistoryDirReadMaxima;
  61. time_t BWHistoryDirWriteEnds;
  62. int BWHistoryDirWriteInterval;
  63. struct smartlist_t *BWHistoryDirWriteValues;
  64. struct smartlist_t *BWHistoryDirWriteMaxima;
  65. /** Build time histogram */
  66. struct config_line_t * BuildtimeHistogram;
  67. int TotalBuildTimes;
  68. int CircuitBuildAbandonedCount;
  69. /** What version of Tor wrote this state file? */
  70. char *TorVersion;
  71. /** Holds any unrecognized values we found in the state file, in the order
  72. * in which we found them. */
  73. struct config_line_t *ExtraLines;
  74. /** When did we last rotate our onion key? "0" for 'no idea'. */
  75. time_t LastRotatedOnionKey;
  76. /** Number of minutes since the last user-initiated request (as defined by
  77. * the dormant net-status system.) Set to zero if we are dormant. */
  78. int MinutesSinceUserActivity;
  79. /** True if we were dormant when we last wrote the file; false if we
  80. * weren't. "auto" on initial startup. */
  81. int Dormant;
  82. /**
  83. * State objects for individual modules.
  84. *
  85. * Never access this field or its members directly: instead, use the module
  86. * in question to get its relevant state object if you must.
  87. */
  88. struct config_suite_t *substates_;
  89. };
  90. #endif /* !defined(TOR_OR_STATE_ST_H) */