1 | /* |
---|
2 | * gaim |
---|
3 | * |
---|
4 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
---|
5 | * Copyright (C) 2002-2004, Wilmer van der Gaast, Jelmer Vernooij |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or modify |
---|
8 | * it under the terms of the GNU General Public License as published by |
---|
9 | * the Free Software Foundation; either version 2 of the License, or |
---|
10 | * (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | #define BITLBEE_CORE |
---|
24 | #include <stdio.h> |
---|
25 | #include <stdlib.h> |
---|
26 | #include <string.h> |
---|
27 | #include <sys/types.h> |
---|
28 | #include <sys/socket.h> |
---|
29 | #include <netdb.h> |
---|
30 | #include <netinet/in.h> |
---|
31 | #include <arpa/inet.h> |
---|
32 | #include <unistd.h> |
---|
33 | #include <fcntl.h> |
---|
34 | #include <errno.h> |
---|
35 | #include "nogaim.h" |
---|
36 | #include "proxy.h" |
---|
37 | #include "base64.h" |
---|
38 | |
---|
39 | char proxyhost[128] = ""; |
---|
40 | int proxyport = 0; |
---|
41 | int proxytype = PROXY_NONE; |
---|
42 | char proxyuser[128] = ""; |
---|
43 | char proxypass[128] = ""; |
---|
44 | |
---|
45 | /* Some systems don't know this one. It's not essential, so set it to 0 then. */ |
---|
46 | #ifndef AI_NUMERICSERV |
---|
47 | #define AI_NUMERICSERV 0 |
---|
48 | #endif |
---|
49 | #ifndef AI_ADDRCONFIG |
---|
50 | #define AI_ADDRCONFIG 0 |
---|
51 | #endif |
---|
52 | |
---|
53 | struct PHB { |
---|
54 | b_event_handler func, proxy_func; |
---|
55 | gpointer data, proxy_data; |
---|
56 | char *host; |
---|
57 | int port; |
---|
58 | int fd; |
---|
59 | gint inpa; |
---|
60 | struct addrinfo *gai, *gai_cur; |
---|
61 | }; |
---|
62 | |
---|
63 | typedef int (*proxy_connect_func)(const char *host, unsigned short port_, struct PHB *phb); |
---|
64 | |
---|
65 | static int proxy_connect_none(const char *host, unsigned short port_, struct PHB *phb); |
---|
66 | |
---|
67 | static gboolean phb_free(struct PHB *phb, gboolean success) |
---|
68 | { |
---|
69 | if (!success) { |
---|
70 | if (phb->fd > 0) { |
---|
71 | closesocket(phb->fd); |
---|
72 | } |
---|
73 | if (phb->func) { |
---|
74 | phb->func(phb->data, -1, B_EV_IO_READ); |
---|
75 | } |
---|
76 | } |
---|
77 | if (phb->gai) { |
---|
78 | freeaddrinfo(phb->gai); |
---|
79 | } |
---|
80 | g_free(phb->host); |
---|
81 | g_free(phb); |
---|
82 | return FALSE; |
---|
83 | } |
---|
84 | |
---|
85 | static gboolean proxy_connected(gpointer data, gint source, b_input_condition cond) |
---|
86 | { |
---|
87 | struct PHB *phb = data; |
---|
88 | socklen_t len; |
---|
89 | int error = ETIMEDOUT; |
---|
90 | |
---|
91 | len = sizeof(error); |
---|
92 | |
---|
93 | if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) { |
---|
94 | if ((phb->gai_cur = phb->gai_cur->ai_next)) { |
---|
95 | int new_fd; |
---|
96 | b_event_remove(phb->inpa); |
---|
97 | if ((new_fd = proxy_connect_none(NULL, 0, phb))) { |
---|
98 | b_event_remove(phb->inpa); |
---|
99 | closesocket(source); |
---|
100 | dup2(new_fd, source); |
---|
101 | closesocket(new_fd); |
---|
102 | phb->inpa = b_input_add(source, B_EV_IO_WRITE, proxy_connected, phb); |
---|
103 | return FALSE; |
---|
104 | } |
---|
105 | } |
---|
106 | closesocket(source); |
---|
107 | source = -1; |
---|
108 | /* socket is dead, but continue to clean up */ |
---|
109 | } else { |
---|
110 | sock_make_blocking(source); |
---|
111 | } |
---|
112 | |
---|
113 | freeaddrinfo(phb->gai); |
---|
114 | phb->gai = NULL; |
---|
115 | |
---|
116 | b_event_remove(phb->inpa); |
---|
117 | phb->inpa = 0; |
---|
118 | |
---|
119 | if (phb->proxy_func) { |
---|
120 | phb->proxy_func(phb->proxy_data, source, B_EV_IO_READ); |
---|
121 | } else { |
---|
122 | phb->func(phb->data, source, B_EV_IO_READ); |
---|
123 | phb_free(phb, TRUE); |
---|
124 | } |
---|
125 | |
---|
126 | return FALSE; |
---|
127 | } |
---|
128 | |
---|
129 | static int proxy_connect_none(const char *host, unsigned short port_, struct PHB *phb) |
---|
130 | { |
---|
131 | struct sockaddr_in me; |
---|
132 | int fd = -1; |
---|
133 | |
---|
134 | if (phb->gai_cur == NULL) { |
---|
135 | int ret; |
---|
136 | char port[6]; |
---|
137 | struct addrinfo hints; |
---|
138 | |
---|
139 | g_snprintf(port, sizeof(port), "%d", port_); |
---|
140 | |
---|
141 | memset(&hints, 0, sizeof(struct addrinfo)); |
---|
142 | hints.ai_family = AF_UNSPEC; |
---|
143 | hints.ai_socktype = SOCK_STREAM; |
---|
144 | hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; |
---|
145 | |
---|
146 | if (!(ret = getaddrinfo(host, port, &hints, &phb->gai))) { |
---|
147 | phb->gai_cur = phb->gai; |
---|
148 | } else { |
---|
149 | event_debug("gai(): %s\n", gai_strerror(ret)); |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|
153 | for (; phb->gai_cur; phb->gai_cur = phb->gai_cur->ai_next) { |
---|
154 | if ((fd = socket(phb->gai_cur->ai_family, phb->gai_cur->ai_socktype, phb->gai_cur->ai_protocol)) < 0) { |
---|
155 | event_debug("socket failed: %d\n", errno); |
---|
156 | continue; |
---|
157 | } |
---|
158 | |
---|
159 | sock_make_nonblocking(fd); |
---|
160 | |
---|
161 | if (global.conf->iface_out) { |
---|
162 | me.sin_family = AF_INET; |
---|
163 | me.sin_port = 0; |
---|
164 | me.sin_addr.s_addr = inet_addr(global.conf->iface_out); |
---|
165 | |
---|
166 | if (bind(fd, (struct sockaddr *) &me, sizeof(me)) != 0) { |
---|
167 | event_debug("bind( %d, \"%s\" ) failure\n", fd, global.conf->iface_out); |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port_, fd); |
---|
172 | |
---|
173 | if (connect(fd, phb->gai_cur->ai_addr, phb->gai_cur->ai_addrlen) < 0 && !sockerr_again()) { |
---|
174 | event_debug("connect failed: %s\n", strerror(errno)); |
---|
175 | closesocket(fd); |
---|
176 | fd = -1; |
---|
177 | continue; |
---|
178 | } else { |
---|
179 | phb->inpa = b_input_add(fd, B_EV_IO_WRITE, proxy_connected, phb); |
---|
180 | phb->fd = fd; |
---|
181 | |
---|
182 | break; |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | if (fd < 0 && host) { |
---|
187 | phb_free(phb, TRUE); |
---|
188 | } |
---|
189 | |
---|
190 | return fd; |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | /* Connecting to HTTP proxies */ |
---|
195 | |
---|
196 | #define HTTP_GOODSTRING "HTTP/1.0 200" |
---|
197 | #define HTTP_GOODSTRING2 "HTTP/1.1 200" |
---|
198 | |
---|
199 | static gboolean http_canread(gpointer data, gint source, b_input_condition cond) |
---|
200 | { |
---|
201 | int nlc = 0; |
---|
202 | int pos = 0; |
---|
203 | struct PHB *phb = data; |
---|
204 | char inputline[8192]; |
---|
205 | |
---|
206 | b_event_remove(phb->inpa); |
---|
207 | |
---|
208 | while ((pos < sizeof(inputline) - 1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) { |
---|
209 | if (inputline[pos - 1] == '\n') { |
---|
210 | nlc++; |
---|
211 | } else if (inputline[pos - 1] != '\r') { |
---|
212 | nlc = 0; |
---|
213 | } |
---|
214 | } |
---|
215 | inputline[pos] = '\0'; |
---|
216 | |
---|
217 | if ((memcmp(HTTP_GOODSTRING, inputline, strlen(HTTP_GOODSTRING)) == 0) || |
---|
218 | (memcmp(HTTP_GOODSTRING2, inputline, strlen(HTTP_GOODSTRING2)) == 0)) { |
---|
219 | phb->func(phb->data, source, B_EV_IO_READ); |
---|
220 | return phb_free(phb, TRUE); |
---|
221 | } |
---|
222 | |
---|
223 | return phb_free(phb, FALSE); |
---|
224 | } |
---|
225 | |
---|
226 | static gboolean http_canwrite(gpointer data, gint source, b_input_condition cond) |
---|
227 | { |
---|
228 | char cmd[384]; |
---|
229 | struct PHB *phb = data; |
---|
230 | socklen_t len; |
---|
231 | int error = ETIMEDOUT; |
---|
232 | |
---|
233 | if (phb->inpa > 0) { |
---|
234 | b_event_remove(phb->inpa); |
---|
235 | } |
---|
236 | len = sizeof(error); |
---|
237 | if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { |
---|
238 | return phb_free(phb, FALSE); |
---|
239 | } |
---|
240 | sock_make_blocking(source); |
---|
241 | |
---|
242 | g_snprintf(cmd, sizeof(cmd), "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", phb->host, phb->port, |
---|
243 | phb->host, phb->port); |
---|
244 | if (send(source, cmd, strlen(cmd), 0) < 0) { |
---|
245 | return phb_free(phb, FALSE); |
---|
246 | } |
---|
247 | |
---|
248 | if (strlen(proxyuser) > 0) { |
---|
249 | char *t1, *t2; |
---|
250 | t1 = g_strdup_printf("%s:%s", proxyuser, proxypass); |
---|
251 | t2 = tobase64(t1); |
---|
252 | g_free(t1); |
---|
253 | g_snprintf(cmd, sizeof(cmd), "Proxy-Authorization: Basic %s\r\n", t2); |
---|
254 | g_free(t2); |
---|
255 | if (send(source, cmd, strlen(cmd), 0) < 0) { |
---|
256 | return phb_free(phb, FALSE); |
---|
257 | } |
---|
258 | } |
---|
259 | |
---|
260 | g_snprintf(cmd, sizeof(cmd), "\r\n"); |
---|
261 | if (send(source, cmd, strlen(cmd), 0) < 0) { |
---|
262 | return phb_free(phb, FALSE); |
---|
263 | } |
---|
264 | |
---|
265 | phb->inpa = b_input_add(source, B_EV_IO_READ, http_canread, phb); |
---|
266 | |
---|
267 | return FALSE; |
---|
268 | } |
---|
269 | |
---|
270 | static int proxy_connect_http(const char *host, unsigned short port, struct PHB *phb) |
---|
271 | { |
---|
272 | phb->host = g_strdup(host); |
---|
273 | phb->port = port; |
---|
274 | phb->proxy_func = http_canwrite; |
---|
275 | phb->proxy_data = phb; |
---|
276 | |
---|
277 | return(proxy_connect_none(proxyhost, proxyport, phb)); |
---|
278 | } |
---|
279 | |
---|
280 | |
---|
281 | /* Connecting to SOCKS4 proxies */ |
---|
282 | |
---|
283 | static gboolean s4_canread(gpointer data, gint source, b_input_condition cond) |
---|
284 | { |
---|
285 | unsigned char packet[12]; |
---|
286 | struct PHB *phb = data; |
---|
287 | |
---|
288 | b_event_remove(phb->inpa); |
---|
289 | |
---|
290 | memset(packet, 0, sizeof(packet)); |
---|
291 | if (read(source, packet, 9) >= 4 && packet[1] == 90) { |
---|
292 | phb->func(phb->data, source, B_EV_IO_READ); |
---|
293 | return phb_free(phb, TRUE); |
---|
294 | } |
---|
295 | |
---|
296 | return phb_free(phb, FALSE); |
---|
297 | } |
---|
298 | |
---|
299 | static gboolean s4_canwrite(gpointer data, gint source, b_input_condition cond) |
---|
300 | { |
---|
301 | unsigned char packet[12]; |
---|
302 | struct hostent *hp; |
---|
303 | struct PHB *phb = data; |
---|
304 | socklen_t len; |
---|
305 | int error = ETIMEDOUT; |
---|
306 | gboolean is_socks4a = (proxytype == PROXY_SOCKS4A); |
---|
307 | |
---|
308 | if (phb->inpa > 0) { |
---|
309 | b_event_remove(phb->inpa); |
---|
310 | } |
---|
311 | len = sizeof(error); |
---|
312 | if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { |
---|
313 | return phb_free(phb, FALSE); |
---|
314 | } |
---|
315 | sock_make_blocking(source); |
---|
316 | |
---|
317 | if (!is_socks4a && !(hp = gethostbyname(phb->host))) { |
---|
318 | return phb_free(phb, FALSE); |
---|
319 | } |
---|
320 | |
---|
321 | packet[0] = 4; |
---|
322 | packet[1] = 1; |
---|
323 | packet[2] = phb->port >> 8; |
---|
324 | packet[3] = phb->port & 0xff; |
---|
325 | if (is_socks4a) { |
---|
326 | packet[4] = 0; |
---|
327 | packet[5] = 0; |
---|
328 | packet[6] = 0; |
---|
329 | packet[7] = 1; |
---|
330 | } else { |
---|
331 | packet[4] = (unsigned char) (hp->h_addr_list[0])[0]; |
---|
332 | packet[5] = (unsigned char) (hp->h_addr_list[0])[1]; |
---|
333 | packet[6] = (unsigned char) (hp->h_addr_list[0])[2]; |
---|
334 | packet[7] = (unsigned char) (hp->h_addr_list[0])[3]; |
---|
335 | } |
---|
336 | packet[8] = 0; |
---|
337 | if (write(source, packet, 9) != 9) { |
---|
338 | return phb_free(phb, FALSE); |
---|
339 | } |
---|
340 | |
---|
341 | if (is_socks4a) { |
---|
342 | size_t host_len = strlen(phb->host) + 1; /* include the \0 */ |
---|
343 | |
---|
344 | if (write(source, phb->host, host_len) != host_len) { |
---|
345 | return phb_free(phb, FALSE); |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | phb->inpa = b_input_add(source, B_EV_IO_READ, s4_canread, phb); |
---|
350 | |
---|
351 | return FALSE; |
---|
352 | } |
---|
353 | |
---|
354 | static int proxy_connect_socks4(const char *host, unsigned short port, struct PHB *phb) |
---|
355 | { |
---|
356 | phb->host = g_strdup(host); |
---|
357 | phb->port = port; |
---|
358 | phb->proxy_func = s4_canwrite; |
---|
359 | phb->proxy_data = phb; |
---|
360 | |
---|
361 | return(proxy_connect_none(proxyhost, proxyport, phb)); |
---|
362 | } |
---|
363 | |
---|
364 | |
---|
365 | /* Connecting to SOCKS5 proxies */ |
---|
366 | |
---|
367 | static gboolean s5_canread_again(gpointer data, gint source, b_input_condition cond) |
---|
368 | { |
---|
369 | unsigned char buf[512]; |
---|
370 | struct PHB *phb = data; |
---|
371 | |
---|
372 | b_event_remove(phb->inpa); |
---|
373 | |
---|
374 | if (read(source, buf, 10) < 10) { |
---|
375 | return phb_free(phb, FALSE); |
---|
376 | } |
---|
377 | if ((buf[0] != 0x05) || (buf[1] != 0x00)) { |
---|
378 | return phb_free(phb, FALSE); |
---|
379 | } |
---|
380 | |
---|
381 | phb->func(phb->data, source, B_EV_IO_READ); |
---|
382 | return phb_free(phb, TRUE); |
---|
383 | } |
---|
384 | |
---|
385 | static void s5_sendconnect(gpointer data, gint source) |
---|
386 | { |
---|
387 | unsigned char buf[512]; |
---|
388 | struct PHB *phb = data; |
---|
389 | int hlen = strlen(phb->host); |
---|
390 | |
---|
391 | buf[0] = 0x05; |
---|
392 | buf[1] = 0x01; /* CONNECT */ |
---|
393 | buf[2] = 0x00; /* reserved */ |
---|
394 | buf[3] = 0x03; /* address type -- host name */ |
---|
395 | buf[4] = hlen; |
---|
396 | memcpy(buf + 5, phb->host, hlen); |
---|
397 | buf[5 + strlen(phb->host)] = phb->port >> 8; |
---|
398 | buf[5 + strlen(phb->host) + 1] = phb->port & 0xff; |
---|
399 | |
---|
400 | if (write(source, buf, (5 + strlen(phb->host) + 2)) < (5 + strlen(phb->host) + 2)) { |
---|
401 | phb_free(phb, FALSE); |
---|
402 | return; |
---|
403 | } |
---|
404 | |
---|
405 | phb->inpa = b_input_add(source, B_EV_IO_READ, s5_canread_again, phb); |
---|
406 | } |
---|
407 | |
---|
408 | static gboolean s5_readauth(gpointer data, gint source, b_input_condition cond) |
---|
409 | { |
---|
410 | unsigned char buf[512]; |
---|
411 | struct PHB *phb = data; |
---|
412 | |
---|
413 | b_event_remove(phb->inpa); |
---|
414 | |
---|
415 | if (read(source, buf, 2) < 2) { |
---|
416 | return phb_free(phb, FALSE); |
---|
417 | } |
---|
418 | |
---|
419 | if ((buf[0] != 0x01) || (buf[1] != 0x00)) { |
---|
420 | return phb_free(phb, FALSE); |
---|
421 | } |
---|
422 | |
---|
423 | s5_sendconnect(phb, source); |
---|
424 | |
---|
425 | return FALSE; |
---|
426 | } |
---|
427 | |
---|
428 | static gboolean s5_canread(gpointer data, gint source, b_input_condition cond) |
---|
429 | { |
---|
430 | unsigned char buf[512]; |
---|
431 | struct PHB *phb = data; |
---|
432 | |
---|
433 | b_event_remove(phb->inpa); |
---|
434 | |
---|
435 | if (read(source, buf, 2) < 2) { |
---|
436 | return phb_free(phb, FALSE); |
---|
437 | } |
---|
438 | |
---|
439 | if ((buf[0] != 0x05) || (buf[1] == 0xff)) { |
---|
440 | return phb_free(phb, FALSE); |
---|
441 | } |
---|
442 | |
---|
443 | if (buf[1] == 0x02) { |
---|
444 | unsigned int i = strlen(proxyuser), j = strlen(proxypass); |
---|
445 | buf[0] = 0x01; /* version 1 */ |
---|
446 | buf[1] = i; |
---|
447 | memcpy(buf + 2, proxyuser, i); |
---|
448 | buf[2 + i] = j; |
---|
449 | memcpy(buf + 2 + i + 1, proxypass, j); |
---|
450 | if (write(source, buf, 3 + i + j) < 3 + i + j) { |
---|
451 | return phb_free(phb, FALSE); |
---|
452 | } |
---|
453 | |
---|
454 | phb->inpa = b_input_add(source, B_EV_IO_READ, s5_readauth, phb); |
---|
455 | } else { |
---|
456 | s5_sendconnect(phb, source); |
---|
457 | } |
---|
458 | |
---|
459 | return FALSE; |
---|
460 | } |
---|
461 | |
---|
462 | static gboolean s5_canwrite(gpointer data, gint source, b_input_condition cond) |
---|
463 | { |
---|
464 | unsigned char buf[512]; |
---|
465 | int i; |
---|
466 | struct PHB *phb = data; |
---|
467 | socklen_t len; |
---|
468 | int error = ETIMEDOUT; |
---|
469 | |
---|
470 | if (phb->inpa > 0) { |
---|
471 | b_event_remove(phb->inpa); |
---|
472 | } |
---|
473 | len = sizeof(error); |
---|
474 | if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { |
---|
475 | return phb_free(phb, FALSE); |
---|
476 | } |
---|
477 | sock_make_blocking(source); |
---|
478 | |
---|
479 | i = 0; |
---|
480 | buf[0] = 0x05; /* SOCKS version 5 */ |
---|
481 | if (proxyuser[0]) { |
---|
482 | buf[1] = 0x02; /* two methods */ |
---|
483 | buf[2] = 0x00; /* no authentication */ |
---|
484 | buf[3] = 0x02; /* username/password authentication */ |
---|
485 | i = 4; |
---|
486 | } else { |
---|
487 | buf[1] = 0x01; |
---|
488 | buf[2] = 0x00; |
---|
489 | i = 3; |
---|
490 | } |
---|
491 | |
---|
492 | if (write(source, buf, i) < i) { |
---|
493 | return phb_free(phb, FALSE); |
---|
494 | } |
---|
495 | |
---|
496 | phb->inpa = b_input_add(source, B_EV_IO_READ, s5_canread, phb); |
---|
497 | |
---|
498 | return FALSE; |
---|
499 | } |
---|
500 | |
---|
501 | static int proxy_connect_socks5(const char *host, unsigned short port, struct PHB *phb) |
---|
502 | { |
---|
503 | phb->host = g_strdup(host); |
---|
504 | phb->port = port; |
---|
505 | phb->proxy_func = s5_canwrite; |
---|
506 | phb->proxy_data = phb; |
---|
507 | |
---|
508 | return(proxy_connect_none(proxyhost, proxyport, phb)); |
---|
509 | } |
---|
510 | |
---|
511 | static const proxy_connect_func proxy_connect_funcs_array[] = { |
---|
512 | proxy_connect_none, /* PROXY_NONE */ |
---|
513 | proxy_connect_http, /* PROXY_HTTP */ |
---|
514 | proxy_connect_socks4, /* PROXY_SOCKS4 */ |
---|
515 | proxy_connect_socks5, /* PROXY_SOCKS5 */ |
---|
516 | proxy_connect_socks4, /* PROXY_SOCKS4A */ |
---|
517 | }; |
---|
518 | |
---|
519 | /* Export functions */ |
---|
520 | |
---|
521 | int proxy_connect(const char *host, int port, b_event_handler func, gpointer data) |
---|
522 | { |
---|
523 | struct PHB *phb; |
---|
524 | proxy_connect_func fun; |
---|
525 | |
---|
526 | if (!host || port <= 0 || !func || strlen(host) > 128) { |
---|
527 | return -1; |
---|
528 | } |
---|
529 | |
---|
530 | phb = g_new0(struct PHB, 1); |
---|
531 | phb->func = func; |
---|
532 | phb->data = data; |
---|
533 | |
---|
534 | if (proxyhost[0] && proxyport > 0 && proxytype >= 0 && proxytype <= G_N_ELEMENTS(proxy_connect_funcs_array)) { |
---|
535 | fun = proxy_connect_funcs_array[proxytype]; |
---|
536 | } else { |
---|
537 | fun = proxy_connect_none; |
---|
538 | } |
---|
539 | |
---|
540 | return fun(host, port, phb); |
---|
541 | } |
---|