tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 3eb9331133a0606e86114bb613f03c674050932d
parent 67fc69c8c1546d1f02f66848997192023f7d1141
Author: Nick Mathewson <nickm@torproject.org>
Date:   Mon, 10 Aug 2020 14:51:12 -0400

Merge remote-tracking branch 'tor-gitlab/mr/110'

Diffstat:
Achanges/ticket40039 | 5+++++
Msrc/feature/control/control_getinfo.c | 15++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/changes/ticket40039 b/changes/ticket40039 @@ -0,0 +1,5 @@ + o Minor features (control port, relay): + - Introduce "GETINFO address/v4" and "GETINFO address/v6" in the control + port to fetch the Tor host's respective IPv4 or IPv6 address. We keep + "GETINFO address" for backwords-compatibility which retains the current + behavior. Closes ticket 40039. Patch by Neel Chauhan. diff --git a/src/feature/control/control_getinfo.c b/src/feature/control/control_getinfo.c @@ -131,7 +131,7 @@ getinfo_helper_misc(control_connection_t *conn, const char *question, smartlist_free(signal_names); } else if (!strcmp(question, "features/names")) { *answer = tor_strdup("VERBOSE_NAMES EXTENDED_EVENTS"); - } else if (!strcmp(question, "address")) { + } else if (!strcmp(question, "address") || !strcmp(question, "address/v4")) { tor_addr_t addr; if (!relay_find_addr_to_publish(get_options(), AF_INET, RELAY_FIND_ADDR_CACHE_ONLY, &addr)) { @@ -140,6 +140,15 @@ getinfo_helper_misc(control_connection_t *conn, const char *question, } *answer = tor_addr_to_str_dup(&addr); tor_assert_nonfatal(*answer); + } else if (!strcmp(question, "address/v6")) { + tor_addr_t addr; + if (!relay_find_addr_to_publish(get_options(), AF_INET6, + RELAY_FIND_ADDR_CACHE_ONLY, &addr)) { + *errmsg = "Address unknown"; + return -1; + } + *answer = tor_addr_to_str_dup(&addr); + tor_assert_nonfatal(*answer); } else if (!strcmp(question, "traffic/read")) { tor_asprintf(answer, "%"PRIu64, (get_bytes_read())); } else if (!strcmp(question, "traffic/written")) { @@ -1663,6 +1672,10 @@ static const getinfo_item_t getinfo_items[] = { DOC("status/version/recommended", "List of currently recommended versions."), DOC("status/version/current", "Status of the current version."), ITEM("address", misc, "IP address of this Tor host, if we can guess it."), + ITEM("address/v4", misc, + "IPv4 address of this Tor host, if we can guess it."), + ITEM("address/v6", misc, + "IPv6 address of this Tor host, if we can guess it."), ITEM("traffic/read", misc,"Bytes read since the process was started."), ITEM("traffic/written", misc, "Bytes written since the process was started."),