[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Add a "quit" command for the controller.
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
control.c dirserv.c or.h
Log Message:
Add a 'quit' command for the controller.
Add a 'getinfo unregistered-servers' for arma's internal use.
Index: control.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- control.c 12 Aug 2005 17:24:53 -0000 1.118
+++ control.c 13 Aug 2005 01:55:23 -0000 1.119
@@ -75,7 +75,8 @@
#define _EVENT_MAX 0x000C
/** Array mapping from message type codes to human-readable message
- * type names. */
+ * type names. Used for compatibility with version 0 of the control
+ * protocol. */
static const char * CONTROL0_COMMANDS[_CONTROL0_CMD_MAX_RECOGNIZED+1] = {
"error",
"done",
@@ -1172,6 +1173,8 @@
routerinfo_t *ri = router_get_by_nickname(question+strlen("desc/name/"));
if (ri && ri->signed_descriptor)
*answer = tor_strdup(ri->signed_descriptor);
+ } else if (!strcmp(question, "unregistered-servers")) {
+ *answer = dirserver_getinfo_unregistered();
} else if (!strcmp(question, "network-status")) {
routerlist_t *routerlist;
router_get_routerlist(&routerlist);
@@ -1309,7 +1312,7 @@
smartlist_t *questions = NULL;
smartlist_t *answers = NULL;
smartlist_t *unrecognized = NULL;
- char *msg = NULL, *ans;
+ char *msg = NULL, *ans = NULL;
size_t msg_len;
int v0 = STATE_IS_V0(conn->state);
@@ -1964,6 +1967,12 @@
log_fn(LOG_NOTICE, "ARGS ARE: <%s>", args);
*/
+ if (!strcasecmp(conn->incoming_cmd, "QUIT")) {
+ connection_write_str_to_buf("250 closing connection\r\n", conn);
+ connection_mark_for_close(conn);
+ return 0;
+ }
+
if (conn->state == CONTROL_CONN_STATE_NEEDAUTH_V1 &&
strcasecmp(conn->incoming_cmd, "AUTHENTICATE")) {
connection_write_str_to_buf("514 Authentication required.\r\n", conn);
Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- dirserv.c 22 Jul 2005 21:12:10 -0000 1.173
+++ dirserv.c 13 Aug 2005 01:55:23 -0000 1.174
@@ -442,6 +442,41 @@
}
}
+/** Write a list of unregistered descriptors into a newly allocated
+ * string and return it. Used by dirserv operators to keep track of
+ * fast nodes that haven't registered.
+ */
+char *
+dirserver_getinfo_unregistered(void)
+{
+ int i, r;
+ smartlist_t *answerlist;
+ char buf[1024];
+ char *answer;
+ routerinfo_t *ent;
+
+ if (!descriptor_list)
+ return tor_strdup("");
+
+ answerlist = smartlist_create();
+ for (i = 0; i < smartlist_len(descriptor_list); ++i) {
+ ent = smartlist_get(descriptor_list, i);
+ r = dirserv_router_fingerprint_is_known(ent);
+ if (ent->bandwidthcapacity > 100000 && r == 0) {
+ /* then log this one */
+ tor_snprintf(buf, sizeof(buf),
+ "%s: BW %d on '%s'.",
+ ent->nickname, ent->bandwidthcapacity,
+ ent->platform ? ent->platform : "");
+ smartlist_add(answerlist, tor_strdup(buf));
+ }
+ }
+ answer = smartlist_join_strings(answerlist, "\r\n", 0, NULL);
+ SMARTLIST_FOREACH(answerlist, char *, cp, tor_free(cp));
+ smartlist_free(answerlist);
+ return answer;
+}
+
/** Mark the directory as <b>dirty</b> -- when we're next asked for a
* directory, we will rebuild it instead of reusing the most recently
* generated one.
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.641
retrieving revision 1.642
diff -u -d -r1.641 -r1.642
--- or.h 13 Aug 2005 00:22:06 -0000 1.641
+++ or.h 13 Aug 2005 01:55:23 -0000 1.642
@@ -1621,6 +1621,7 @@
void dirserv_free_fingerprint_list(void);
const char *dirserv_get_nickname_by_digest(const char *digest);
int dirserv_add_descriptor(const char **desc, const char **msg);
+char *dirserver_getinfo_unregistered(void);
int dirserv_load_from_directory_string(const char *dir);
void dirserv_free_descriptors(void);
int list_server_status(smartlist_t *routers, char **router_status_out);