Tor 0.4.9.0-alpha-dev
routermode.c
Go to the documentation of this file.
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 routermode.c
9 * @brief Check if we're running as a relay/cache.
10 **/
11
12#include "core/or/or.h"
13
14#include "app/config/config.h"
17
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.
21 */
22int
24{
25 if (!options->DirCache)
26 return 0;
27 return options->DirPort_set ||
29}
30
31/** Return true iff we are trying to be a server.
32 */
33MOCK_IMPL(int,
34server_mode,(const or_options_t *options))
35{
36 if (options->ClientOnly) return 0;
37 return (options->ORPort_set);
38}
39
40/** Return true iff we are trying to be a non-bridge server.
41 */
42MOCK_IMPL(int,
44{
45 if (!server_mode(options)) return 0;
46 return (!options->BridgeRelay);
47}
48
49/** Remember if we've advertised ourselves to the dirservers. */
51
52/** Return true iff we have published our descriptor lately.
53 */
54MOCK_IMPL(int,
56{
58}
59
60/**
61 * Called with a boolean: set whether we have recently published our
62 * descriptor.
63 */
64void
66{
68}
Header file for config.c.
Master header file for Tor-specific functionality.
int router_has_bandwidth_to_be_dirserver(const or_options_t *options)
Definition: router.c:1243
Header file for router.c.
int public_server_mode(const or_options_t *options)
Definition: routermode.c:43
static int server_is_advertised
Definition: routermode.c:50
int advertised_server_mode(void)
Definition: routermode.c:55
int dir_server_mode(const or_options_t *options)
Definition: routermode.c:23
int server_mode(const or_options_t *options)
Definition: routermode.c:34
void set_server_advertised(int s)
Definition: routermode.c:65
Header file for routermode.c.
#define MOCK_IMPL(rv, funcname, arglist)
Definition: testsupport.h:133