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
This commit is contained in:
Nick Mathewson 2007-03-04 21:08:28 +00:00
parent 4a6e29b029
commit 92f62b3684
6 changed files with 186 additions and 955 deletions

View File

@ -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):

View File

@ -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:

View File

@ -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

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -341,18 +341,12 @@ typedef enum {
#define DIR_CONN_IS_SERVER(conn) ((conn)->purpose == DIR_PURPOSE_SERVER)
#define _CONTROL_CONN_STATE_MIN 1
/** State for a control connection: Authenticated and accepting v0 commands. */
#define CONTROL_CONN_STATE_OPEN_V0 1
/** State for a control connection: Authenticated and accepting v1 commands. */
#define CONTROL_CONN_STATE_OPEN_V1 2
/** State for a control connection: Waiting for authentication; either
* speaking v0 commands or waiting for evidence that it's a v1
* connection. */
#define CONTROL_CONN_STATE_NEEDAUTH_V0 3
#define CONTROL_CONN_STATE_OPEN 1
/** State for a control connection: Waiting for authentication; speaking
* protocol v1. */
#define CONTROL_CONN_STATE_NEEDAUTH_V1 4
#define _CONTROL_CONN_STATE_MAX 4
#define CONTROL_CONN_STATE_NEEDAUTH 2
#define _CONTROL_CONN_STATE_MAX 2
#define _DIR_PURPOSE_MIN 1
/** A connection to a directory server: download a directory. */
@ -1929,11 +1923,11 @@ int fetch_from_buf_http(buf_t *buf,
int force_complete);
int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
int log_sockstype, int safe_socks);
int fetch_from_buf_control0(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
char **body_out, int check_for_v1);
int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
int fetch_from_buf_line_lf(buf_t *buf, char *data_out, size_t *data_len);
int peek_buf_has_control0_command(buf_t *buf);
void assert_buf_ok(buf_t *buf);
/********************************* circuitbuild.c **********************/