mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r11641@catbus: nickm | 2007-02-05 13:59:26 -0500
Add a REMAP state to stream events so that controllers can learn exactly when the target address for a stream has changed. May help Vidalia resolve confusions related to bug 375. svn:r9484
This commit is contained in:
@@ -97,7 +97,8 @@ Changes in version 0.1.2.7-alpha - 2007-??-??
|
||||
- Add a SOCKS_BAD_HOSTNAME client status event so controllers
|
||||
can learn when clients are sending malformed hostnames to Tor.
|
||||
- Clean up documentation for controller status events.
|
||||
|
||||
- Add a REMAP status to stream events to note that a stream's address has
|
||||
changed because of a cached address or a MapAddress directive.
|
||||
|
||||
Changes in version 0.1.2.6-alpha - 2007-01-09
|
||||
o Major bugfixes:
|
||||
|
||||
@@ -832,6 +832,7 @@ $Id$
|
||||
StreamStatus =
|
||||
"NEW" / ; New request to connect
|
||||
"NEWRESOLVE" / ; New request to resolve an address
|
||||
"REMAP" / ; Address re-mapped to another
|
||||
"SENTCONNECT" / ; Sent a connect cell along a circuit
|
||||
"SENTRESOLVE" / ; Sent a resolve cell along a circuit
|
||||
"SUCCEEDED" / ; Received a reply; stream established
|
||||
|
||||
@@ -682,9 +682,10 @@ addressmap_free_all(void)
|
||||
|
||||
/** Look at address, and rewrite it until it doesn't want any
|
||||
* more rewrites; but don't get into an infinite loop.
|
||||
* Don't write more than maxlen chars into address.
|
||||
* Don't write more than maxlen chars into address. Return true if the
|
||||
* address changed; false otherwise.
|
||||
*/
|
||||
void
|
||||
int
|
||||
addressmap_rewrite(char *address, size_t maxlen)
|
||||
{
|
||||
addressmap_entry_t *ent;
|
||||
@@ -695,7 +696,7 @@ addressmap_rewrite(char *address, size_t maxlen)
|
||||
ent = strmap_get(addressmap, address);
|
||||
|
||||
if (!ent || !ent->new_address)
|
||||
return; /* done, no rewrite needed */
|
||||
return (rewrites > 0); /* done, no rewrite needed */
|
||||
|
||||
cp = tor_strdup(escaped_safe_str(ent->new_address));
|
||||
log_info(LD_APP, "Addressmap: rewriting %s to %s",
|
||||
@@ -707,6 +708,7 @@ addressmap_rewrite(char *address, size_t maxlen)
|
||||
"Loop detected: we've rewritten %s 16 times! Using it as-is.",
|
||||
escaped_safe_str(address));
|
||||
/* it's fine to rewrite a rewrite, but don't loop forever */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** If we have a cached reverse DNS entry for the address stored in the
|
||||
@@ -1216,7 +1218,9 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
|
||||
}
|
||||
} else {
|
||||
/* For address map controls, remap the address */
|
||||
addressmap_rewrite(socks->address, sizeof(socks->address));
|
||||
if (addressmap_rewrite(socks->address, sizeof(socks->address))) {
|
||||
control_event_stream_status(conn, STREAM_EVENT_REMAP, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (address_is_in_virtual_range(socks->address)) {
|
||||
|
||||
@@ -3206,6 +3206,7 @@ control_event_stream_status(edge_connection_t *conn, stream_status_event_t tp,
|
||||
case STREAM_EVENT_NEW: status = "NEW"; break;
|
||||
case STREAM_EVENT_NEW_RESOLVE: status = "NEWRESOLVE"; break;
|
||||
case STREAM_EVENT_FAILED_RETRIABLE: status = "DETACHED"; break;
|
||||
case STREAM_EVENT_REMAP: status = "REMAP"; break;
|
||||
default:
|
||||
log_warn(LD_BUG, "Unrecognized status code %d", (int)tp);
|
||||
return 0;
|
||||
|
||||
+3
-2
@@ -2208,7 +2208,7 @@ void addressmap_clean(time_t now);
|
||||
void addressmap_clear_configured(void);
|
||||
void addressmap_clear_transient(void);
|
||||
void addressmap_free_all(void);
|
||||
void addressmap_rewrite(char *address, size_t maxlen);
|
||||
int addressmap_rewrite(char *address, size_t maxlen);
|
||||
int addressmap_have_mapping(const char *address);
|
||||
void addressmap_register(const char *address, char *new_address,
|
||||
time_t expires);
|
||||
@@ -2272,7 +2272,8 @@ typedef enum stream_status_event_t {
|
||||
STREAM_EVENT_CLOSED = 4,
|
||||
STREAM_EVENT_NEW = 5,
|
||||
STREAM_EVENT_NEW_RESOLVE = 6,
|
||||
STREAM_EVENT_FAILED_RETRIABLE = 7
|
||||
STREAM_EVENT_FAILED_RETRIABLE = 7,
|
||||
STREAM_EVENT_REMAP = 8
|
||||
} stream_status_event_t;
|
||||
|
||||
typedef enum or_conn_status_event_t {
|
||||
|
||||
+4
-2
@@ -750,8 +750,10 @@ connection_edge_process_end_not_open(
|
||||
router_parse_addr_policy_from_string("reject *:*", -1);
|
||||
}
|
||||
/* rewrite it to an IP if we learned one. */
|
||||
addressmap_rewrite(conn->socks_request->address,
|
||||
sizeof(conn->socks_request->address));
|
||||
if (addressmap_rewrite(conn->socks_request->address,
|
||||
sizeof(conn->socks_request->address))) {
|
||||
control_event_stream_status(conn, STREAM_EVENT_REMAP, 0);
|
||||
}
|
||||
if (conn->_base.chosen_exit_optional) {
|
||||
/* stop wanting a specific exit */
|
||||
conn->_base.chosen_exit_optional = 0;
|
||||
|
||||
Reference in New Issue
Block a user