aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/circuituse.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-05-28 09:44:06 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-05-29 09:40:13 -0400
commit3789f22bcbfbc6de415a838e4c4bfb2555c7d6c3 (patch)
tree823e4db5b38cec12156f5d3a4dfb9df725eeba64 /src/core/or/circuituse.c
parente5deb2bbc73d8830ae6c479a4532e72112f5484a (diff)
downloadtor-3789f22bcbfbc6de415a838e4c4bfb2555c7d6c3.tar.gz
tor-3789f22bcbfbc6de415a838e4c4bfb2555c7d6c3.zip
hs: Implement a helper to repurpose a circuit
When we repurpose a hidden service circuit, we need to clean up from the HS circuit map and any HS related data structured contained in the circuit. This commit adds an helper function that does it when repurposing a hidden service circuit. Fixes #29034 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/circuituse.c')
-rw-r--r--src/core/or/circuituse.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/or/circuituse.c b/src/core/or/circuituse.c
index 02bfa15fb3..465d64215b 100644
--- a/src/core/or/circuituse.c
+++ b/src/core/or/circuituse.c
@@ -3052,6 +3052,12 @@ circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
if (circ->purpose == new_purpose) return;
+ /* Take specific actions if we are repurposing a hidden service circuit. */
+ if (circuit_purpose_is_hidden_service(circ->purpose) &&
+ !circuit_purpose_is_hidden_service(new_purpose)) {
+ hs_circ_repurpose(circ);
+ }
+
if (CIRCUIT_IS_ORIGIN(circ)) {
char old_purpose_desc[80] = "";