Commit 28fafb90 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

new config option SocksTimeout: How long do we let a socks connection

wait unattached before we fail it?

Use this value for controller socks timeout, for normal socks
timeout, and for hidden-service socks timeout.


svn:r6217
parent 5399e394
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -13,9 +13,6 @@ const char circuituse_c_id[] =

#include "or.h"

/** Longest time to wait for a circuit before closing an AP connection */
#define CONN_AP_MAX_ATTACH_DELAY 59

/********* START VARIABLES **********/

extern circuit_t *global_circuitlist; /* from circuitlist.c */
@@ -1154,7 +1151,7 @@ connection_ap_handshake_attach_circuit(connection_t *conn)
  tor_assert(conn->socks_request);

  conn_age = time(NULL) - conn->timestamp_created;
  if (conn_age > CONN_AP_MAX_ATTACH_DELAY) {
  if (conn_age > get_options()->SocksTimeout) {
    log_notice(LD_APP,
               "Tried for %d seconds to get a connection to %s:%d. Giving up.",
               conn_age, safe_str(conn->socks_request->address),
+1 −0
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ static config_var_t _option_vars[] = {
  VAR("SocksListenAddress",  LINELIST, SocksListenAddress,   NULL),
  VAR("SocksPolicy",         LINELIST, SocksPolicy,          NULL),
  VAR("SocksPort",           UINT,     SocksPort,            "9050"),
  VAR("SocksTimeout",        INTERVAL, SocksTimeout,         "2 minutes"),
  /* if StatusFetchPeriod is 0, see get_status_fetch_period() in main.c */
  VAR("StatusFetchPeriod",   INTERVAL, StatusFetchPeriod,    "0 seconds"),
  VAR("StrictEntryNodes",    BOOL,     StrictEntryNodes,     "0"),
+3 −3
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ connection_edge_finished_connecting(connection_t *conn)
 * connection_ap_handshake_attach_circuit() to attach to a new circuit (if
 * available) or launch a new one.
 *
 * For rendezvous streams, simply give up after 45 seconds (with no
 * For rendezvous streams, simply give up after SocksTimeout seconds (with no
 * retry attempt).
 */
void
@@ -335,7 +335,7 @@ connection_ap_expire_beginning(void)
    if (conn->type != CONN_TYPE_AP)
      continue;
    if (conn->state == AP_CONN_STATE_CONTROLLER_WAIT) {
      if (now - conn->timestamp_lastread >= 120) {
      if (now - conn->timestamp_lastread >= options->SocksTimeout) {
        log_notice(LD_APP, "Closing unattached stream.");
        connection_mark_unattached_ap(conn, END_STREAM_REASON_TIMEOUT);
      }
@@ -355,7 +355,7 @@ connection_ap_expire_beginning(void)
      continue;
    }
    if (circ->purpose == CIRCUIT_PURPOSE_C_REND_JOINED) {
      if (now - conn->timestamp_lastread > 45) {
      if (now - conn->timestamp_lastread > options->SocksTimeout) {
        log_notice(LD_REND,
                   "Rend stream is %d seconds late. Giving up on address"
                   " '%s.onion'.",
+2 −0
Original line number Diff line number Diff line
@@ -1315,6 +1315,8 @@ typedef struct {
  int StatusFetchPeriod; /**< How often do we fetch running-routers lists? */
  int KeepalivePeriod; /**< How often do we send padding cells to keep
                        * connections alive? */
  int SocksTimeout; /**< How long do we let a socks connection wait
                     * unattached before we fail it? */
  int MaxOnionsPending; /**< How many circuit CREATE requests do we allow
                         * to wait simultaneously before we start dropping
                         * them? */