diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-14 13:53:27 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-07-16 09:02:10 -0400 |
commit | 0ccdf05dc54bf956348b0647414732b6a497d17a (patch) | |
tree | 44caca876238a69ed7f447aa5aff30f0bb29a041 /src/test/test_channel.c | |
parent | 382387882c3f9cfaac6ee0c83908dc24135ba5c4 (diff) | |
download | tor-0ccdf05dc54bf956348b0647414732b6a497d17a.tar.gz tor-0ccdf05dc54bf956348b0647414732b6a497d17a.zip |
Minor refactoring on channel_get_remote_addr_if_possible()
* We no longer call this an optional method
* We document that it returns the real address, not a canonical one.
* We have it try harder if the real address hasn't been set yet.
Diffstat (limited to 'src/test/test_channel.c')
-rw-r--r-- | src/test/test_channel.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/test_channel.c b/src/test/test_channel.c index 2b723b4a8d..efe195eac4 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -166,13 +166,21 @@ static const char * chan_test_get_remote_descr(channel_t *ch, int flags) { tt_assert(ch); - tt_int_op(flags & ~(GRD_FLAG_ORIGINAL | GRD_FLAG_ADDR_ONLY), OP_EQ, 0); + tt_int_op(flags & ~(GRD_FLAG_ORIGINAL), OP_EQ, 0); done: return "Fake channel for unit tests; no real endpoint"; } static int +chan_test_get_remote_addr(const channel_t *ch, tor_addr_t *out) +{ + (void)ch; + tor_addr_from_ipv4h(out, 0x7f000001); + return 1; +} + +static int chan_test_num_cells_writeable(channel_t *ch) { tt_assert(ch); @@ -269,6 +277,7 @@ new_fake_channel(void) chan->close = chan_test_close; chan->num_cells_writeable = chan_test_num_cells_writeable; chan->get_remote_descr = chan_test_get_remote_descr; + chan->get_remote_addr = chan_test_get_remote_addr; chan->write_packed_cell = chan_test_write_packed_cell; chan->write_var_cell = chan_test_write_var_cell; chan->state = CHANNEL_STATE_OPEN; |