|
@@ -21,22 +21,33 @@ hs_helper_build_intro_point(const ed25519_keypair_t *signing_kp, time_t now,
|
|
|
|
|
|
* keyid and one ipv4 */
|
|
* keyid and one ipv4 */
|
|
{
|
|
{
|
|
- hs_desc_link_specifier_t *ls_legacy = tor_malloc_zero(sizeof(*ls_legacy));
|
|
+ tor_addr_t a;
|
|
- hs_desc_link_specifier_t *ls_v4 = tor_malloc_zero(sizeof(*ls_v4));
|
|
+ tor_addr_make_unspec(&a);
|
|
- ls_legacy->type = LS_LEGACY_ID;
|
|
+ link_specifier_t *ls_legacy = link_specifier_new();
|
|
- memcpy(ls_legacy->u.legacy_id, "0299F268FCA9D55CD157976D39AE92B4B455B3A8",
|
|
+
|
|
- DIGEST_LEN);
|
|
+ link_specifier_t *ls_v4 = link_specifier_new();
|
|
- ls_v4->u.ap.port = 9001;
|
|
+ link_specifier_set_ls_type(ls_legacy, LS_LEGACY_ID);
|
|
- int family = tor_addr_parse(&ls_v4->u.ap.addr, addr);
|
|
+ memcpy(link_specifier_getarray_un_legacy_id(ls_legacy),
|
|
|
|
+
|
|
|
|
+ "0299F268FCA9D55CD157976D39AE92B4B455B3A8",
|
|
|
|
+ link_specifier_getlen_un_legacy_id(ls_legacy));
|
|
|
|
+ int family = tor_addr_parse(&a, addr);
|
|
switch (family) {
|
|
switch (family) {
|
|
case AF_INET:
|
|
case AF_INET:
|
|
- ls_v4->type = LS_IPV4;
|
|
+ link_specifier_set_ls_type(ls_v4, LS_IPV4);
|
|
|
|
+ link_specifier_set_un_ipv4_addr(ls_v4, tor_addr_to_ipv4h(&a));
|
|
|
|
+ link_specifier_set_un_ipv4_port(ls_v4, 9001);
|
|
break;
|
|
break;
|
|
case AF_INET6:
|
|
case AF_INET6:
|
|
- ls_v4->type = LS_IPV6;
|
|
+ link_specifier_set_ls_type(ls_v4, LS_IPV6);
|
|
|
|
+ memcpy(link_specifier_getarray_un_ipv6_addr(ls_v4),
|
|
|
|
+ tor_addr_to_in6_addr8(&a),
|
|
|
|
+ link_specifier_getlen_un_ipv6_addr(ls_v4));
|
|
|
|
+ link_specifier_set_un_ipv6_port(ls_v4, 9001);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
|
|
|
|
|
|
+
|
|
tt_int_op(family, OP_EQ, AF_INET);
|
|
tt_int_op(family, OP_EQ, AF_INET);
|
|
}
|
|
}
|
|
smartlist_add(ip->link_specifiers, ls_legacy);
|
|
smartlist_add(ip->link_specifiers, ls_legacy);
|
|
@@ -153,8 +164,11 @@ hs_helper_build_hs_desc_impl(unsigned int no_ip,
|
|
|
|
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
hs_helper_build_intro_point(signing_kp, now, "1.2.3.4", 0));
|
|
hs_helper_build_intro_point(signing_kp, now, "1.2.3.4", 0));
|
|
|
|
+
|
|
|
|
+#if 0
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
hs_helper_build_intro_point(signing_kp, now, "[2600::1]", 0));
|
|
hs_helper_build_intro_point(signing_kp, now, "[2600::1]", 0));
|
|
|
|
+#endif
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
hs_helper_build_intro_point(signing_kp, now, "3.2.1.4", 1));
|
|
hs_helper_build_intro_point(signing_kp, now, "3.2.1.4", 1));
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
smartlist_add(desc->encrypted_data.intro_points,
|
|
@@ -202,7 +216,6 @@ void
|
|
hs_helper_desc_equal(const hs_descriptor_t *desc1,
|
|
hs_helper_desc_equal(const hs_descriptor_t *desc1,
|
|
const hs_descriptor_t *desc2)
|
|
const hs_descriptor_t *desc2)
|
|
{
|
|
{
|
|
- char *addr1 = NULL, *addr2 = NULL;
|
|
|
|
|
|
|
|
tt_int_op(desc1->plaintext_data.version, OP_EQ,
|
|
tt_int_op(desc1->plaintext_data.version, OP_EQ,
|
|
desc2->plaintext_data.version);
|
|
desc2->plaintext_data.version);
|
|
@@ -291,35 +304,57 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1,
|
|
tt_int_op(smartlist_len(ip1->link_specifiers), ==,
|
|
tt_int_op(smartlist_len(ip1->link_specifiers), ==,
|
|
smartlist_len(ip2->link_specifiers));
|
|
smartlist_len(ip2->link_specifiers));
|
|
for (int j = 0; j < smartlist_len(ip1->link_specifiers); j++) {
|
|
for (int j = 0; j < smartlist_len(ip1->link_specifiers); j++) {
|
|
- hs_desc_link_specifier_t *ls1 = smartlist_get(ip1->link_specifiers, j),
|
|
+ link_specifier_t *ls1 = smartlist_get(ip1->link_specifiers, j),
|
|
- *ls2 = smartlist_get(ip2->link_specifiers, j);
|
|
+ *ls2 = smartlist_get(ip2->link_specifiers, j);
|
|
- tt_int_op(ls1->type, ==, ls2->type);
|
|
+ tt_int_op(link_specifier_get_ls_type(ls1), ==,
|
|
- switch (ls1->type) {
|
|
+ link_specifier_get_ls_type(ls2));
|
|
|
|
+ switch (link_specifier_get_ls_type(ls1)) {
|
|
case LS_IPV4:
|
|
case LS_IPV4:
|
|
|
|
+ {
|
|
|
|
+ uint32_t addr1 = link_specifier_get_un_ipv4_addr(ls1);
|
|
|
|
+ uint32_t addr2 = link_specifier_get_un_ipv4_addr(ls2);
|
|
|
|
+ tt_int_op(addr1, OP_EQ, addr2);
|
|
|
|
+ uint16_t port1 = link_specifier_get_un_ipv4_port(ls1);
|
|
|
|
+ uint16_t port2 = link_specifier_get_un_ipv4_port(ls2);
|
|
|
|
+ tt_int_op(port1, ==, port2);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
case LS_IPV6:
|
|
case LS_IPV6:
|
|
{
|
|
{
|
|
- addr1 = tor_addr_to_str_dup(&ls1->u.ap.addr);
|
|
+ const uint8_t *addr1 =
|
|
- addr2 = tor_addr_to_str_dup(&ls2->u.ap.addr);
|
|
+ link_specifier_getconstarray_un_ipv6_addr(ls1);
|
|
- tt_str_op(addr1, OP_EQ, addr2);
|
|
+ const uint8_t *addr2 =
|
|
- tor_free(addr1);
|
|
+ link_specifier_getconstarray_un_ipv6_addr(ls2);
|
|
- tor_free(addr2);
|
|
+ tt_int_op(link_specifier_getlen_un_ipv6_addr(ls1), OP_EQ,
|
|
- tt_int_op(ls1->u.ap.port, ==, ls2->u.ap.port);
|
|
+ link_specifier_getlen_un_ipv6_addr(ls2));
|
|
|
|
+ tt_mem_op(addr1, OP_EQ, addr2,
|
|
|
|
+ link_specifier_getlen_un_ipv6_addr(ls1));
|
|
|
|
+ uint16_t port1 = link_specifier_get_un_ipv6_port(ls1);
|
|
|
|
+ uint16_t port2 = link_specifier_get_un_ipv6_port(ls2);
|
|
|
|
+ tt_int_op(port1, ==, port2);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case LS_LEGACY_ID:
|
|
case LS_LEGACY_ID:
|
|
- tt_mem_op(ls1->u.legacy_id, OP_EQ, ls2->u.legacy_id,
|
|
+ {
|
|
- sizeof(ls1->u.legacy_id));
|
|
+ const uint8_t *id1 =
|
|
|
|
+ link_specifier_getconstarray_un_legacy_id(ls1);
|
|
|
|
+ const uint8_t *id2 =
|
|
|
|
+ link_specifier_getconstarray_un_legacy_id(ls2);
|
|
|
|
+ tt_int_op(link_specifier_getlen_un_legacy_id(ls1), OP_EQ,
|
|
|
|
+ link_specifier_getlen_un_legacy_id(ls2));
|
|
|
|
+ tt_mem_op(id1, OP_EQ, id2,
|
|
|
|
+ link_specifier_getlen_un_legacy_id(ls1));
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
|
|
|
|
- tt_int_op(ls1->type, OP_EQ, -1);
|
|
+ tt_int_op(link_specifier_get_ls_type(ls1), OP_EQ, -1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
done:
|
|
done:
|
|
- tor_free(addr1);
|
|
+ ;
|
|
- tor_free(addr2);
|
|
|
|
}
|
|
}
|
|
|
|
|