Skip to content
Snippets Groups Projects
Commit 1053af0b authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Merge branch 'bug7555_v2_squashed'

Conflicts:
	src/or/connection_edge.c
parents 63765399 758d7713
No related branches found
No related tags found
No related merge requests found
o Minor bugfixes (client DNS):
- Report the correct cached DNS expiration times. Previously, we
would report everything as "never expires." Fixes bug 14193;
bugfix on 0.2.3.17-beta.
o Minor bugfixes (client):
- Avoid a small memory leak when we find a cached answer for a reverse
DNS lookup in a client-side DNS cache. (Remember, client-side DNS
caching is off by default, and is not recommended.) Fixes bug 14259;
bugfix on 0.2.0.1-alpha.
o Major bugfixes (client):
- Allow MapAddress and AutomapHostsOnResolve to work together when an
address is mapped into another address type that must be
automapped at resolve time. Fixes bug 7555; bugfix on
0.2.0.1-alpha.
......@@ -390,13 +390,35 @@ addressmap_rewrite(char *address, size_t maxlen,
goto done;
}
if (ent && ent->source == ADDRMAPSRC_DNS) {
sa_family_t f;
tor_addr_t tmp;
f = tor_addr_parse(&tmp, ent->new_address);
if (f == AF_INET && !(flags & AMR_FLAG_USE_IPV4_DNS))
goto done;
else if (f == AF_INET6 && !(flags & AMR_FLAG_USE_IPV6_DNS))
switch (ent->source) {
case ADDRMAPSRC_DNS:
{
sa_family_t f;
tor_addr_t tmp;
f = tor_addr_parse(&tmp, ent->new_address);
if (f == AF_INET && !(flags & AMR_FLAG_USE_IPV4_DNS))
goto done;
else if (f == AF_INET6 && !(flags & AMR_FLAG_USE_IPV6_DNS))
goto done;
}
break;
case ADDRMAPSRC_CONTROLLER:
case ADDRMAPSRC_TORRC:
if (!(flags & AMR_FLAG_USE_MAPADDRESS))
goto done;
break;
case ADDRMAPSRC_AUTOMAP:
if (!(flags & AMR_FLAG_USE_AUTOMAP))
goto done;
break;
case ADDRMAPSRC_TRACKEXIT:
if (!(flags & AMR_FLAG_USE_TRACKEXIT))
goto done;
break;
case ADDRMAPSRC_NONE:
default:
log_warn(LD_BUG, "Unknown addrmap source value %d. Ignoring it.",
(int) ent->source);
goto done;
}
......@@ -431,7 +453,7 @@ addressmap_rewrite(char *address, size_t maxlen,
if (exit_source_out)
*exit_source_out = exit_source;
if (expires_out)
*expires_out = TIME_MAX;
*expires_out = expires;
return (rewrites > 0);
}
......@@ -455,6 +477,8 @@ addressmap_rewrite_reverse(char *address, size_t maxlen, unsigned flags,
return 0;
else if (f == AF_INET6 && !(flags & AMR_FLAG_USE_IPV6_DNS))
return 0;
/* FFFF we should reverse-map virtual addresses even if we haven't
* enabled DNS cacheing. */
}
tor_asprintf(&s, "REVERSE[%s]", address);
......@@ -981,6 +1005,8 @@ addressmap_register_virtual_address(int type, char *new_address)
strmap_set(virtaddress_reversemap, new_address, vent);
addressmap_register(*addrp, new_address, 2, ADDRMAPSRC_AUTOMAP, 0, 0);
/* FFFF register corresponding reverse mapping. */
#if 0
{
/* Try to catch possible bugs */
......
......@@ -16,8 +16,11 @@ void addressmap_clean(time_t now);
void addressmap_clear_configured(void);
void addressmap_clear_transient(void);
void addressmap_free_all(void);
#define AMR_FLAG_USE_IPV4_DNS (1u<<0)
#define AMR_FLAG_USE_IPV6_DNS (1u<<1)
#define AMR_FLAG_USE_IPV4_DNS (1u<<0)
#define AMR_FLAG_USE_IPV6_DNS (1u<<1)
#define AMR_FLAG_USE_MAPADDRESS (1u<<2)
#define AMR_FLAG_USE_AUTOMAP (1u<<3)
#define AMR_FLAG_USE_TRACKEXIT (1u<<4)
int addressmap_rewrite(char *address, size_t maxlen, unsigned flags,
time_t *expires_out,
addressmap_entry_source_t *exit_source_out);
......
This diff is collapsed.
......@@ -143,6 +143,31 @@ STATIC int begin_cell_parse(const cell_t *cell, begin_cell_t *bcell,
STATIC int connected_cell_format_payload(uint8_t *payload_out,
const tor_addr_t *addr,
uint32_t ttl);
typedef struct {
/** Original address, after we lowercased it but before we started
* mapping it.
*/
char orig_address[MAX_SOCKS_ADDR_LEN];
/** True iff the address has been automatically remapped to a local
* address in VirtualAddrNetwork. (Only set true when we do a resolve
* and get a virtual address; not when we connect to the address.) */
int automap;
/** If this connection has a .exit address, who put it there? */
addressmap_entry_source_t exit_source;
/** If we've rewritten the address, when does this map expire? */
time_t map_expires;
/** If we should close the connection, this is the end_reason to pass
* to connection_mark_unattached_ap */
int end_reason;
/** True iff we should close the connection, either because of error or
* because of successful early RESOLVED reply. */
int should_close;
} rewrite_result_t;
STATIC void connection_ap_handshake_rewrite(entry_connection_t *conn,
rewrite_result_t *out);
#endif
#endif
......
......@@ -31,6 +31,7 @@ src_test_test_SOURCES = \
src/test/test_data.c \
src/test/test_dir.c \
src/test/test_checkdir.c \
src/test/test_entryconn.c \
src/test/test_entrynodes.c \
src/test/test_extorport.c \
src/test/test_introduce.c \
......
......@@ -1313,6 +1313,7 @@ extern struct testcase_t channel_tests[];
extern struct testcase_t channeltls_tests[];
extern struct testcase_t relay_tests[];
extern struct testcase_t scheduler_tests[];
extern struct testcase_t entryconn_tests[];
static struct testgroup_t testgroups[] = {
{ "", test_array },
......@@ -1337,6 +1338,7 @@ static struct testgroup_t testgroups[] = {
{ "circuitmux/", circuitmux_tests },
{ "options/", options_tests },
{ "entrynodes/", entrynodes_tests },
{ "entryconn/", entryconn_tests },
{ "extorport/", extorport_tests },
{ "control/", controller_event_tests },
{ "hs/", hs_tests },
......
......@@ -51,8 +51,7 @@ test_config_addressmap(void *arg)
/* Use old interface for now, so we don't need to rewrite the unit tests */
#define addressmap_rewrite(a,s,eo,ao) \
addressmap_rewrite((a),(s),AMR_FLAG_USE_IPV4_DNS|AMR_FLAG_USE_IPV6_DNS, \
(eo),(ao))
addressmap_rewrite((a),(s), ~0, (eo),(ao))
/* MapAddress .invalidwildcard.com .torserver.exit - no match */
strlcpy(address, "www.invalidwildcard.com", sizeof(address));
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment