tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

dirauth_sys.c (1667B)


      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-2021, The Tor Project, Inc. */
      5 /* See LICENSE for licensing information */
      6 
      7 /**
      8 * @file dirauth_sys.c
      9 * @brief Directory authority subsystem declarations
     10 **/
     11 
     12 #include "core/or/or.h"
     13 
     14 #define DIRAUTH_SYS_PRIVATE
     15 #include "feature/dirauth/bwauth.h"
     16 #include "feature/dirauth/dirauth_sys.h"
     17 #include "feature/dirauth/dirvote.h"
     18 #include "feature/dirauth/dirauth_periodic.h"
     19 #include "feature/dirauth/keypin.h"
     20 #include "feature/dirauth/process_descs.h"
     21 #include "feature/dirauth/dirauth_config.h"
     22 
     23 #include "feature/dirauth/dirauth_options_st.h"
     24 
     25 #include "lib/subsys/subsys.h"
     26 
     27 static const dirauth_options_t *global_dirauth_options;
     28 
     29 static int
     30 subsys_dirauth_initialize(void)
     31 {
     32  dirauth_register_periodic_events();
     33  return 0;
     34 }
     35 
     36 static void
     37 subsys_dirauth_shutdown(void)
     38 {
     39  dirserv_free_fingerprint_list();
     40  dirvote_free_all();
     41  dirserv_clear_measured_bw_cache();
     42  keypin_close_journal();
     43  global_dirauth_options = NULL;
     44 }
     45 
     46 const dirauth_options_t *
     47 dirauth_get_options(void)
     48 {
     49  tor_assert(global_dirauth_options);
     50  return global_dirauth_options;
     51 }
     52 
     53 STATIC int
     54 dirauth_set_options(void *arg)
     55 {
     56  dirauth_options_t *opts = arg;
     57  global_dirauth_options = opts;
     58  return 0;
     59 }
     60 
     61 const struct subsys_fns_t sys_dirauth = {
     62  .name = "dirauth",
     63  SUBSYS_DECLARE_LOCATION(),
     64  .supported = true,
     65  .level = DIRAUTH_SUBSYS_LEVEL,
     66  .initialize = subsys_dirauth_initialize,
     67  .shutdown = subsys_dirauth_shutdown,
     68 
     69  .options_format = &dirauth_options_fmt,
     70  .set_options = dirauth_set_options,
     71 };