mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-01 08:03:31 +01:00
Use same macros to simplify options_transition_affects_*
This commit is contained in:
parent
376f97aaa1
commit
93e7b837c8
127
src/or/config.c
127
src/or/config.c
@ -1677,32 +1677,46 @@ get_effective_bwburst(const or_options_t *options)
|
|||||||
return (uint32_t)bw;
|
return (uint32_t)bw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Used in the various options_transition_affects* functions. */
|
||||||
|
#define YES_IF_CHANGED_BOOL(opt) \
|
||||||
|
if (!CFG_EQ_BOOL(old_options, new_options, opt)) return 1;
|
||||||
|
#define YES_IF_CHANGED_INT(opt) \
|
||||||
|
if (!CFG_EQ_INT(old_options, new_options, opt)) return 1;
|
||||||
|
#define YES_IF_CHANGED_STRING(opt) \
|
||||||
|
if (!CFG_EQ_STRING(old_options, new_options, opt)) return 1;
|
||||||
|
#define YES_IF_CHANGED_LINELIST(opt) \
|
||||||
|
if (!CFG_EQ_LINELIST(old_options, new_options, opt)) return 1;
|
||||||
|
#define YES_IF_CHANGED_SMARTLIST(opt) \
|
||||||
|
if (!CFG_EQ_SMARTLIST(old_options, new_options, opt)) return 1;
|
||||||
|
#define YES_IF_CHANGED_ROUTERSET(opt) \
|
||||||
|
if (!CFG_EQ_ROUTERSET(old_options, new_options, opt)) return 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if changing the configuration from <b>old</b> to <b>new</b>
|
* Return true if changing the configuration from <b>old</b> to <b>new</b>
|
||||||
* affects the guard susbsystem.
|
* affects the guard subsystem.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
options_transition_affects_guards(const or_options_t *old,
|
options_transition_affects_guards(const or_options_t *old_options,
|
||||||
const or_options_t *new)
|
const or_options_t *new_options)
|
||||||
{
|
{
|
||||||
/* NOTE: Make sure this function stays in sync with
|
/* NOTE: Make sure this function stays in sync with
|
||||||
* node_passes_guard_filter */
|
* node_passes_guard_filter */
|
||||||
|
tor_assert(old_options);
|
||||||
|
tor_assert(new_options);
|
||||||
|
|
||||||
tor_assert(old);
|
YES_IF_CHANGED_BOOL(UseEntryGuards);
|
||||||
tor_assert(new);
|
YES_IF_CHANGED_BOOL(UseBridges);
|
||||||
|
YES_IF_CHANGED_BOOL(ClientUseIPv4);
|
||||||
|
YES_IF_CHANGED_BOOL(ClientUseIPv6);
|
||||||
|
YES_IF_CHANGED_BOOL(FascistFirewall);
|
||||||
|
YES_IF_CHANGED_ROUTERSET(ExcludeNodes);
|
||||||
|
YES_IF_CHANGED_ROUTERSET(EntryNodes);
|
||||||
|
YES_IF_CHANGED_SMARTLIST(FirewallPorts);
|
||||||
|
YES_IF_CHANGED_LINELIST(Bridges);
|
||||||
|
YES_IF_CHANGED_LINELIST(ReachableORAddresses);
|
||||||
|
YES_IF_CHANGED_LINELIST(ReachableDirAddresses);
|
||||||
|
|
||||||
return
|
return 0;
|
||||||
(old->UseEntryGuards != new->UseEntryGuards ||
|
|
||||||
old->UseBridges != new->UseBridges ||
|
|
||||||
old->ClientUseIPv4 != new->ClientUseIPv4 ||
|
|
||||||
old->ClientUseIPv6 != new->ClientUseIPv6 ||
|
|
||||||
old->FascistFirewall != new->FascistFirewall ||
|
|
||||||
!routerset_equal(old->ExcludeNodes, new->ExcludeNodes) ||
|
|
||||||
!routerset_equal(old->EntryNodes, new->EntryNodes) ||
|
|
||||||
!smartlist_strings_eq(old->FirewallPorts, new->FirewallPorts) ||
|
|
||||||
!config_lines_eq(old->Bridges, new->Bridges) ||
|
|
||||||
!config_lines_eq(old->ReachableORAddresses, new->ReachableORAddresses) ||
|
|
||||||
!config_lines_eq(old->ReachableDirAddresses, new->ReachableDirAddresses));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch the active option list, and take actions based on it. All of the
|
/** Fetch the active option list, and take actions based on it. All of the
|
||||||
@ -4712,20 +4726,18 @@ static int
|
|||||||
options_transition_affects_workers(const or_options_t *old_options,
|
options_transition_affects_workers(const or_options_t *old_options,
|
||||||
const or_options_t *new_options)
|
const or_options_t *new_options)
|
||||||
{
|
{
|
||||||
if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) ||
|
YES_IF_CHANGED_STRING(DataDirectory);
|
||||||
old_options->NumCPUs != new_options->NumCPUs ||
|
YES_IF_CHANGED_INT(NumCPUs);
|
||||||
!config_lines_eq(old_options->ORPort_lines, new_options->ORPort_lines) ||
|
YES_IF_CHANGED_LINELIST(ORPort_lines);
|
||||||
old_options->ServerDNSSearchDomains !=
|
YES_IF_CHANGED_BOOL(ServerDNSSearchDomains);
|
||||||
new_options->ServerDNSSearchDomains ||
|
YES_IF_CHANGED_BOOL(SafeLogging_);
|
||||||
old_options->SafeLogging_ != new_options->SafeLogging_ ||
|
YES_IF_CHANGED_BOOL(ClientOnly);
|
||||||
old_options->ClientOnly != new_options->ClientOnly ||
|
YES_IF_CHANGED_BOOL(LogMessageDomains);
|
||||||
server_mode(old_options) != server_mode(new_options) ||
|
YES_IF_CHANGED_LINELIST(Logs);
|
||||||
public_server_mode(old_options) != public_server_mode(new_options) ||
|
|
||||||
!config_lines_eq(old_options->Logs, new_options->Logs) ||
|
|
||||||
old_options->LogMessageDomains != new_options->LogMessageDomains)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* Check whether log options match. */
|
if (server_mode(old_options) != server_mode(new_options) ||
|
||||||
|
public_server_mode(old_options) != public_server_mode(new_options))
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* Nothing that changed matters. */
|
/* Nothing that changed matters. */
|
||||||
return 0;
|
return 0;
|
||||||
@ -4739,37 +4751,34 @@ options_transition_affects_descriptor(const or_options_t *old_options,
|
|||||||
{
|
{
|
||||||
/* XXX We can be smarter here. If your DirPort isn't being
|
/* XXX We can be smarter here. If your DirPort isn't being
|
||||||
* published and you just turned it off, no need to republish. Etc. */
|
* published and you just turned it off, no need to republish. Etc. */
|
||||||
if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) ||
|
|
||||||
!opt_streq(old_options->Nickname,new_options->Nickname) ||
|
YES_IF_CHANGED_STRING(DataDirectory);
|
||||||
!opt_streq(old_options->Address,new_options->Address) ||
|
YES_IF_CHANGED_STRING(Nickname);
|
||||||
!config_lines_eq(old_options->ExitPolicy,new_options->ExitPolicy) ||
|
YES_IF_CHANGED_STRING(Address);
|
||||||
old_options->ExitRelay != new_options->ExitRelay ||
|
YES_IF_CHANGED_LINELIST(ExitPolicy);
|
||||||
old_options->ExitPolicyRejectPrivate !=
|
YES_IF_CHANGED_BOOL(ExitRelay);
|
||||||
new_options->ExitPolicyRejectPrivate ||
|
YES_IF_CHANGED_BOOL(ExitPolicyRejectPrivate);
|
||||||
old_options->ExitPolicyRejectLocalInterfaces !=
|
YES_IF_CHANGED_BOOL(ExitPolicyRejectLocalInterfaces);
|
||||||
new_options->ExitPolicyRejectLocalInterfaces ||
|
YES_IF_CHANGED_BOOL(IPv6Exit);
|
||||||
old_options->IPv6Exit != new_options->IPv6Exit ||
|
YES_IF_CHANGED_LINELIST(ORPort_lines);
|
||||||
!config_lines_eq(old_options->ORPort_lines,
|
YES_IF_CHANGED_LINELIST(DirPort_lines);
|
||||||
new_options->ORPort_lines) ||
|
YES_IF_CHANGED_LINELIST(DirPort_lines);
|
||||||
!config_lines_eq(old_options->DirPort_lines,
|
YES_IF_CHANGED_BOOL(ClientOnly);
|
||||||
new_options->DirPort_lines) ||
|
YES_IF_CHANGED_BOOL(DisableNetwork);
|
||||||
old_options->ClientOnly != new_options->ClientOnly ||
|
YES_IF_CHANGED_BOOL(PublishServerDescriptor_);
|
||||||
old_options->DisableNetwork != new_options->DisableNetwork ||
|
YES_IF_CHANGED_STRING(ContactInfo);
|
||||||
old_options->PublishServerDescriptor_ !=
|
YES_IF_CHANGED_STRING(BridgeDistribution);
|
||||||
new_options->PublishServerDescriptor_ ||
|
YES_IF_CHANGED_LINELIST(MyFamily);
|
||||||
get_effective_bwrate(old_options) != get_effective_bwrate(new_options) ||
|
YES_IF_CHANGED_STRING(AccountingStart);
|
||||||
|
YES_IF_CHANGED_INT(AccountingMax);
|
||||||
|
YES_IF_CHANGED_INT(AccountingRule);
|
||||||
|
YES_IF_CHANGED_BOOL(DirCache);
|
||||||
|
YES_IF_CHANGED_BOOL(AssumeReachable);
|
||||||
|
|
||||||
|
if (get_effective_bwrate(old_options) != get_effective_bwrate(new_options) ||
|
||||||
get_effective_bwburst(old_options) !=
|
get_effective_bwburst(old_options) !=
|
||||||
get_effective_bwburst(new_options) ||
|
get_effective_bwburst(new_options) ||
|
||||||
!opt_streq(old_options->ContactInfo, new_options->ContactInfo) ||
|
public_server_mode(old_options) != public_server_mode(new_options))
|
||||||
!opt_streq(old_options->BridgeDistribution,
|
|
||||||
new_options->BridgeDistribution) ||
|
|
||||||
!config_lines_eq(old_options->MyFamily, new_options->MyFamily) ||
|
|
||||||
!opt_streq(old_options->AccountingStart, new_options->AccountingStart) ||
|
|
||||||
old_options->AccountingMax != new_options->AccountingMax ||
|
|
||||||
old_options->AccountingRule != new_options->AccountingRule ||
|
|
||||||
public_server_mode(old_options) != public_server_mode(new_options) ||
|
|
||||||
old_options->DirCache != new_options->DirCache ||
|
|
||||||
old_options->AssumeReachable != new_options->AssumeReachable)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user