* <b>address</b> is provided, set *<b>address</b> to a copy of the
* host portion of the string. If <b>addr</b> is provided, try to
* resolve the host portion of the string and store it into
- * *<b>addr</b> (in network byte order). If <b>port</b> is provided,
+ * *<b>addr</b> (in host byte order). If <b>port</b> is provided,
* store the port number into *<b>port</b>, or 0 if no port is given.
* Return 0 on success, -1 on failure.
*/
ok = 0;
*addr = 0;
}
+ *addr = ntohl(*addr);
}
if (address && ok) {
log(LOG_WARN,"HttpProxy failed to parse or resolve. Please fix.");
result = -1;
}
- options->HttpProxyAddr = ntohl(options->HttpProxyAddr); /* switch to host-order */
if (options->HttpProxyPort == 0) { /* give it a default */
options->HttpProxyPort = 80;
}
struct sockaddr_in bindaddr; /* where to bind */
connection_t *conn;
uint16_t usePort;
+ uint32_t addr;
int s; /* the socket we're going to make */
int one=1;
memset(&bindaddr,0,sizeof(struct sockaddr_in));
- if (parse_addr_port(bindaddress, NULL, &(bindaddr.sin_addr.s_addr),
- &usePort)<0) {
+ if (parse_addr_port(bindaddress, NULL, &addr, &usePort)<0) {
log_fn(LOG_WARN, "Error parsing/resolving BindAddress %s",bindaddress);
return -1;
}
+
if (usePort==0)
usePort = bindport;
+ binaddrr.sin_addr.s_addr = htonl(addr);
bindaddr.sin_family = AF_INET;
bindaddr.sin_port = htons((uint16_t) usePort);
log_fn(LOG_WARN, "Port out of range");
return NULL;
}
- addr = htonl(0x7F000001u); /* Default to 127.0.0.1 */
+ addr = 0x7F000001u; /* Default to 127.0.0.1 */
}
result = tor_malloc(sizeof(rend_service_port_config_t));
result->virtual_port = virtport;
result->real_port = realport;
- result->real_address = ntohl(addr);
+ result->real_address = addr;
return result;
}