hs_control.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file hs_control.c
  5. * \brief Contains control port event related code.
  6. **/
  7. #include "or.h"
  8. #include "control.h"
  9. #include "hs_common.h"
  10. #include "hs_control.h"
  11. #include "nodelist.h"
  12. /* Send on the control port the "HS_DESC REQUESTED [...]" event.
  13. *
  14. * The onion_pk is the onion service public key, base64_blinded_pk is the
  15. * base64 encoded blinded key for the service and hsdir_rs is the routerstatus
  16. * object of the HSDir that this request is for. */
  17. void
  18. hs_control_desc_event_requested(const ed25519_public_key_t *onion_pk,
  19. const char *base64_blinded_pk,
  20. const routerstatus_t *hsdir_rs)
  21. {
  22. char onion_address[HS_SERVICE_ADDR_LEN_BASE32 + 1];
  23. const uint8_t *hsdir_index;
  24. const node_t *hsdir_node;
  25. tor_assert(onion_pk);
  26. tor_assert(base64_blinded_pk);
  27. tor_assert(hsdir_rs);
  28. hs_build_address(onion_pk, HS_VERSION_THREE, onion_address);
  29. /* Get the node from the routerstatus object to get the HSDir index used for
  30. * this request. We can't have a routerstatus entry without a node and we
  31. * can't pick a node without an hsdir_index. */
  32. hsdir_node = node_get_by_id(hsdir_rs->identity_digest);
  33. tor_assert(hsdir_node);
  34. tor_assert(hsdir_node->hsdir_index);
  35. /* This is a fetch event. */
  36. hsdir_index = hsdir_node->hsdir_index->fetch;
  37. /* Trigger the event. */
  38. control_event_hs_descriptor_requested(onion_address, REND_NO_AUTH,
  39. hsdir_rs->identity_digest,
  40. base64_blinded_pk,
  41. hex_str((const char *) hsdir_index,
  42. DIGEST256_LEN));
  43. memwipe(onion_address, 0, sizeof(onion_address));
  44. }