http: get remote address from usock instead of using getpeername
authorFelix Fietkau <nbd@openwrt.org>
Fri, 15 Jan 2016 20:30:09 +0000 (21:30 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 15 Jan 2016 20:30:09 +0000 (21:30 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
uclient-http.c

index 4300d0511e95d0dfa74d5044bd0e1ab8bd92018f..676ce1bea1af81c14764df449db99c42043a6dd7 100644 (file)
@@ -115,18 +115,17 @@ static int uclient_do_connect(struct uclient_http *uh, const char *port)
        if (uh->uc.url->port)
                port = uh->uc.url->port;
 
-       fd = usock(USOCK_TCP | USOCK_NONBLOCK, uh->uc.url->host, port);
+       memset(&uh->uc.remote_addr, 0, sizeof(uh->uc.remote_addr));
+
+       fd = usock_inet(USOCK_TCP | USOCK_NONBLOCK, uh->uc.url->host, port, &uh->uc.remote_addr);
        if (fd < 0)
                return -1;
 
        ustream_fd_init(&uh->ufd, fd);
 
-       memset(&uh->uc.local_addr, 0, sizeof(uh->uc.local_addr));
-       memset(&uh->uc.remote_addr, 0, sizeof(uh->uc.remote_addr));
-
        sl = sizeof(uh->uc.local_addr);
+       memset(&uh->uc.local_addr, 0, sl);
        getsockname(fd, &uh->uc.local_addr.sa, &sl);
-       getpeername(fd, &uh->uc.remote_addr.sa, &sl);
 
        return 0;
 }