aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_service.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-09-14 21:37:36 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2018-09-15 16:52:36 +0300
commit8f085841ef40f00bbc2bb146a2d555aba527738f (patch)
tree96deb3c31c9559bf97230b53c0bd86229ecf6a16 /src/test/test_hs_service.c
parente44e6a1857ff8ad39d3e298b512e8c8a1e513c99 (diff)
downloadtor-8f085841ef40f00bbc2bb146a2d555aba527738f.tar.gz
tor-8f085841ef40f00bbc2bb146a2d555aba527738f.zip
Encode the 32-bit Global Identifier as 2 x 16-bit in the IPv6 address.
Without this patch we would encode the IPv6 address' last part as ::ffffffff instead of ::ffff:ffff when the GID is UINT32_MAX. See: https://bugs.torproject.org/4700
Diffstat (limited to 'src/test/test_hs_service.c')
-rw-r--r--src/test/test_hs_service.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 0a1c866d6b..2b8d6e597a 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -2061,6 +2061,32 @@ test_export_client_circuit_id(void *arg)
export_hs_client_circuit_id_haproxy(edge_conn, conn);
cp2 = buf_get_contents(conn->outbuf, &sz);
tt_str_op(cp1, OP_NE, cp2);
+ tor_free(cp1);
+
+ /* Check that GID with UINT32_MAX works. */
+ or_circ->global_identifier = UINT32_MAX;
+
+ export_hs_client_circuit_id_haproxy(edge_conn, conn);
+ cp1 = buf_get_contents(conn->outbuf, &sz);
+ tt_str_op(cp1, OP_EQ,
+ "PROXY TCP6 fc00:dead:beef:4dad::ffff:ffff ::1 65535 42\r\n");
+ tor_free(cp1);
+
+ /* Check that GID with UINT16_MAX works. */
+ or_circ->global_identifier = UINT16_MAX;
+
+ export_hs_client_circuit_id_haproxy(edge_conn, conn);
+ cp1 = buf_get_contents(conn->outbuf, &sz);
+ tt_str_op(cp1, OP_EQ,
+ "PROXY TCP6 fc00:dead:beef:4dad::0:ffff ::1 65535 42\r\n");
+ tor_free(cp1);
+
+ /* Check that GID with UINT16_MAX + 7 works. */
+ or_circ->global_identifier = UINT16_MAX + 7;
+
+ export_hs_client_circuit_id_haproxy(edge_conn, conn);
+ cp1 = buf_get_contents(conn->outbuf, &sz);
+ tt_str_op(cp1, OP_EQ, "PROXY TCP6 fc00:dead:beef:4dad::1:6 ::1 6 42\r\n");
done:
UNMOCK(connection_write_to_buf_impl_);