Commit 92f62b36 authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

r12077@catbus: nickm | 2007-03-04 16:08:23 -0500

 Remove support for v0 control protocol from 0.2.0.x trunk; send back error when we receive a v0 control message.  (Leave "if(v1){...}"blocks indented for now so this patch is easier to read.)  ((Finally, the linecount goes _down_ a little.))


svn:r9735
parent 4a6e29b0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -6,6 +6,12 @@ Changes in version 0.2.0.1-alpha - 2007-??-??
  o Minor features (logging):
    - Always prepend "Bug: " to any log message about a bug.

  o Removed features:
    - Removed support for the old binary "version 0" controller protocol.
      This has been deprecated since 0.1.1, and warnings have been issued
      since 0.1.2.  When we encounter a v0 control message, we now send back
      an error and close the connection.


Changes in version 0.1.2.10-rc - 2007-03-??
  o Major bugfixes (Windows):
+2 −2
Original line number Diff line number Diff line
@@ -139,8 +139,8 @@ Things we'd like to do in 0.2.0.x:
  - Blocking
    - It would be potentially helpful to https requests on the OR port by
      acting like an HTTPS server.
  - Deprecations:
    - Remove v0 control protocol.
  o Deprecations:
    o Remove v0 control protocol.


Deferred from 0.1.2.x:
+11 −45
Original line number Diff line number Diff line
@@ -1228,54 +1228,20 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
  }
}

/** If there is a complete version 0 control message waiting on buf, then store
 * its contents into *<b>type_out</b>, store its body's length into
 * *<b>len_out</b>, allocate and store a string for its body into
 * *<b>body_out</b>, and return 1.  (body_out will always be NUL-terminated,
 * even if the control message body doesn't end with NUL.)
 *
 * If there is not a complete control message waiting, return 0.
 *
 * Return -1 on error; return -2 on "seems to be control protocol v1."
 */
/** Return 1 iff buf looks more like it has an (obsolete) v0 controller
 * command on it than any valid v1 controller command. */
int
fetch_from_buf_control0(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
                        char **body_out, int check_for_v1)
peek_buf_has_control0_command(buf_t *buf)
{
  uint32_t msglen;
  uint16_t type;
  char tmp[4];

  tor_assert(buf);
  tor_assert(len_out);
  tor_assert(type_out);
  tor_assert(body_out);

  *len_out = 0;
  *body_out = NULL;

  if (buf->datalen < 4)
    return 0;

  peek_from_buf(tmp, 4, buf);

  msglen = ntohs(get_uint16(tmp));
  type = ntohs(get_uint16(tmp+2));
  if (type > 255 && check_for_v1)
    return -2;

  if (buf->datalen < 4 + (unsigned)msglen)
    return 0;

  *len_out = msglen;
  *type_out = type;
  buf_remove_from_front(buf, 4);
  if (msglen) {
    *body_out = tor_malloc(msglen+1);
    fetch_from_buf(*body_out, msglen, buf);
    (*body_out)[msglen] = '\0';
  if (buf->datalen >= 4) {
    char header[4];
    uint16_t cmd;
    peek_from_buf(header, sizeof(header), buf);
    cmd = ntohs(get_uint16(header+2));
    if (cmd <= 0x14)
      return 1; /* This is definitely not a v1 control command. */
  }
  return 1;
  return 0;
}

/** Helper: return a pointer to the first instance of <b>c</b> in the
+4 −8
Original line number Diff line number Diff line
@@ -132,11 +132,8 @@ conn_state_to_string(int type, int state)
      break;
    case CONN_TYPE_CONTROL:
      switch (state) {
        case CONTROL_CONN_STATE_OPEN_V0: return "open (protocol v0)";
        case CONTROL_CONN_STATE_OPEN_V1: return "open (protocol v1)";
        case CONTROL_CONN_STATE_NEEDAUTH_V0:
          return "waiting for authentication (protocol unknown)";
        case CONTROL_CONN_STATE_NEEDAUTH_V1:
        case CONTROL_CONN_STATE_OPEN: return "open (protocol v1)";
        case CONTROL_CONN_STATE_NEEDAUTH:
          return "waiting for authentication (protocol v1)";
      }
      break;
@@ -860,7 +857,7 @@ connection_init_accepted_conn(connection_t *conn, uint8_t listener_type)
      conn->state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
      break;
    case CONN_TYPE_CONTROL:
      conn->state = CONTROL_CONN_STATE_NEEDAUTH_V0;
      conn->state = CONTROL_CONN_STATE_NEEDAUTH;
      break;
  }
  return 0;
@@ -2121,8 +2118,7 @@ connection_state_is_open(connection_t *conn)
      (conn->type == CONN_TYPE_AP && conn->state == AP_CONN_STATE_OPEN) ||
      (conn->type == CONN_TYPE_EXIT && conn->state == EXIT_CONN_STATE_OPEN) ||
      (conn->type == CONN_TYPE_CONTROL &&
       (conn->state == CONTROL_CONN_STATE_OPEN_V0 ||
        conn->state == CONTROL_CONN_STATE_OPEN_V1)))
       conn->state == CONTROL_CONN_STATE_OPEN))
    return 1;

  return 0;
+160 −891

File changed.

Preview size limit exceeded, changes collapsed.

Loading