mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-26 23:52:30 +01:00
Using proper functions to create tor_addr_t.
This commit is contained in:
parent
3a4b24c3ab
commit
e82e772f2b
3 changed files with 5 additions and 17 deletions
|
@ -2104,8 +2104,7 @@ resolve_my_address(int warn_severity, const or_options_t *options,
|
||||||
"local interface. Using that.", fmt_addr32(addr));
|
"local interface. Using that.", fmt_addr32(addr));
|
||||||
strlcpy(hostname, "<guessed from interfaces>", sizeof(hostname));
|
strlcpy(hostname, "<guessed from interfaces>", sizeof(hostname));
|
||||||
} else { /* resolved hostname into addr */
|
} else { /* resolved hostname into addr */
|
||||||
myaddr.family = AF_INET;
|
tor_addr_from_ipv4h(&myaddr, addr);
|
||||||
myaddr.addr.in_addr.s_addr = htonl(addr);
|
|
||||||
|
|
||||||
if (!explicit_hostname &&
|
if (!explicit_hostname &&
|
||||||
tor_addr_is_internal(&myaddr, 0)) {
|
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.
|
* out if it is and we don't want that.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
myaddr.family = AF_INET;
|
tor_addr_from_ipv4h(&myaddr,addr);
|
||||||
myaddr.addr.in_addr.s_addr = htonl(addr);
|
|
||||||
|
|
||||||
addr_string = tor_dup_ip(addr);
|
addr_string = tor_dup_ip(addr);
|
||||||
if (tor_addr_is_internal(&myaddr, 0)) {
|
if (tor_addr_is_internal(&myaddr, 0)) {
|
||||||
|
|
|
@ -1414,20 +1414,11 @@ http_set_address_origin(const char *headers, connection_t *conn)
|
||||||
if (!fwd)
|
if (!fwd)
|
||||||
fwd = http_get_header(headers, "X-Forwarded-For: ");
|
fwd = http_get_header(headers, "X-Forwarded-For: ");
|
||||||
if (fwd) {
|
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;
|
tor_addr_t toraddr;
|
||||||
toraddr.family = AF_INET;
|
tor_addr_parse(&toraddr,fwd);
|
||||||
toraddr.addr.in_addr = in;
|
|
||||||
|
|
||||||
if (tor_addr_is_internal(&toraddr,0)) {
|
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);
|
tor_free(fwd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -535,8 +535,7 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
|
||||||
}
|
}
|
||||||
|
|
||||||
tor_addr_t toraddr;
|
tor_addr_t toraddr;
|
||||||
toraddr.family = AF_INET;
|
tor_addr_from_in(&toraddr,&iaddr);
|
||||||
toraddr.addr.in_addr = iaddr;
|
|
||||||
|
|
||||||
if (tor_addr_is_internal(&toraddr, 0)) {
|
if (tor_addr_is_internal(&toraddr, 0)) {
|
||||||
log_info(LD_DIRSERV,
|
log_info(LD_DIRSERV,
|
||||||
|
|
Loading…
Add table
Reference in a new issue