diff options
author | Neel Chauhan <neel@neelc.org> | 2019-01-14 14:09:53 -0500 |
---|---|---|
committer | Neel Chauhan <neel@neelc.org> | 2019-01-24 10:22:41 -0500 |
commit | c985940de9ec743cbb3e9a3e32fd482bd859c9ed (patch) | |
tree | ada77d45ae70210a34c9761b36bd5e539dd2a2f9 /src/feature/control | |
parent | cef910642efb1f9a2db16146eb8a191327b51310 (diff) | |
download | tor-c985940de9ec743cbb3e9a3e32fd482bd859c9ed.tar.gz tor-c985940de9ec743cbb3e9a3e32fd482bd859c9ed.zip |
Add version 3 onion service support to HSFETCH
Diffstat (limited to 'src/feature/control')
-rw-r--r-- | src/feature/control/control.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/feature/control/control.c b/src/feature/control/control.c index 170037e060..d7299a4cf6 100644 --- a/src/feature/control/control.c +++ b/src/feature/control/control.c @@ -4426,6 +4426,8 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len, static const char *v2_str = "v2-"; const size_t v2_str_len = strlen(v2_str); rend_data_t *rend_query = NULL; + ed25519_public_key_t v3_pk; + uint32_t version; /* Make sure we have at least one argument, the HSAddress. */ args = getargs_helper(hsfetch_command, conn, body, 1, -1); @@ -4438,6 +4440,7 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len, /* Test if it's an HS address without the .onion part. */ if (rend_valid_v2_service_id(arg1)) { hsaddress = arg1; + version = HS_VERSION_TWO; } else if (strcmpstart(arg1, v2_str) == 0 && rend_valid_descriptor_id(arg1 + v2_str_len) && base32_decode(digest, sizeof(digest), arg1 + v2_str_len, @@ -4445,6 +4448,11 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len, /* We have a well formed version 2 descriptor ID. Keep the decoded value * of the id. */ desc_id = digest; + version = HS_VERSION_TWO; + } else if (hs_address_is_valid(arg1)) { + hsaddress = arg1; + version = HS_VERSION_THREE; + hs_parse_address(hsaddress, &v3_pk, NULL, NULL); } else { connection_printf_to_buf(conn, "513 Invalid argument \"%s\"\r\n", arg1); @@ -4481,11 +4489,13 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len, } } - rend_query = rend_data_client_create(hsaddress, desc_id, NULL, - REND_NO_AUTH); - if (rend_query == NULL) { - connection_printf_to_buf(conn, "551 Error creating the HS query\r\n"); - goto done; + if (version == HS_VERSION_TWO) { + rend_query = rend_data_client_create(hsaddress, desc_id, NULL, + REND_NO_AUTH); + if (rend_query == NULL) { + connection_printf_to_buf(conn, "551 Error creating the HS query\r\n"); + goto done; + } } /* Using a descriptor ID, we force the user to provide at least one @@ -4504,7 +4514,11 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len, /* Trigger the fetch using the built rend query and possibly a list of HS * directory to use. This function ignores the client cache thus this will * always send a fetch command. */ - rend_client_fetch_v2_desc(rend_query, hsdirs); + if (version == HS_VERSION_TWO) { + rend_client_fetch_v2_desc(rend_query, hsdirs); + } else if (version == HS_VERSION_THREE) { + hs_control_hsfetch_command(&v3_pk, hsdirs); + } done: SMARTLIST_FOREACH(args, char *, cp, tor_free(cp)); |