From db0aaf428ebb00b37b451db1d5eecb2fd5689b79 Mon Sep 17 00:00:00 2001 From: Alexander Færøy Date: Tue, 2 Jul 2019 19:03:39 +0200 Subject: Add `OutboundBindAddressPT` to torrc. This patch adds a new option to torrc: `OutboundBindAddressPT`. This option works in the same way as `OutboundBindAddressOR` and `OutboundBindAddressExit` in that it allows the user to specify which outbound IP address the user wants the PT to make its connections from. There is one difference though in that OutboundBindAddressPT will only be a suggestion for the PT to use since Tor cannot enforce whether or not the PT actually uses this option for anything. See: https://bugs.torproject.org/5304 --- src/app/config/config.c | 10 +++++++++- src/app/config/or_options_st.h | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/app/config/config.c b/src/app/config/config.c index 5c8a3792ee..9fee83aebb 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -580,6 +580,7 @@ static const config_var_t option_vars_[] = { V(OutboundBindAddress, LINELIST, NULL), V(OutboundBindAddressOR, LINELIST, NULL), V(OutboundBindAddressExit, LINELIST, NULL), + V(OutboundBindAddressPT, LINELIST, NULL), OBSOLETE("PathBiasDisableRate"), V(PathBiasCircThreshold, INT, "-1"), @@ -7180,7 +7181,8 @@ parse_outbound_address_lines(const config_line_t *lines, outbound_addr_t type, "configured: %s", family==AF_INET?" IPv4":(family==AF_INET6?" IPv6":""), type==OUTBOUND_ADDR_OR?" OR": - (type==OUTBOUND_ADDR_EXIT?" exit":""), lines->value); + (type==OUTBOUND_ADDR_EXIT?" exit": + (type==OUTBOUND_ADDR_PT?" PT":"")), lines->value); return -1; } lines = lines->next; @@ -7220,6 +7222,12 @@ parse_outbound_addresses(or_options_t *options, int validate_only, char **msg) goto err; } + if (parse_outbound_address_lines(options->OutboundBindAddressPT, + OUTBOUND_ADDR_PT, options, validate_only, + msg) < 0) { + goto err; + } + return 0; err: return -1; diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h index 9520a1b736..ce3006cc37 100644 --- a/src/app/config/or_options_st.h +++ b/src/app/config/or_options_st.h @@ -34,6 +34,10 @@ typedef enum { * `OutboundBindAddressOR` configuration entry in torrc. */ OUTBOUND_ADDR_OR, + /** Outbound IP address for PT connections. Controlled by the + * `OutboundBindAddressPT` configuration entry in torrc. */ + OUTBOUND_ADDR_PT, + /** Outbound IP address for both Exit and OR connections. Controlled by the * OutboundBindAddress configuration entry in torrc. This value is used as * fallback if the more specific OUTBOUND_ADDR_EXIT and OUTBOUND_ADDR_OR is @@ -146,6 +150,8 @@ struct or_options_t { struct config_line_t *OutboundBindAddressOR; /** Local address to bind outbound exit sockets */ struct config_line_t *OutboundBindAddressExit; + /** Local address to bind outbound PT sockets */ + struct config_line_t *OutboundBindAddressPT; /** Addresses derived from the various OutboundBindAddress lines. * [][0] is IPv4, [][1] is IPv6 */ -- cgit v1.2.3-54-g00ecf