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 */
9 * @brief Check if we're running as a relay/cache.
12 #include "core/or/or.h"
14 #include "app/config/config.h"
15 #include "feature/relay/router.h"
16 #include "feature/relay/routermode.h"
18 /** Return 1 if we are configured to accept either relay or directory requests
19 * from clients and we aren't at risk of exceeding our bandwidth limits, thus
20 * we should be a directory server. If not, return 0.
23 dir_server_mode(const or_options_t
*options
)
25 if (!options
->DirCache
)
27 return options
->DirPort_set
||
28 (server_mode(options
) && router_has_bandwidth_to_be_dirserver(options
));
31 /** Return true iff we are trying to be a server.
34 server_mode
,(const or_options_t
*options
))
36 if (options
->ClientOnly
) return 0;
37 return (options
->ORPort_set
);
40 /** Return true iff we are trying to be a non-bridge server.
43 public_server_mode
,(const or_options_t
*options
))
45 if (!server_mode(options
)) return 0;
46 return (!options
->BridgeRelay
);
49 /** Remember if we've advertised ourselves to the dirservers. */
50 static int server_is_advertised
=0;
52 /** Return true iff we have published our descriptor lately.
55 advertised_server_mode
,(void))
57 return server_is_advertised
;
61 * Called with a boolean: set whether we have recently published our
65 set_server_advertised(int s
)
67 server_is_advertised
= s
;