aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2013-11-20 21:49:17 +0200
committerNick Mathewson <nickm@torproject.org>2014-02-03 14:20:24 -0500
commite82e772f2b1a2b2235d3b3bcde85666e09a182b5 (patch)
tree142878ebb0e236afaf1df8a4b4a5ed8eb2c3afd5 /src
parent3a4b24c3aba56475822ad94d268b48fd58b74645 (diff)
downloadtor-e82e772f2b1a2b2235d3b3bcde85666e09a182b5.tar
tor-e82e772f2b1a2b2235d3b3bcde85666e09a182b5.tar.gz
Using proper functions to create tor_addr_t.
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c6
-rw-r--r--src/or/directory.c13
-rw-r--r--src/or/dirserv.c3
3 files changed, 5 insertions, 17 deletions
diff --git a/src/or/config.c b/src/or/config.c
index f840b5e28..a90468dfa 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2104,8 +2104,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
"local interface. Using that.", fmt_addr32(addr));
strlcpy(hostname, "<guessed from interfaces>", sizeof(hostname));
} else { /* resolved hostname into addr */
- myaddr.family = AF_INET;
- myaddr.addr.in_addr.s_addr = htonl(addr);
+ tor_addr_from_ipv4h(&myaddr, addr);
if (!explicit_hostname &&
tor_addr_is_internal(&myaddr, 0)) {
@@ -2142,8 +2141,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
* out if it is and we don't want that.
*/
- myaddr.family = AF_INET;
- myaddr.addr.in_addr.s_addr = htonl(addr);
+ tor_addr_from_ipv4h(&myaddr,addr);
addr_string = tor_dup_ip(addr);
if (tor_addr_is_internal(&myaddr, 0)) {
diff --git a/src/or/directory.c b/src/or/directory.c
index 7f26affa2..6effe45db 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1414,20 +1414,11 @@ http_set_address_origin(const char *headers, connection_t *conn)
if (!fwd)
fwd = http_get_header(headers, "X-Forwarded-For: ");
if (fwd) {
- struct in_addr in;
- if (!tor_inet_aton(fwd, &in)) {
- log_debug(LD_DIR, "Ignoring unrecognized IP %s",
- escaped(fwd));
- tor_free(fwd);
- return;
- }
-
tor_addr_t toraddr;
- toraddr.family = AF_INET;
- toraddr.addr.in_addr = in;
+ tor_addr_parse(&toraddr,fwd);
if (tor_addr_is_internal(&toraddr,0)) {
- log_debug(LD_DIR, "Ignoring local IP %s", escaped(fwd));
+ log_debug(LD_DIR, "Ignoring local/internal IP %s", escaped(fwd));
tor_free(fwd);
return;
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 4a25f99a4..b6bb607fa 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -535,8 +535,7 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
}
tor_addr_t toraddr;
- toraddr.family = AF_INET;
- toraddr.addr.in_addr = iaddr;
+ tor_addr_from_in(&toraddr,&iaddr);
if (tor_addr_is_internal(&toraddr, 0)) {
log_info(LD_DIRSERV,