diff options
author | Felix Fietkau <nbd@openwrt.org> | 2016-01-15 21:30:09 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2016-01-15 21:30:09 +0100 |
commit | b80dc6035287b17165f220033b270e5608e744e5 (patch) | |
tree | 691c810313c8837bbec31b422b08d9dce2701cf0 /uclient-http.c | |
parent | 4edb1426cef9eb07aa52dab2c34ab51f64e10f74 (diff) | |
download | uclient-b80dc6035287b17165f220033b270e5608e744e5.tar.gz |
http: get remote address from usock instead of using getpeername
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-http.c')
-rw-r--r-- | uclient-http.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/uclient-http.c b/uclient-http.c index 4300d05..676ce1b 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -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; } |