mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
r13102@catbus: nickm | 2007-05-31 13:56:25 -0400
Make "authdir_newdesc rejected" work again. svn:r10421
This commit is contained in:
parent
4061b2cbd1
commit
77502ac82d
@ -35,7 +35,7 @@ const char control_c_id[] =
|
||||
#define EVENT_WARN_MSG 0x000A
|
||||
#define EVENT_ERR_MSG 0x000B
|
||||
#define EVENT_ADDRMAP 0x000C
|
||||
#define EVENT_AUTHDIR_NEWDESCS 0x000D
|
||||
// #define EVENT_AUTHDIR_NEWDESCS 0x000D
|
||||
#define EVENT_DESCCHANGED 0x000E
|
||||
#define EVENT_NS 0x000F
|
||||
#define EVENT_STATUS_CLIENT 0x0010
|
||||
@ -248,6 +248,16 @@ control_adjust_event_log_severity(void)
|
||||
control_event_logmsg);
|
||||
}
|
||||
|
||||
/** Return true iff the event with code <b>c</b> is being sent to any current
|
||||
* control connection. This is useful if the amount of work needed to prepare
|
||||
* to call the appropriate control_event_...() function is high.
|
||||
*/
|
||||
int
|
||||
control_event_is_interesting(int event)
|
||||
{
|
||||
return EVENT_IS_INTERESTING(event);
|
||||
}
|
||||
|
||||
/** Append a NUL-terminated string <b>s</b> to the end of
|
||||
* <b>conn</b>-\>outbuf
|
||||
*/
|
||||
@ -3032,7 +3042,7 @@ control_event_address_mapped(const char *from, const char *to, time_t expires)
|
||||
* been done with it, and also optionally give an explanation/reason. */
|
||||
int
|
||||
control_event_or_authdir_new_descriptor(const char *action,
|
||||
signed_descriptor_t *desc,
|
||||
const char *desc, size_t desclen,
|
||||
const char *msg)
|
||||
{
|
||||
char firstline[1024];
|
||||
@ -3050,8 +3060,7 @@ control_event_or_authdir_new_descriptor(const char *action,
|
||||
msg ? msg : "");
|
||||
|
||||
/* Escape the server descriptor properly */
|
||||
esclen = write_escaped_data(desc->signed_descriptor_body,
|
||||
desc->signed_descriptor_len, 1, &esc);
|
||||
esclen = write_escaped_data(desc, desclen, 1, &esc);
|
||||
|
||||
totallen = strlen(firstline) + esclen + 1;
|
||||
buf = tor_malloc(totallen);
|
||||
|
@ -581,7 +581,8 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg)
|
||||
{
|
||||
int r;
|
||||
routerinfo_t *ri_old;
|
||||
signed_descriptor_t *desc = &ri->cache_info;
|
||||
char *desc = NULL;
|
||||
size_t desclen = 0;
|
||||
|
||||
/* Check whether this descriptor is semantically identical to the last one
|
||||
* from this server. (We do this here and not in router_add_to_routerlist
|
||||
@ -596,23 +597,27 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg)
|
||||
ri->nickname);
|
||||
*msg = "Not replacing router descriptor; no information has changed since "
|
||||
"the last one with this identity.";
|
||||
control_event_or_authdir_new_descriptor("DROPPED", desc, *msg);
|
||||
control_event_or_authdir_new_descriptor("DROPPED",
|
||||
ri->cache_info.signed_descriptor_body,
|
||||
ri->cache_info.signed_descriptor_len, *msg);
|
||||
routerinfo_free(ri);
|
||||
return 0;
|
||||
}
|
||||
if (control_event_is_interesting(EVENT_AUTHDIR_NEWDESCS)) {
|
||||
/* Make a copy of desc, since router_add_to_routerlist might free
|
||||
* ri and its associated signed_descriptor_t. */
|
||||
desclen = ri->cache_info.signed_descriptor_len;
|
||||
desc = tor_strndup(ri->cache_info.signed_descriptor_body, desclen);
|
||||
}
|
||||
|
||||
if ((r = router_add_to_routerlist(ri, msg, 0, 0))<0) {
|
||||
#if 0
|
||||
/* XXXX020 reinstate this code, but remember that it can't actually
|
||||
work, since it is NOT kosher to look at ri or desc after
|
||||
add_to_routerlist, _unless_ the descriptor is accepted.
|
||||
*/
|
||||
if (r < -1) /* unless the routerinfo was fine, just out-of-date */
|
||||
control_event_or_authdir_new_descriptor("REJECTED", desc, *msg);
|
||||
#endif
|
||||
if (r < -1 && desc) /* unless the routerinfo was fine, just out-of-date */
|
||||
control_event_or_authdir_new_descriptor("REJECTED", desc, desclen, *msg);
|
||||
tor_free(desc);
|
||||
return r == -1 ? 0 : -1;
|
||||
} else {
|
||||
smartlist_t *changed;
|
||||
control_event_or_authdir_new_descriptor("ACCEPTED", desc, *msg);
|
||||
control_event_or_authdir_new_descriptor("ACCEPTED", desc, desclen, *msg);
|
||||
|
||||
changed = smartlist_create();
|
||||
smartlist_add(changed, ri);
|
||||
@ -622,6 +627,7 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg)
|
||||
*msg = ri->is_valid ? "Descriptor for valid server accepted" :
|
||||
"Descriptor for invalid server accepted";
|
||||
}
|
||||
tor_free(desc);
|
||||
return r == 0 ? 2 : 1;
|
||||
}
|
||||
}
|
||||
|
@ -2525,6 +2525,9 @@ int connection_control_finished_flushing(control_connection_t *conn);
|
||||
int connection_control_reached_eof(control_connection_t *conn);
|
||||
int connection_control_process_inbuf(control_connection_t *conn);
|
||||
|
||||
#define EVENT_AUTHDIR_NEWDESCS 0x000D
|
||||
int control_event_is_interesting(int event);
|
||||
|
||||
int control_event_circuit_status(origin_circuit_t *circ,
|
||||
circuit_status_event_t e, int reason);
|
||||
int control_event_stream_status(edge_connection_t *conn,
|
||||
@ -2540,7 +2543,8 @@ int control_event_descriptors_changed(smartlist_t *routers);
|
||||
int control_event_address_mapped(const char *from, const char *to,
|
||||
time_t expires);
|
||||
int control_event_or_authdir_new_descriptor(const char *action,
|
||||
signed_descriptor_t *desc,
|
||||
const char *desc,
|
||||
size_t desclen,
|
||||
const char *msg);
|
||||
int control_event_my_descriptor_changed(void);
|
||||
int control_event_networkstatus_changed(smartlist_t *statuses);
|
||||
|
Loading…
Reference in New Issue
Block a user