mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 22:58:50 +01:00
Move the "is the network disabled?" functions out of router.c
Since this is completely core functionality, I'm putting it in core/mainloop, even though it depends on feature/hibernate. We'll have to sort that out in the future.
This commit is contained in:
parent
b8df2318e9
commit
3ff58e47d2
5 changed files with 44 additions and 21 deletions
|
@ -20,6 +20,7 @@ LIBTOR_APP_A_SOURCES = \
|
||||||
src/core/mainloop/connection.c \
|
src/core/mainloop/connection.c \
|
||||||
src/core/mainloop/cpuworker.c \
|
src/core/mainloop/cpuworker.c \
|
||||||
src/core/mainloop/mainloop.c \
|
src/core/mainloop/mainloop.c \
|
||||||
|
src/core/mainloop/netstatus.c \
|
||||||
src/core/mainloop/periodic.c \
|
src/core/mainloop/periodic.c \
|
||||||
src/core/or/address_set.c \
|
src/core/or/address_set.c \
|
||||||
src/core/or/channel.c \
|
src/core/or/channel.c \
|
||||||
|
@ -187,6 +188,7 @@ noinst_HEADERS += \
|
||||||
src/core/mainloop/connection.h \
|
src/core/mainloop/connection.h \
|
||||||
src/core/mainloop/cpuworker.h \
|
src/core/mainloop/cpuworker.h \
|
||||||
src/core/mainloop/mainloop.h \
|
src/core/mainloop/mainloop.h \
|
||||||
|
src/core/mainloop/netstatus.h \
|
||||||
src/core/mainloop/periodic.h \
|
src/core/mainloop/periodic.h \
|
||||||
src/core/or/addr_policy_st.h \
|
src/core/or/addr_policy_st.h \
|
||||||
src/core/or/address_set.h \
|
src/core/or/address_set.h \
|
||||||
|
|
28
src/core/mainloop/netstatus.c
Normal file
28
src/core/mainloop/netstatus.c
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/* Copyright (c) 2001 Matej Pfajfar.
|
||||||
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||||
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||||
|
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||||
|
/* See LICENSE for licensing information */
|
||||||
|
|
||||||
|
#include "core/or/or.h"
|
||||||
|
#include "core/mainloop/netstatus.h"
|
||||||
|
#include "app/config/config.h"
|
||||||
|
#include "feature/hibernate/hibernate.h"
|
||||||
|
|
||||||
|
/** Return true iff our network is in some sense disabled or shutting down:
|
||||||
|
* either we're hibernating, entering hibernation, or the network is turned
|
||||||
|
* off with DisableNetwork. */
|
||||||
|
int
|
||||||
|
net_is_disabled(void)
|
||||||
|
{
|
||||||
|
return get_options()->DisableNetwork || we_are_hibernating();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return true iff our network is in some sense "completely disabled" either
|
||||||
|
* we're fully hibernating or the network is turned off with
|
||||||
|
* DisableNetwork. */
|
||||||
|
int
|
||||||
|
net_is_completely_disabled(void)
|
||||||
|
{
|
||||||
|
return get_options()->DisableNetwork || we_are_fully_hibernating();
|
||||||
|
}
|
13
src/core/mainloop/netstatus.h
Normal file
13
src/core/mainloop/netstatus.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/* Copyright (c) 2001 Matej Pfajfar.
|
||||||
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||||
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||||
|
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||||
|
/* See LICENSE for licensing information */
|
||||||
|
|
||||||
|
#ifndef TOR_NETSTATUS_H
|
||||||
|
#define TOR_NETSTATUS_H
|
||||||
|
|
||||||
|
int net_is_disabled(void);
|
||||||
|
int net_is_completely_disabled(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1311,24 +1311,6 @@ router_should_advertise_begindir(const or_options_t *options,
|
||||||
supports_tunnelled_dir_requests);
|
supports_tunnelled_dir_requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true iff our network is in some sense disabled or shutting down:
|
|
||||||
* either we're hibernating, entering hibernation, or the network is turned
|
|
||||||
* off with DisableNetwork. */
|
|
||||||
int
|
|
||||||
net_is_disabled(void)
|
|
||||||
{
|
|
||||||
return get_options()->DisableNetwork || we_are_hibernating();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return true iff our network is in some sense "completely disabled" either
|
|
||||||
* we're fully hibernating or the network is turned off with
|
|
||||||
* DisableNetwork. */
|
|
||||||
int
|
|
||||||
net_is_completely_disabled(void)
|
|
||||||
{
|
|
||||||
return get_options()->DisableNetwork || we_are_fully_hibernating();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return true iff the combination of options in <b>options</b> and parameters
|
/** Return true iff the combination of options in <b>options</b> and parameters
|
||||||
* in the consensus mean that we don't want to allow exits from circuits
|
* in the consensus mean that we don't want to allow exits from circuits
|
||||||
* we got from addresses not known to be servers. */
|
* we got from addresses not known to be servers. */
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "feature/nodelist/describe.h"
|
#include "feature/nodelist/describe.h"
|
||||||
#include "feature/nodelist/nickname.h"
|
#include "feature/nodelist/nickname.h"
|
||||||
#include "feature/nodelist/routerinfo.h"
|
#include "feature/nodelist/routerinfo.h"
|
||||||
|
#include "core/mainloop/netstatus.h"
|
||||||
|
|
||||||
struct curve25519_keypair_t;
|
struct curve25519_keypair_t;
|
||||||
struct ed25519_keypair_t;
|
struct ed25519_keypair_t;
|
||||||
|
@ -59,9 +60,6 @@ int router_initialize_tls_context(void);
|
||||||
int init_keys(void);
|
int init_keys(void);
|
||||||
int init_keys_client(void);
|
int init_keys_client(void);
|
||||||
|
|
||||||
int net_is_disabled(void);
|
|
||||||
int net_is_completely_disabled(void);
|
|
||||||
|
|
||||||
uint16_t router_get_active_listener_port_by_type_af(int listener_type,
|
uint16_t router_get_active_listener_port_by_type_af(int listener_type,
|
||||||
sa_family_t family);
|
sa_family_t family);
|
||||||
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
||||||
|
|
Loading…
Add table
Reference in a new issue