mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Merge branch '13605_reduced_exit_squashed'
This commit is contained in:
commit
1f9764f90d
5
changes/ticket13605
Normal file
5
changes/ticket13605
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
o Major features (relay):
|
||||||
|
- Implement an option, ReducedExitPolicy, to allow an Tor exit relay
|
||||||
|
operator to use a more reasonable ("reduced") exit policy, rather
|
||||||
|
than the default one. Closes ticket 13605. Patch from Neel Chauhan.
|
||||||
|
|
101
doc/tor.1.txt
101
doc/tor.1.txt
@ -1770,7 +1770,13 @@ is non-zero):
|
|||||||
reject *:6346-6429
|
reject *:6346-6429
|
||||||
reject *:6699
|
reject *:6699
|
||||||
reject *:6881-6999
|
reject *:6881-6999
|
||||||
accept *:*
|
accept *:* +
|
||||||
|
+
|
||||||
|
If you want to use a reduced exit policy rather than the default exit
|
||||||
|
policy, set "ReducedExitPolicy 1". If you want to _replace_ the default
|
||||||
|
exit policy with your custom exit policy, end your exit policy with either
|
||||||
|
a reject *:* or an accept *:*. Otherwise, you’re _augmenting_ (prepending
|
||||||
|
to) the default or reduced exit policy.
|
||||||
|
|
||||||
[[ExitPolicyDefault]]::
|
[[ExitPolicyDefault]]::
|
||||||
Since the default exit policy uses accept/reject *, it applies to both
|
Since the default exit policy uses accept/reject *, it applies to both
|
||||||
@ -1794,6 +1800,99 @@ is non-zero):
|
|||||||
to disclose.
|
to disclose.
|
||||||
(Default: 0)
|
(Default: 0)
|
||||||
|
|
||||||
|
[[ReducedExitPolicy] **ReducedExitPolicy** **0**|**1**::
|
||||||
|
If set, use a reduced exit policy rather than the default one. +
|
||||||
|
+
|
||||||
|
The reduced exit policy is an alternative to the default exit policy. It
|
||||||
|
allows as many Internet services as possible while still blocking the
|
||||||
|
majority of TCP ports. Currently, the policy allows approximately 65 ports.
|
||||||
|
This reduces the odds that your node will be used for peer-to-peer
|
||||||
|
applications. +
|
||||||
|
+
|
||||||
|
The reduced exit policy is:
|
||||||
|
|
||||||
|
accept *:20-21
|
||||||
|
accept *:22
|
||||||
|
accept *:23
|
||||||
|
accept *:43
|
||||||
|
accept *:53
|
||||||
|
accept *:79
|
||||||
|
accept *:80-81
|
||||||
|
accept *:88
|
||||||
|
accept *:110
|
||||||
|
accept *:143
|
||||||
|
accept *:194
|
||||||
|
accept *:220
|
||||||
|
accept *:389
|
||||||
|
accept *:443
|
||||||
|
accept *:464
|
||||||
|
accept *:465
|
||||||
|
accept *:531
|
||||||
|
accept *:543-544
|
||||||
|
accept *:554
|
||||||
|
accept *:563
|
||||||
|
accept *:587
|
||||||
|
accept *:636
|
||||||
|
accept *:706
|
||||||
|
accept *:749
|
||||||
|
accept *:873
|
||||||
|
accept *:902-904
|
||||||
|
accept *:981
|
||||||
|
accept *:989-990
|
||||||
|
accept *:991
|
||||||
|
accept *:992
|
||||||
|
accept *:993
|
||||||
|
accept *:994
|
||||||
|
accept *:995
|
||||||
|
accept *:1194
|
||||||
|
accept *:1220
|
||||||
|
accept *:1293
|
||||||
|
accept *:1500
|
||||||
|
accept *:1533
|
||||||
|
accept *:1677
|
||||||
|
accept *:1723
|
||||||
|
accept *:1755
|
||||||
|
accept *:1863
|
||||||
|
accept *:2082
|
||||||
|
accept *:2083
|
||||||
|
accept *:2086-2087
|
||||||
|
accept *:2095-2096
|
||||||
|
accept *:2102-2104
|
||||||
|
accept *:3128
|
||||||
|
accept *:3389
|
||||||
|
accept *:3690
|
||||||
|
accept *:4321
|
||||||
|
accept *:4643
|
||||||
|
accept *:5050
|
||||||
|
accept *:5190
|
||||||
|
accept *:5222-5223
|
||||||
|
accept *:5228
|
||||||
|
accept *:5900
|
||||||
|
accept *:6660-6669
|
||||||
|
accept *:6679
|
||||||
|
accept *:6697
|
||||||
|
accept *:8000
|
||||||
|
accept *:8008
|
||||||
|
accept *:8074
|
||||||
|
accept *:8080
|
||||||
|
accept *:8082
|
||||||
|
accept *:8087-8088
|
||||||
|
accept *:8232-8233
|
||||||
|
accept *:8332-8333
|
||||||
|
accept *:8443
|
||||||
|
accept *:8888
|
||||||
|
accept *:9418
|
||||||
|
accept *:9999
|
||||||
|
accept *:10000
|
||||||
|
accept *:11371
|
||||||
|
accept *:19294
|
||||||
|
accept *:19638
|
||||||
|
accept *:50002
|
||||||
|
accept *:64738
|
||||||
|
reject *:* +
|
||||||
|
+
|
||||||
|
(Default: 0)
|
||||||
|
|
||||||
[[IPv6Exit]] **IPv6Exit** **0**|**1**::
|
[[IPv6Exit]] **IPv6Exit** **0**|**1**::
|
||||||
If set, and we are an exit node, allow clients to use us for IPv6
|
If set, and we are an exit node, allow clients to use us for IPv6
|
||||||
traffic. (Default: 0)
|
traffic. (Default: 0)
|
||||||
|
@ -485,6 +485,7 @@ static config_var_t option_vars_[] = {
|
|||||||
V(RendPostPeriod, INTERVAL, "1 hour"),
|
V(RendPostPeriod, INTERVAL, "1 hour"),
|
||||||
V(RephistTrackTime, INTERVAL, "24 hours"),
|
V(RephistTrackTime, INTERVAL, "24 hours"),
|
||||||
V(RunAsDaemon, BOOL, "0"),
|
V(RunAsDaemon, BOOL, "0"),
|
||||||
|
V(ReducedExitPolicy, BOOL, "0"),
|
||||||
OBSOLETE("RunTesting"), // currently unused
|
OBSOLETE("RunTesting"), // currently unused
|
||||||
V(Sandbox, BOOL, "0"),
|
V(Sandbox, BOOL, "0"),
|
||||||
V(SafeLogging, STRING, "1"),
|
V(SafeLogging, STRING, "1"),
|
||||||
|
@ -3674,6 +3674,7 @@ typedef struct {
|
|||||||
* interface addresses?
|
* interface addresses?
|
||||||
* Includes OutboundBindAddresses and
|
* Includes OutboundBindAddresses and
|
||||||
* configured ports. */
|
* configured ports. */
|
||||||
|
int ReducedExitPolicy; /**<Should we use the Reduced Exit Policy? */
|
||||||
config_line_t *SocksPolicy; /**< Lists of socks policy components */
|
config_line_t *SocksPolicy; /**< Lists of socks policy components */
|
||||||
config_line_t *DirPolicy; /**< Lists of dir policy components */
|
config_line_t *DirPolicy; /**< Lists of dir policy components */
|
||||||
/** Local address to bind outbound sockets */
|
/** Local address to bind outbound sockets */
|
||||||
|
@ -81,7 +81,8 @@ static int policies_parse_exit_policy_internal(
|
|||||||
const smartlist_t *configured_addresses,
|
const smartlist_t *configured_addresses,
|
||||||
int reject_interface_addresses,
|
int reject_interface_addresses,
|
||||||
int reject_configured_port_addresses,
|
int reject_configured_port_addresses,
|
||||||
int add_default_policy);
|
int add_default_policy,
|
||||||
|
int add_reduced_policy);
|
||||||
|
|
||||||
/** Replace all "private" entries in *<b>policy</b> with their expanded
|
/** Replace all "private" entries in *<b>policy</b> with their expanded
|
||||||
* equivalents. */
|
* equivalents. */
|
||||||
@ -1144,7 +1145,7 @@ validate_addr_policies(const or_options_t *options, char **msg)
|
|||||||
"to 1 to disable this warning, and for forward compatibility.",
|
"to 1 to disable this warning, and for forward compatibility.",
|
||||||
options->ExitPolicy == NULL ?
|
options->ExitPolicy == NULL ?
|
||||||
" with the default exit policy" : "");
|
" with the default exit policy" : "");
|
||||||
if (options->ExitPolicy == NULL) {
|
if (options->ExitPolicy == NULL && options->ReducedExitPolicy == 0) {
|
||||||
log_warn(LD_CONFIG,
|
log_warn(LD_CONFIG,
|
||||||
"In a future version of Tor, ExitRelay 0 may become the "
|
"In a future version of Tor, ExitRelay 0 may become the "
|
||||||
"default when no ExitPolicy is given.");
|
"default when no ExitPolicy is given.");
|
||||||
@ -1877,6 +1878,24 @@ policies_log_first_redundant_entry(const smartlist_t *policy)
|
|||||||
"reject *:563,reject *:1214,reject *:4661-4666," \
|
"reject *:563,reject *:1214,reject *:4661-4666," \
|
||||||
"reject *:6346-6429,reject *:6699,reject *:6881-6999,accept *:*"
|
"reject *:6346-6429,reject *:6699,reject *:6881-6999,accept *:*"
|
||||||
|
|
||||||
|
#define REDUCED_EXIT_POLICY \
|
||||||
|
"accept *:20-23,accept *:43,accept *:53,accept *:79-81,accept *:88," \
|
||||||
|
"accept *:110,accept *:143,accept *:194,accept *:220,accept *:389," \
|
||||||
|
"accept *:443,accept *:464,accept *:465,accept *:531,accept *:543-544," \
|
||||||
|
"accept *:554,accept *:563,accept *:587,accept *:636,accept *:706," \
|
||||||
|
"accept *:749,accept *:873,accept *:902-904,accept *:981,accept *:989-995," \
|
||||||
|
"accept *:1194,accept *:1220,accept *:1293,accept *:1500,accept *:1533," \
|
||||||
|
"accept *:1677,accept *:1723,accept *:1755,accept *:1863," \
|
||||||
|
"accept *:2082-2083,accept *:2086-2087,accept *:2095-2096," \
|
||||||
|
"accept *:2102-2104,accept *:3128,accept *:3389,accept *:3690," \
|
||||||
|
"accept *:4321,accept *:4643,accept *:5050,accept *:5190," \
|
||||||
|
"accept *:5222-5223,accept *:5228,accept *:5900,accept *:6660-6669," \
|
||||||
|
"accept *:6679,accept *:6697,accept *:8000,accept *:8008,accept *:8074," \
|
||||||
|
"accept *:8080,accept *:8082,accept *:8087-8088,accept *:8232-8233," \
|
||||||
|
"accept *:8332-8333,accept *:8443,accept *:8888,accept *:9418," \
|
||||||
|
"accept *:9999,accept *:10000,accept *:11371,accept *:19294," \
|
||||||
|
"accept *:19638,accept *:50002,accept *:64738,reject *:*"
|
||||||
|
|
||||||
/** Parse the exit policy <b>cfg</b> into the linked list *<b>dest</b>.
|
/** Parse the exit policy <b>cfg</b> into the linked list *<b>dest</b>.
|
||||||
*
|
*
|
||||||
* If <b>ipv6_exit</b> is false, prepend "reject *6:*" to the policy.
|
* If <b>ipv6_exit</b> is false, prepend "reject *6:*" to the policy.
|
||||||
@ -1912,7 +1931,8 @@ policies_parse_exit_policy_internal(config_line_t *cfg,
|
|||||||
const smartlist_t *configured_addresses,
|
const smartlist_t *configured_addresses,
|
||||||
int reject_interface_addresses,
|
int reject_interface_addresses,
|
||||||
int reject_configured_port_addresses,
|
int reject_configured_port_addresses,
|
||||||
int add_default_policy)
|
int add_default_policy,
|
||||||
|
int add_reduced_policy)
|
||||||
{
|
{
|
||||||
if (!ipv6_exit) {
|
if (!ipv6_exit) {
|
||||||
append_exit_policy_string(dest, "reject *6:*");
|
append_exit_policy_string(dest, "reject *6:*");
|
||||||
@ -1938,7 +1958,9 @@ policies_parse_exit_policy_internal(config_line_t *cfg,
|
|||||||
* effect, and are most likely an error. */
|
* effect, and are most likely an error. */
|
||||||
policies_log_first_redundant_entry(*dest);
|
policies_log_first_redundant_entry(*dest);
|
||||||
|
|
||||||
if (add_default_policy) {
|
if (add_reduced_policy) {
|
||||||
|
append_exit_policy_string(dest, REDUCED_EXIT_POLICY);
|
||||||
|
} else if (add_default_policy) {
|
||||||
append_exit_policy_string(dest, DEFAULT_EXIT_POLICY);
|
append_exit_policy_string(dest, DEFAULT_EXIT_POLICY);
|
||||||
} else {
|
} else {
|
||||||
append_exit_policy_string(dest, "reject *4:*");
|
append_exit_policy_string(dest, "reject *4:*");
|
||||||
@ -1979,13 +2001,15 @@ policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
|
|||||||
int add_default = (options & EXIT_POLICY_ADD_DEFAULT) ? 1 : 0;
|
int add_default = (options & EXIT_POLICY_ADD_DEFAULT) ? 1 : 0;
|
||||||
int reject_local_interfaces = (options &
|
int reject_local_interfaces = (options &
|
||||||
EXIT_POLICY_REJECT_LOCAL_INTERFACES) ? 1 : 0;
|
EXIT_POLICY_REJECT_LOCAL_INTERFACES) ? 1 : 0;
|
||||||
|
int add_reduced = (options & EXIT_POLICY_ADD_REDUCED) ? 1 : 0;
|
||||||
|
|
||||||
return policies_parse_exit_policy_internal(cfg,dest,ipv6_enabled,
|
return policies_parse_exit_policy_internal(cfg,dest,ipv6_enabled,
|
||||||
reject_private,
|
reject_private,
|
||||||
configured_addresses,
|
configured_addresses,
|
||||||
reject_local_interfaces,
|
reject_local_interfaces,
|
||||||
reject_local_interfaces,
|
reject_local_interfaces,
|
||||||
add_default);
|
add_default,
|
||||||
|
add_reduced);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper function that adds a copy of addr to a smartlist as long as it is
|
/** Helper function that adds a copy of addr to a smartlist as long as it is
|
||||||
@ -2095,7 +2119,10 @@ policies_parse_exit_policy_from_options(const or_options_t *or_options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!or_options->BridgeRelay) {
|
if (!or_options->BridgeRelay) {
|
||||||
parser_cfg |= EXIT_POLICY_ADD_DEFAULT;
|
if (or_options->ReducedExitPolicy)
|
||||||
|
parser_cfg |= EXIT_POLICY_ADD_REDUCED;
|
||||||
|
else
|
||||||
|
parser_cfg |= EXIT_POLICY_ADD_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or_options->ExitPolicyRejectLocalInterfaces) {
|
if (or_options->ExitPolicyRejectLocalInterfaces) {
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#define EXIT_POLICY_REJECT_PRIVATE (1 << 1)
|
#define EXIT_POLICY_REJECT_PRIVATE (1 << 1)
|
||||||
#define EXIT_POLICY_ADD_DEFAULT (1 << 2)
|
#define EXIT_POLICY_ADD_DEFAULT (1 << 2)
|
||||||
#define EXIT_POLICY_REJECT_LOCAL_INTERFACES (1 << 3)
|
#define EXIT_POLICY_REJECT_LOCAL_INTERFACES (1 << 3)
|
||||||
#define EXIT_POLICY_OPTION_MAX EXIT_POLICY_REJECT_LOCAL_INTERFACES
|
#define EXIT_POLICY_ADD_REDUCED (1 << 4)
|
||||||
|
#define EXIT_POLICY_OPTION_MAX EXIT_POLICY_ADD_REDUCED
|
||||||
/* All options set: used for unit testing */
|
/* All options set: used for unit testing */
|
||||||
#define EXIT_POLICY_OPTION_ALL ((EXIT_POLICY_OPTION_MAX << 1) - 1)
|
#define EXIT_POLICY_OPTION_ALL ((EXIT_POLICY_OPTION_MAX << 1) - 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user