summaryrefslogtreecommitdiff
path: root/src/feature/control/control_hs.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-06-03 15:43:54 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2019-11-18 19:18:49 +0200
commit8330b4dc2a18befa0eda8e48abb7f6e151596562 (patch)
treec9310b17d5755ccd34a5120f3d3d26df430fd982 /src/feature/control/control_hs.c
parent46f441502227665c25aa0ad8710bdf8487193904 (diff)
downloadtor-8330b4dc2a18befa0eda8e48abb7f6e151596562.tar.gz
tor-8330b4dc2a18befa0eda8e48abb7f6e151596562.zip
control-port: Implement ONION_CLIENT_AUTH_REMOVE.
Diffstat (limited to 'src/feature/control/control_hs.c')
-rw-r--r--src/feature/control/control_hs.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/feature/control/control_hs.c b/src/feature/control/control_hs.c
index 5db8a0f007..93e66261e0 100644
--- a/src/feature/control/control_hs.c
+++ b/src/feature/control/control_hs.c
@@ -159,3 +159,53 @@ handle_control_onion_client_auth_add(control_connection_t *conn,
smartlist_free(flags);
return retval;
}
+
+/** Syntax details for ONION_CLIENT_AUTH_REMOVE */
+const control_cmd_syntax_t onion_client_auth_remove_syntax = {
+ .max_args = 1,
+ .accept_keywords = true,
+};
+
+/** Called when we get an ONION_CLIENT_AUTH_REMOVE command; parse the body, and
+ * register the new client-side client auth credentials.
+ * "ONION_CLIENT_AUTH_REMOVE" SP HSAddress
+ */
+int
+handle_control_onion_client_auth_remove(control_connection_t *conn,
+ const control_cmd_args_t *args)
+{
+ int retval = -1;
+
+ tor_assert(args);
+
+ int argc = smartlist_len(args->args);
+ if (argc < 1) {
+ control_printf_endreply(conn, 512,
+ "Incomplete ONION_CLIENT_AUTH_REMOVE command");
+ goto err;
+ }
+
+ const char *hsaddress = smartlist_get(args->args, 0);
+ if (!hs_address_is_valid(hsaddress)) {
+ control_printf_endreply(conn, 512, "Invalid v3 address \"%s\"",hsaddress);
+ goto err;
+ }
+
+ hs_client_removal_auth_status_t removal_status;
+ removal_status = hs_client_remove_auth_credentials(hsaddress);
+ if (BUG(removal_status == REMOVAL_BAD_ADDRESS)) {
+ /* It's a bug because the service addr has already been validated above */
+ control_printf_endreply(conn, 512, "Invalid v3 address \"%s\"",hsaddress);
+ } else if (removal_status == REMOVAL_SUCCESS_NOT_FOUND) {
+ control_printf_endreply(conn, 251, "No credentials for \"%s\"",hsaddress);
+ } else if (removal_status == REMOVAL_SUCCESS) {
+ control_printf_endreply(conn, 250, "OK");
+ } else {
+ tor_assert_nonfatal_unreached();
+ }
+
+ retval = 0;
+
+ err:
+ return retval;
+}