Skip to content

Commit

Permalink
Final touches to #32709 based on Nick's feedback.
Browse files Browse the repository at this point in the history
- Fix a bug and add unittest.
- Add changes file.
- Add man page entry.
  • Loading branch information
asn-d6 committed Feb 24, 2020
1 parent 9751028 commit 93cb807
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
4 changes: 4 additions & 0 deletions changes/bug32709
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
o Major features (v3 onion services):
- Allow v3 onion services to act as OnionBalance backend instances using
the HiddenServiceOnionBalanceInstance torrc option. Closes ticket 32709.

13 changes: 13 additions & 0 deletions doc/tor.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3128,6 +3128,19 @@ The next section describes the per service options that can only be set
The HAProxy version 1 protocol is described in detail at
https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt

[[HiddenServiceOnionBalanceInstance]] **HiddenServiceOnionBalanceInstance** **0**|**1**::

If set to 1, this onion service becomes an OnionBalance instance and will
accept client connections destined to an OnionBalance frontend. In this
case, Tor expects to find a file named "ob_config" inside the
**HiddenServiceDir** directory with content:
+
MasterOnionAddress <frontend_onion_address>
+
where <frontend_onion_address> is the onion address of the OnionBalance
frontend (e.g. wrxdvcaqpuzakbfww5sxs6r2uybczwijzfn2ezy2osaj7iox7kl7nhad.onion).


[[HiddenServiceMaxStreams]] **HiddenServiceMaxStreams** __N__::
The maximum number of simultaneous streams (connections) per rendezvous
circuit. The maximum value allowed is 65535. (Setting this to 0 will allow
Expand Down
4 changes: 2 additions & 2 deletions src/feature/hs/hs_ob.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ compute_subcredentials(const hs_service_t *service,
tor_assert(service->desc_current);
tor_assert(service->desc_next);

/* Our caller made sure that we are an OB instance */
/* Make sure we are an OB instance, or bail out. */
num_pkeys = smartlist_len(service->config.ob_master_pubkeys);
if (!num_pkeys) {
subcredentials_out = NULL;
*subcredentials_out = NULL;
return 0;
}

Expand Down
22 changes: 16 additions & 6 deletions src/test/test_hs_ob.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ test_get_subcredentials(void *arg)
int ret;
hs_service_t *service = NULL;
hs_service_config_t config;
hs_subcredential_t *subcreds = NULL;

(void) arg;

Expand All @@ -188,16 +189,24 @@ test_get_subcredentials(void *arg)
config.ob_master_pubkeys = smartlist_new();
tt_assert(config.ob_master_pubkeys);

/* Generate a keypair to add to the list. */
ed25519_keypair_generate(&onion_addr_kp_1, 0);
smartlist_add(config.ob_master_pubkeys, &onion_addr_kp_1.pubkey);

/* Set up an instance */
service = tor_malloc_zero(sizeof(hs_service_t));
service->config = config;
/* Setup the service descriptors */
service->desc_current = service_descriptor_new();
service->desc_next = service_descriptor_new();

/* First try to compute subcredentials but with no OB keys. Make sure that
* subcreds get NULLed. To do this check we first poison subcreds. */
subcreds = (void*)999;
tt_ptr_op(subcreds, OP_NE, NULL);
size_t num = compute_subcredentials(service, &subcreds);
tt_ptr_op(subcreds, OP_EQ, NULL);

/* Generate a keypair to add to the OB keys list. */
ed25519_keypair_generate(&onion_addr_kp_1, 0);
smartlist_add(config.ob_master_pubkeys, &onion_addr_kp_1.pubkey);

/* Set up the instance subcredentials */
char current_subcred[SUBCRED_LEN];
char next_subcred[SUBCRED_LEN];
Expand All @@ -208,10 +217,11 @@ test_get_subcredentials(void *arg)
memcpy(service->desc_next->desc->subcredential.subcred, next_subcred,
SUBCRED_LEN);

hs_subcredential_t *subcreds = NULL;
size_t num = compute_subcredentials(service, &subcreds);
/* See that subcreds are computed properly */
num = compute_subcredentials(service, &subcreds);
/* 5 subcredentials: 3 for the frontend, 2 for the instance */
tt_uint_op(num, OP_EQ, 5);
tt_ptr_op(subcreds, OP_NE, NULL);

/* Validate the subcredentials we just got. We'll build them oursevles with
* the right time period steps and compare. */
Expand Down

0 comments on commit 93cb807

Please sign in to comment.