Commit dcf8b182 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

when the hidden service launches a rendezvous circ, make sure it

provides good uptime if any virtual_port of the service wants that.


svn:r3355
parent a38bccdc
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -342,6 +342,22 @@ rend_service_get_by_pk_digest(const char* digest)
  return NULL;
}

/** Return 1 if any virtual port in <b>service</b> wants a circuit
 * to have good uptime. Else return 0.
 */
static int
rend_service_requires_uptime(rend_service_t *service) {
  int i;
  rend_service_port_config_t *p;

  for (i=0; i < smartlist_len(service->ports); ++i) {
    p = smartlist_get(service->ports, i);
    if (smartlist_string_num_isin(get_options()->LongLivedPorts, p->virtual_port))
      return 1;
  }
  return 0;
}

/******
 * Handle cells
 ******/
@@ -458,7 +474,8 @@ rend_service_introduce(circuit_t *circuit, const char *request, size_t request_l
  /* Launch a circuit to alice's chosen rendezvous point.
   */
  for (i=0;i<MAX_REND_FAILURES;i++) {
    launched = circuit_launch_by_nickname(CIRCUIT_PURPOSE_S_CONNECT_REND, rp_nickname, 0, 1);
    launched = circuit_launch_by_nickname(CIRCUIT_PURPOSE_S_CONNECT_REND, rp_nickname,
                                           rend_service_requires_uptime(service), 1);
    if (launched)
      break;
  }