tor  0.4.2.1-alpha-dev
routermode.c
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 #include "core/or/or.h"
8 
9 #include "app/config/config.h"
11 #include "core/or/port_cfg_st.h"
12 #include "feature/relay/router.h"
14 
19 int
21 {
22  if (!options->DirCache)
23  return 0;
24  return options->DirPort_set ||
25  (server_mode(options) && router_has_bandwidth_to_be_dirserver(options));
26 }
27 
29 int
30 proxy_mode(const or_options_t *options)
31 {
32  (void)options;
33  SMARTLIST_FOREACH_BEGIN(get_configured_ports(), const port_cfg_t *, p) {
34  if (p->type == CONN_TYPE_AP_LISTENER ||
35  p->type == CONN_TYPE_AP_TRANS_LISTENER ||
36  p->type == CONN_TYPE_AP_DNS_LISTENER ||
37  p->type == CONN_TYPE_AP_NATD_LISTENER)
38  return 1;
39  } SMARTLIST_FOREACH_END(p);
40  return 0;
41 }
42 
45 MOCK_IMPL(int,
46 server_mode,(const or_options_t *options))
47 {
48  if (options->ClientOnly) return 0;
49  return (options->ORPort_set);
50 }
51 
54 MOCK_IMPL(int,
55 public_server_mode,(const or_options_t *options))
56 {
57  if (!server_mode(options)) return 0;
58  return (!options->BridgeRelay);
59 }
60 
62 static int server_is_advertised=0;
63 
66 MOCK_IMPL(int,
67 advertised_server_mode,(void))
68 {
69  return server_is_advertised;
70 }
71 
76 void
78 {
79  server_is_advertised = s;
80 }
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
int dir_server_mode(const or_options_t *options)
Definition: routermode.c:20
#define CONN_TYPE_AP_NATD_LISTENER
Definition: connection.h:46
Header file for connection.c.
#define CONN_TYPE_AP_TRANS_LISTENER
Definition: connection.h:43
Header file for config.c.
Header file for routermode.c.
Master header file for Tor-specific functionality.
void set_server_advertised(int s)
Definition: routermode.c:77
#define CONN_TYPE_AP_DNS_LISTENER
Definition: connection.h:48
Header file for router.c.
int router_has_bandwidth_to_be_dirserver(const or_options_t *options)
Definition: router.c:1189
#define CONN_TYPE_AP_LISTENER
Definition: connection.h:28
int proxy_mode(const or_options_t *options)
Definition: routermode.c:30