summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-29 05:51:50 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-29 05:51:50 +0000
commit6fbf17e7b0a690d95abe9cc889133b607e6f2e28 (patch)
tree81724cab811617dbbc8ba1652b676152598c92cc
parent0e172d9f6e0f6b1fbe20618879b892662a7dc051 (diff)
downloadtor-6fbf17e7b0a690d95abe9cc889133b607e6f2e28.tar.gz
tor-6fbf17e7b0a690d95abe9cc889133b607e6f2e28.zip
r11749@Kushana: nickm | 2006-12-29 00:51:42 -0500
Remove dead code; make targets of addressmap commands/configs use AllowNonRFC953Hostnames svn:r9211
-rw-r--r--src/common/util.c21
-rw-r--r--src/common/util.h1
-rw-r--r--src/or/config.c11
-rw-r--r--src/or/connection_edge.c20
-rw-r--r--src/or/control.c12
-rw-r--r--src/or/directory.c6
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/rephist.c8
8 files changed, 7 insertions, 74 deletions
diff --git a/src/common/util.c b/src/common/util.c
index ceb8716105..5e0c23bb3b 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1899,27 +1899,6 @@ tor_dup_addr(uint32_t addr)
return tor_strdup(buf);
}
-/* Return true iff <b>name</b> looks like it might be a hostname,
- * nickname, key, or IP address of some kind, suitable for the
- * controller's "mapaddress" command. */
-int
-is_plausible_address(const char *name)
-{
-// const char *cp;
- tor_assert(name);
- /* We could check better here. */
- if (!*name)
- return 0;
-#if 0
- for (cp=name; *cp; cp++) {
- if (*cp != '.' && *cp != '-' && !TOR_ISALNUM(*cp))
- return 0;
- }
-#endif
-
- return 1;
-}
-
/**
* Set *<b>addr</b> to the host-order IPv4 address (if any) of whatever
* interface connects to the internet. This address should only be used in
diff --git a/src/common/util.h b/src/common/util.h
index 54a2552da5..3ada73d4b7 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -202,7 +202,6 @@ int addr_mask_get_bits(uint32_t mask);
#define INET_NTOA_BUF_LEN 16
int tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len);
char *tor_dup_addr(uint32_t addr) ATTR_MALLOC;
-int is_plausible_address(const char *name);
int get_interface_address(int severity, uint32_t *addr);
/* Process helpers */
diff --git a/src/or/config.c b/src/or/config.c
index 383ecc62f6..67c6140748 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2286,10 +2286,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->NatdPort == 0 && options->NatdListenAddress != NULL)
REJECT("NatdPort must be defined if NatdListenAddress is defined.");
-#if 0 /* don't complain, since a standard configuration does this! */
- if (options->SocksPort == 0 && options->SocksListenAddress != NULL)
- REJECT("SocksPort must be defined if SocksListenAddress is defined.");
-#endif
+ /* Don't gripe about SocksPort 0 with SocksListenAddress set; a standard
+ * configuration does this. */
for (i = 0; i < 3; ++i) {
int is_socks = i==0;
@@ -3090,10 +3088,7 @@ config_register_addressmaps(or_options_t *options)
if (smartlist_len(elts) >= 2) {
from = smartlist_get(elts,0);
to = smartlist_get(elts,1);
- if (!is_plausible_address(from)) {
- log_warn(LD_CONFIG,
- "Skipping invalid argument '%s' to MapAddress", from);
- } else if (!is_plausible_address(to)) {
+ if (address_is_invalid_destination(to)) {
log_warn(LD_CONFIG,
"Skipping invalid argument '%s' to MapAddress", to);
} else {
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 4e6ec78515..06992ee16e 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -1085,7 +1085,7 @@ addressmap_register_virtual_address(int type, char *new_address)
/** Return 1 if <b>address</b> has funny characters in it like
* colons. Return 0 if it's fine.
*/
-static int
+int
address_is_invalid_destination(const char *address)
{
if (get_options()->AllowNonRFC953Hostnames)
@@ -2091,18 +2091,6 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
tor_free(address);
return 0;
}
-#if 0
- if (!tor_strisprint(address)) {
- log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
- "Non-printing characters in address %s in relay "
- "begin cell. Closing.", escaped(address));
- end_payload[0] = END_STREAM_REASON_TORPROTOCOL;
- relay_send_command_from_edge(rh.stream_id, circ, RELAY_COMMAND_END,
- end_payload, 1, NULL);
- tor_free(address);
- return 0;
- }
-#endif
if (or_circ && or_circ->is_first_hop) {
/* Don't let clients use us as a single-hop proxy; it attracts attackers
* and users who'd be better off with, well, single-hop proxies.
@@ -2478,12 +2466,6 @@ connection_ap_can_use_exit(edge_connection_t *conn, routerinfo_t *exit)
tor_assert(conn->socks_request);
tor_assert(exit);
-#if 0
- log_fn(LOG_DEBUG,"considering nickname %s, for address %s / port %d:",
- exit->nickname, safe_str(conn->socks_request->address),
- conn->socks_request->port);
-#endif
-
/* If a particular exit node has been requested for the new connection,
* make sure the exit node of the existing circuit matches exactly.
*/
diff --git a/src/or/control.c b/src/or/control.c
index 21b5350153..4b5947c1f1 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1340,17 +1340,7 @@ handle_control_mapaddress(control_connection_t *conn, uint32_t len,
const char *to = smartlist_get(elts,1);
size_t anslen = strlen(line)+512;
char *ans = tor_malloc(anslen);
- if (!is_plausible_address(from)) {
- if (!v0) {
- tor_snprintf(ans, anslen,
- "512-syntax error: invalid address '%s'", from);
- smartlist_add(reply, ans);
- } else
- tor_free(ans); /* don't respond if v0 */
- log_warn(LD_CONTROL,
- "Skipping invalid argument '%s' in MapAddress msg",
- from);
- } else if (!is_plausible_address(to)) {
+ if (address_is_invalid_destination(to)) {
if (!v0) {
tor_snprintf(ans, anslen,
"512-syntax error: invalid address '%s'", to);
diff --git a/src/or/directory.c b/src/or/directory.c
index 57f0871475..18225aa0d5 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1836,12 +1836,6 @@ directory_handle_command_post(dir_connection_t *conn, char *headers,
log_fn(LOG_PROTOCOL_WARN, LD_DIRSERV,
"Rejected rend descriptor (length %d) from %s.",
(int)body_len, conn->_base.address);
-#if 0
- if (body_len <= 1024) {
- base16_encode(tmp, sizeof(tmp), body, body_len);
- log_notice(LD_DIRSERV,"Body was: %s", escaped(tmp));
- }
-#endif
write_http_status_line(conn, 400, "Invalid service descriptor rejected");
} else {
write_http_status_line(conn, 200, "Service descriptor stored");
diff --git a/src/or/or.h b/src/or/or.h
index b81079ba0e..23ecdad93c 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2088,6 +2088,8 @@ int connection_ap_detach_retriable(edge_connection_t *conn,
int reason);
int connection_ap_process_transparent(edge_connection_t *conn);
+int address_is_invalid_destination(const char *address);
+
void addressmap_init(void);
void addressmap_clean(time_t now);
void addressmap_clear_configured(void);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 7b13d124bc..e24b6ad205 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -882,14 +882,6 @@ rep_hist_note_used_resolve(time_t now)
rep_hist_note_used_port(80, now);
}
-#if 0
-int
-rep_hist_get_predicted_resolve(time_t now)
-{
- return 0;
-}
-#endif
-
/** The last time at which we needed an internal circ. */
static time_t predicted_internal_time = 0;
/** The last time we needed an internal circ with good uptime. */