Lines 11-16
Link Here
|
11 |
|
11 |
|
12 |
#include "xioopen.h" |
12 |
#include "xioopen.h" |
13 |
#include "xio-socket.h" |
13 |
#include "xio-socket.h" |
|
|
14 |
#include "xio-ip.h" |
14 |
#include "xio-ipapp.h" |
15 |
#include "xio-ipapp.h" |
15 |
#include "xio-ascii.h" /* for base64 encoding of authentication */ |
16 |
#include "xio-ascii.h" /* for base64 encoding of authentication */ |
16 |
|
17 |
|
Lines 231-237
static int xioopen_proxy_connect(int argc, const char *argv[], struct opt *opts,
Link Here
|
231 |
|
232 |
|
232 |
int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts, |
233 |
int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts, |
233 |
const char *targetname, const char *targetport) { |
234 |
const char *targetname, const char *targetport) { |
234 |
struct hostent *host; |
235 |
union sockaddr_union host; |
|
|
236 |
socklen_t socklen = sizeof(host); |
237 |
int rc; |
235 |
|
238 |
|
236 |
retropt_bool(opts, OPT_IGNORECR, &proxyvars->ignorecr); |
239 |
retropt_bool(opts, OPT_IGNORECR, &proxyvars->ignorecr); |
237 |
retropt_bool(opts, OPT_PROXY_RESOLVE, &proxyvars->doresolve); |
240 |
retropt_bool(opts, OPT_PROXY_RESOLVE, &proxyvars->doresolve); |
Lines 241-254
int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts,
Link Here
|
241 |
/* currently we only resolve to IPv4 addresses. This is in accordance to |
244 |
/* currently we only resolve to IPv4 addresses. This is in accordance to |
242 |
RFC 2396; however once it becomes clear how IPv6 addresses should be |
245 |
RFC 2396; however once it becomes clear how IPv6 addresses should be |
243 |
represented in CONNECT commands this code might be extended */ |
246 |
represented in CONNECT commands this code might be extended */ |
244 |
host = Gethostbyname(targetname); |
247 |
rc = xiogetaddrinfo(targetname, targetport, PF_UNSPEC, |
245 |
if (host == NULL) { |
248 |
SOCK_STREAM, IPPROTO_TCP, |
246 |
int level = E_WARN; |
249 |
&host, &socklen, 0, 0); |
247 |
/* note: cast is req on AIX: */ |
250 |
if (rc != STAT_OK) { |
248 |
Msg2(level, "gethostbyname(\"%s\"): %s", targetname, |
|
|
249 |
h_errno == NETDB_INTERNAL ? strerror(errno) : |
250 |
(char *)hstrerror(h_errno)/*0 h_messages[h_errno-1]*/); |
251 |
|
252 |
proxyvars->targetaddr = strdup(targetname); |
251 |
proxyvars->targetaddr = strdup(targetname); |
253 |
} else { |
252 |
} else { |
254 |
#define LEN 16 /* www.xxx.yyy.zzz\0 */ |
253 |
#define LEN 16 /* www.xxx.yyy.zzz\0 */ |
Lines 256-265
int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts,
Link Here
|
256 |
return STAT_RETRYLATER; |
255 |
return STAT_RETRYLATER; |
257 |
} |
256 |
} |
258 |
snprintf(proxyvars->targetaddr, LEN, "%u.%u.%u.%u", |
257 |
snprintf(proxyvars->targetaddr, LEN, "%u.%u.%u.%u", |
259 |
(unsigned char)host->h_addr_list[0][0], |
258 |
((unsigned char *)&host.ip4.sin_addr.s_addr)[0], |
260 |
(unsigned char)host->h_addr_list[0][1], |
259 |
((unsigned char *)&host.ip4.sin_addr.s_addr)[1], |
261 |
(unsigned char)host->h_addr_list[0][2], |
260 |
((unsigned char *)&host.ip4.sin_addr.s_addr)[2], |
262 |
(unsigned char)host->h_addr_list[0][3]); |
261 |
((unsigned char *)&host.ip4.sin_addr.s_addr)[3]); |
263 |
#undef LEN |
262 |
#undef LEN |
264 |
} |
263 |
} |
265 |
} else { |
264 |
} else { |