diff options
author | Nick Mathewson <nickm@torproject.org> | 2021-02-08 10:31:30 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2021-02-08 10:31:30 -0500 |
commit | 90add50550f2e101de5383e926d1f2729d8987ce (patch) | |
tree | 285b6adbd529e3851dc47d3a4e3fe63a474786bf /src/feature/control | |
parent | 177b535e7295161db3ac62641173331310ab2ea5 (diff) | |
parent | d159bdb0f498167c2f9ea0004a56bf6f64f2c9ff (diff) | |
download | tor-90add50550f2e101de5383e926d1f2729d8987ce.tar.gz tor-90add50550f2e101de5383e926d1f2729d8987ce.zip |
Merge branch 'bug40249_squashed'
Diffstat (limited to 'src/feature/control')
-rw-r--r-- | src/feature/control/control_cmd.c | 2 | ||||
-rw-r--r-- | src/feature/control/control_events.c | 29 | ||||
-rw-r--r-- | src/feature/control/control_events.h | 2 |
3 files changed, 21 insertions, 12 deletions
diff --git a/src/feature/control/control_cmd.c b/src/feature/control/control_cmd.c index 32c87c6daa..623c6d2eae 100644 --- a/src/feature/control/control_cmd.c +++ b/src/feature/control/control_cmd.c @@ -1233,7 +1233,7 @@ handle_control_resolve(control_connection_t *conn, send_control_done(conn); SMARTLIST_FOREACH(failed, const char *, arg, { control_event_address_mapped(arg, arg, time(NULL), - "internal", 0); + "internal", 0, 0); }); smartlist_free(failed); diff --git a/src/feature/control/control_events.c b/src/feature/control/control_events.c index c0ccb1eb26..b38b7a4f42 100644 --- a/src/feature/control/control_events.c +++ b/src/feature/control/control_events.c @@ -1477,31 +1477,40 @@ control_event_descriptors_changed(smartlist_t *routers) * mode of the mapping. */ int -control_event_address_mapped(const char *from, const char *to, time_t expires, - const char *error, const int cached) +control_event_address_mapped(const char *from, const char *to, + time_t expires, const char *error, + const int cached, uint64_t stream_id) { + char *stream_id_str = NULL; if (!EVENT_IS_INTERESTING(EVENT_ADDRMAP)) return 0; + if (stream_id) { + tor_asprintf(&stream_id_str, " STREAMID=%"PRIu64"", stream_id); + } + if (expires < 3 || expires == TIME_MAX) send_control_event(EVENT_ADDRMAP, "650 ADDRMAP %s %s NEVER %s%s" - "CACHED=\"%s\"\r\n", - from, to, error?error:"", error?" ":"", - cached?"YES":"NO"); + "CACHED=\"%s\"%s\r\n", + from, to, error ? error : "", error ? " " : "", + cached ? "YES" : "NO", + stream_id ? stream_id_str : ""); else { char buf[ISO_TIME_LEN+1]; char buf2[ISO_TIME_LEN+1]; format_local_iso_time(buf,expires); format_iso_time(buf2,expires); send_control_event(EVENT_ADDRMAP, - "650 ADDRMAP %s %s \"%s\"" - " %s%sEXPIRES=\"%s\" CACHED=\"%s\"\r\n", - from, to, buf, - error?error:"", error?" ":"", - buf2, cached?"YES":"NO"); + "650 ADDRMAP %s %s \"%s\" %s%sEXPIRES=\"%s\" " + "CACHED=\"%s\"%s\r\n", + from, to, buf, error ? error : "", + error ? " " : "", buf2, cached ? "YES" : "NO", + stream_id ? stream_id_str: ""); } + tor_free(stream_id_str); + return 0; } /** The network liveness has changed; this is called from circuitstats.c diff --git a/src/feature/control/control_events.h b/src/feature/control/control_events.h index 0ac233cc6e..e499c037ba 100644 --- a/src/feature/control/control_events.h +++ b/src/feature/control/control_events.h @@ -137,7 +137,7 @@ void control_event_logmsg_pending(void); int control_event_descriptors_changed(smartlist_t *routers); int control_event_address_mapped(const char *from, const char *to, time_t expires, const char *error, - const int cached); + const int cached, uint64_t stream_id); int control_event_my_descriptor_changed(void); int control_event_network_liveness_update(int liveness); int control_event_networkstatus_changed(smartlist_t *statuses); |