14192
|
1 /**
|
15025
|
2 * @file qq_proxy.c
|
14192
|
3 *
|
15025
|
4 * gaim
|
14192
|
5 *
|
15025
|
6 * Gaim is the legal property of its developers, whose names are too numerous
|
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
8 * source distribution.
|
14192
|
9 *
|
|
10 * This program is free software; you can redistribute it and/or modify
|
|
11 * it under the terms of the GNU General Public License as published by
|
|
12 * the Free Software Foundation; either version 2 of the License, or
|
|
13 * (at your option) any later version.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this program; if not, write to the Free Software
|
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
23 */
|
|
24
|
|
25 #include "cipher.h"
|
|
26 #include "debug.h"
|
|
27 #include "internal.h"
|
|
28
|
|
29 #ifdef _WIN32
|
|
30 #define random rand
|
|
31 #define srandom srand
|
|
32 #endif
|
|
33
|
|
34 #include "packet_parse.h"
|
|
35 #include "buddy_info.h"
|
|
36 #include "buddy_opt.h"
|
|
37 #include "char_conv.h"
|
|
38 #include "group_free.h"
|
|
39 #include "login_logout.h"
|
|
40 #include "qq_proxy.h"
|
|
41 #include "recv_core.h"
|
|
42 #include "send_core.h"
|
|
43 #include "sendqueue.h"
|
|
44 #include "udp_proxy_s5.h"
|
|
45 #include "utils.h"
|
|
46
|
14195
|
47 /* These functions are used only in development phase */
|
|
48 /*
|
14192
|
49 static void _qq_show_socket(gchar *desc, gint fd) {
|
|
50 struct sockaddr_in sin;
|
14195
|
51 socklen_t len = sizeof(sin);
|
14192
|
52 getsockname(fd, (struct sockaddr *)&sin, &len);
|
|
53 gaim_debug(GAIM_DEBUG_INFO, desc, "%s:%d\n",
|
14610
|
54 inet_ntoa(sin.sin_addr), g_ntohs(sin.sin_port));
|
14192
|
55 }
|
|
56 */
|
|
57
|
|
58 void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len)
|
|
59 {
|
|
60 char buf1[8*len+2], buf2[10];
|
|
61 int i;
|
|
62 buf1[0] = 0;
|
|
63 for (i = 0; i < len; i++) {
|
|
64 sprintf(buf2, " %02x(%d)", buf[i] & 0xff, buf[i] & 0xff);
|
|
65 strcat(buf1, buf2);
|
|
66 }
|
|
67 strcat(buf1, "\n");
|
|
68 gaim_debug(GAIM_DEBUG_INFO, desc, buf1);
|
|
69 }
|
|
70
|
|
71 /* QQ 2003iii uses double MD5 for the pwkey to get the session key */
|
|
72 static guint8 *_gen_pwkey(const gchar *pwd)
|
|
73 {
|
|
74 GaimCipher *cipher;
|
|
75 GaimCipherContext *context;
|
|
76
|
|
77 guchar pwkey_tmp[QQ_KEY_LENGTH];
|
|
78
|
|
79 cipher = gaim_ciphers_find_cipher("md5");
|
|
80 context = gaim_cipher_context_new(cipher, NULL);
|
|
81 gaim_cipher_context_append(context, (guchar *) pwd, strlen(pwd));
|
|
82 gaim_cipher_context_digest(context, sizeof(pwkey_tmp), pwkey_tmp, NULL);
|
|
83 gaim_cipher_context_destroy(context);
|
|
84 context = gaim_cipher_context_new(cipher, NULL);
|
|
85 gaim_cipher_context_append(context, pwkey_tmp, QQ_KEY_LENGTH);
|
|
86 gaim_cipher_context_digest(context, sizeof(pwkey_tmp), pwkey_tmp, NULL);
|
|
87 gaim_cipher_context_destroy(context);
|
|
88
|
|
89 return g_memdup(pwkey_tmp, QQ_KEY_LENGTH);
|
|
90 }
|
|
91
|
14195
|
92 static gboolean _qq_fill_host(GSList *hosts, struct sockaddr_in *addr, gint *addr_size)
|
14192
|
93 {
|
14195
|
94 if (!hosts || !hosts->data)
|
|
95 return FALSE;
|
|
96
|
|
97 *addr_size = GPOINTER_TO_INT(hosts->data);
|
|
98
|
|
99 hosts = g_slist_remove(hosts, hosts->data);
|
|
100 memcpy(addr, hosts->data, *addr_size);
|
|
101 g_free(hosts->data);
|
|
102 hosts = g_slist_remove(hosts, hosts->data);
|
|
103 while(hosts) {
|
|
104 hosts = g_slist_remove(hosts, hosts->data);
|
|
105 g_free(hosts->data);
|
|
106 hosts = g_slist_remove(hosts, hosts->data);
|
14192
|
107 }
|
|
108
|
14195
|
109 return TRUE;
|
14192
|
110 }
|
|
111
|
|
112 /* set up any finalizing start-up stuff */
|
|
113 static void _qq_start_services(GaimConnection *gc)
|
|
114 {
|
|
115 /* start watching for IMs about to be sent */
|
|
116 /*
|
|
117 gaim_signal_connect(gaim_conversations_get_handle(),
|
|
118 "sending-im-msg", gc,
|
|
119 GAIM_CALLBACK(qq_sending_im_msg_cb), NULL);
|
|
120 */
|
|
121 }
|
|
122
|
|
123 /* the callback function after socket is built
|
|
124 * we setup the qq protocol related configuration here */
|
|
125 static void _qq_got_login(gpointer data, gint source, const gchar *error_message)
|
|
126 {
|
|
127 qq_data *qd;
|
|
128 GaimConnection *gc;
|
|
129 gchar *buf;
|
|
130 const gchar *passwd;
|
|
131
|
|
132 gc = (GaimConnection *) data;
|
|
133
|
|
134 if (!GAIM_CONNECTION_IS_VALID(gc)) {
|
|
135 close(source);
|
|
136 return;
|
|
137 }
|
|
138
|
|
139 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
140
|
|
141 if (source < 0) { /* socket returns -1 */
|
14195
|
142 gaim_connection_error(gc, error_message);
|
14192
|
143 return;
|
|
144 }
|
|
145
|
|
146 qd = (qq_data *) gc->proto_data;
|
|
147
|
14195
|
148 /*
|
|
149 _qq_show_socket("Got login socket", source);
|
|
150 */
|
|
151
|
14192
|
152 /* QQ use random seq, to minimize duplicated packets */
|
|
153 srandom(time(NULL));
|
|
154 qd->send_seq = random() & 0x0000ffff;
|
|
155 qd->fd = source;
|
|
156 qd->logged_in = FALSE;
|
|
157 qd->channel = 1;
|
|
158 qd->uid = strtol(gaim_account_get_username(gaim_connection_get_account(gc)), NULL, 10);
|
|
159 qd->before_login_packets = g_queue_new();
|
|
160
|
|
161 /* now generate md5 processed passwd */
|
|
162 passwd = gaim_account_get_password(gaim_connection_get_account(gc));
|
|
163 qd->pwkey = _gen_pwkey(passwd);
|
|
164
|
|
165 qd->sendqueue_timeout = gaim_timeout_add(QQ_SENDQUEUE_TIMEOUT, qq_sendqueue_timeout_callback, gc);
|
|
166 gc->inpa = gaim_input_add(qd->fd, GAIM_INPUT_READ, qq_input_pending, gc);
|
|
167
|
|
168 /* Update the login progress status display */
|
|
169 buf = g_strdup_printf("Login as %d", qd->uid);
|
|
170 gaim_connection_update_progress(gc, buf, 1, QQ_CONNECT_STEPS);
|
|
171 g_free(buf);
|
|
172
|
|
173 _qq_start_services(gc);
|
|
174
|
|
175 qq_send_packet_request_login_token(gc);
|
|
176 }
|
|
177
|
|
178 /* clean up qq_data structure and all its components
|
|
179 * always used before a redirectly connection */
|
|
180 static void _qq_common_clean(GaimConnection *gc)
|
|
181 {
|
|
182 qq_data *qd;
|
|
183
|
|
184 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
185 qd = (qq_data *) gc->proto_data;
|
|
186
|
|
187 /* finish all I/O */
|
|
188 if (qd->fd >= 0 && qd->logged_in)
|
|
189 qq_send_packet_logout(gc);
|
|
190 close(qd->fd);
|
|
191
|
|
192 if (qd->sendqueue_timeout > 0) {
|
|
193 gaim_timeout_remove(qd->sendqueue_timeout);
|
|
194 qd->sendqueue_timeout = 0;
|
|
195 }
|
|
196
|
|
197 if (gc->inpa > 0) {
|
|
198 gaim_input_remove(gc->inpa);
|
|
199 gc->inpa = 0;
|
|
200 }
|
|
201
|
|
202 qq_b4_packets_free(qd);
|
|
203 qq_sendqueue_free(qd);
|
|
204 qq_group_packets_free(qd);
|
|
205 qq_group_free_all(qd);
|
|
206 qq_add_buddy_request_free(qd);
|
|
207 qq_info_query_free(qd);
|
|
208 qq_buddies_list_free(gc->account, qd);
|
|
209 }
|
|
210
|
14195
|
211 static void no_one_calls(gpointer data, gint source, GaimInputCondition cond)
|
|
212 {
|
|
213 struct PHB *phb = data;
|
|
214 socklen_t len;
|
|
215 int error=0, ret;
|
|
216
|
|
217 gaim_debug_info("proxy", "Connected.\n");
|
|
218
|
|
219 len = sizeof(error);
|
|
220
|
|
221 /*
|
|
222 * getsockopt after a non-blocking connect returns -1 if something is
|
|
223 * really messed up (bad descriptor, usually). Otherwise, it returns 0 and
|
|
224 * error holds what connect would have returned if it blocked until now.
|
|
225 * Thus, error == 0 is success, error == EINPROGRESS means "try again",
|
|
226 * and anything else is a real error.
|
|
227 *
|
|
228 * (error == EINPROGRESS can happen after a select because the kernel can
|
|
229 * be overly optimistic sometimes. select is just a hint that you might be
|
|
230 * able to do something.)
|
|
231 */
|
|
232 ret = getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len);
|
|
233 if (ret == 0 && error == EINPROGRESS)
|
|
234 return; /* we'll be called again later */
|
|
235 if (ret < 0 || error != 0) {
|
|
236 if(ret!=0)
|
|
237 error = errno;
|
|
238 close(source);
|
|
239 gaim_input_remove(phb->inpa);
|
|
240
|
|
241 gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error));
|
|
242
|
|
243 phb->func(phb->data, -1, _("Unable to connect"));
|
|
244 return;
|
|
245 }
|
|
246
|
|
247 gaim_input_remove(phb->inpa);
|
|
248
|
|
249 if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) {
|
|
250
|
|
251 phb->func(phb->data, source, NULL);
|
|
252 }
|
|
253
|
|
254 g_free(phb->host);
|
|
255 g_free(phb);
|
|
256 }
|
|
257
|
|
258 /* returns -1 if fails, otherwise returns the file handle */
|
14192
|
259 static gint _qq_proxy_none(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen)
|
|
260 {
|
|
261 gint fd = -1;
|
|
262
|
|
263 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Using UDP without proxy\n");
|
|
264 fd = socket(PF_INET, SOCK_DGRAM, 0);
|
|
265
|
|
266 if (fd < 0) {
|
14195
|
267 gaim_debug(GAIM_DEBUG_ERROR, "QQ Redirect",
|
|
268 "Unable to create socket: %s\n", strerror(errno));
|
14192
|
269 return -1;
|
|
270 }
|
|
271
|
|
272 /* we use non-blocking mode to speed up connection */
|
|
273 fcntl(fd, F_SETFL, O_NONBLOCK);
|
|
274
|
|
275 /* From Unix-socket-FAQ: http://www.faqs.org/faqs/unix-faq/socket/
|
|
276 *
|
|
277 * If a UDP socket is unconnected, which is the normal state after a
|
|
278 * bind() call, then send() or write() are not allowed, since no
|
|
279 * destination is available; only sendto() can be used to send data.
|
|
280 *
|
|
281 * Calling connect() on the socket simply records the specified address
|
|
282 * and port number as being the desired communications partner. That
|
|
283 * means that send() or write() are now allowed; they use the destination
|
|
284 * address and port given on the connect call as the destination of packets.
|
|
285 */
|
|
286 if (connect(fd, addr, addrlen) < 0) {
|
|
287 /* [EINPROGRESS]
|
|
288 * The socket is marked as non-blocking and the connection cannot be
|
|
289 * completed immediately. It is possible to select for completion by
|
|
290 * selecting the socket for writing.
|
|
291 * [EINTR]
|
|
292 * A signal interrupted the call.
|
|
293 * The connection is established asynchronously.
|
|
294 */
|
|
295 if ((errno == EINPROGRESS) || (errno == EINTR)) {
|
|
296 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Connect in asynchronous mode.\n");
|
14195
|
297 phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb);
|
14192
|
298 } else {
|
14195
|
299 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Connection failed: %d\n", strerror(errno));
|
14192
|
300 close(fd);
|
|
301 return -1;
|
|
302 } /* if errno */
|
|
303 } else { /* connect returns 0 */
|
|
304 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Connected.\n");
|
|
305 fcntl(fd, F_SETFL, 0);
|
|
306 phb->func(phb->data, fd, NULL);
|
|
307 }
|
|
308
|
|
309 return fd;
|
|
310 }
|
|
311
|
14195
|
312 static void _qq_proxy_resolved(GSList *hosts, gpointer data, const char *error_message)
|
|
313 {
|
|
314 struct PHB *phb = (struct PHB *) data;
|
|
315 struct sockaddr_in addr;
|
|
316 gint addr_size, ret = -1;
|
|
317
|
|
318 if(_qq_fill_host(hosts, &addr, &addr_size))
|
|
319 ret = qq_proxy_socks5(phb, (struct sockaddr *) &addr, addr_size);
|
|
320
|
|
321 if (ret < 0) {
|
|
322 phb->func(phb->data, -1, _("Unable to connect"));
|
|
323 g_free(phb->host);
|
|
324 g_free(phb);
|
|
325 }
|
|
326 }
|
|
327
|
|
328 static void _qq_server_resolved(GSList *hosts, gpointer data, const char *error_message)
|
|
329 {
|
|
330 struct PHB *phb = (struct PHB *) data;
|
|
331 GaimConnection *gc = (GaimConnection *) phb->data;
|
|
332 qq_data *qd = (qq_data *) gc->proto_data;
|
|
333 struct sockaddr_in addr;
|
|
334 gint addr_size, ret = -1;
|
|
335
|
|
336 if(_qq_fill_host(hosts, &addr, &addr_size)) {
|
|
337 switch (gaim_proxy_info_get_type(phb->gpi)) {
|
|
338 case GAIM_PROXY_NONE:
|
|
339 ret = _qq_proxy_none(phb, (struct sockaddr *) &addr, addr_size);
|
|
340 break;
|
|
341 case GAIM_PROXY_SOCKS5:
|
|
342 ret = 0;
|
|
343 if (gaim_proxy_info_get_host(phb->gpi) == NULL ||
|
|
344 gaim_proxy_info_get_port(phb->gpi) == 0) {
|
|
345 gaim_debug(GAIM_DEBUG_ERROR, "QQ",
|
|
346 "Use of socks5 proxy selected but host or port info doesn't exist.\n");
|
|
347 ret = -1;
|
|
348 } else {
|
|
349 /* as the destination is always QQ server during the session,
|
|
350 * we can set dest_sin here, instead of _qq_s5_canread_again */
|
|
351 memcpy(&qd->dest_sin, &addr, addr_size);
|
|
352 if (gaim_dnsquery_a(gaim_proxy_info_get_host(phb->gpi),
|
|
353 gaim_proxy_info_get_port(phb->gpi),
|
|
354 _qq_proxy_resolved, phb) == NULL)
|
|
355 ret = -1;
|
|
356 }
|
|
357 break;
|
|
358 default:
|
|
359 gaim_debug(GAIM_DEBUG_WARNING, "QQ",
|
|
360 "Proxy type %i is unsupported, not using a proxy.\n",
|
|
361 gaim_proxy_info_get_type(phb->gpi));
|
|
362 ret = _qq_proxy_none(phb, (struct sockaddr *) &addr, addr_size);
|
|
363 }
|
|
364 }
|
|
365
|
|
366 if (ret < 0) {
|
|
367 phb->func(gc, -1, _("Unable to connect"));
|
|
368 g_free(phb->host);
|
|
369 g_free(phb);
|
|
370 }
|
|
371 }
|
|
372
|
|
373 /* returns -1 if dns lookup fails, otherwise returns 0 */
|
14192
|
374 static gint _qq_udp_proxy_connect(GaimAccount *account,
|
14195
|
375 const gchar *server, guint16 port,
|
|
376 void callback(gpointer, gint, const gchar *error_message),
|
|
377 GaimConnection *gc)
|
14192
|
378 {
|
14195
|
379 GaimProxyInfo *info;
|
14192
|
380 struct PHB *phb;
|
14195
|
381 qq_data *qd = (qq_data *) gc->proto_data;
|
14192
|
382
|
14195
|
383 g_return_val_if_fail(gc != NULL && qd != NULL, -1);
|
14192
|
384
|
14195
|
385 info = gaim_proxy_get_setup(account);
|
14192
|
386
|
|
387 phb = g_new0(struct PHB, 1);
|
|
388 phb->host = g_strdup(server);
|
|
389 phb->port = port;
|
|
390 phb->account = account;
|
|
391 phb->gpi = info;
|
|
392 phb->func = callback;
|
|
393 phb->data = gc;
|
14195
|
394 qd->proxy_type = gaim_proxy_info_get_type(phb->gpi);
|
14192
|
395
|
14195
|
396 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Choosing proxy type %d\n",
|
|
397 gaim_proxy_info_get_type(phb->gpi));
|
14192
|
398
|
14195
|
399 if (gaim_dnsquery_a(server, port, _qq_server_resolved, phb) == NULL) {
|
|
400 phb->func(gc, -1, _("Unable to connect"));
|
|
401 g_free(phb->host);
|
|
402 g_free(phb);
|
|
403 return -1;
|
|
404 } else {
|
|
405 return 0;
|
14192
|
406 }
|
|
407 }
|
|
408
|
|
409 /* QQ connection via UDP/TCP.
|
14195
|
410 * I use Gaim proxy function to provide TCP proxy support,
|
|
411 * and qq_udp_proxy.c to add UDP proxy support (thanks henry) */
|
14192
|
412 static gint _proxy_connect_full (GaimAccount *account, const gchar *host, guint16 port,
|
|
413 GaimProxyConnectFunction func, gpointer data, gboolean use_tcp)
|
|
414 {
|
|
415 GaimConnection *gc;
|
|
416 qq_data *qd;
|
|
417
|
|
418 gc = gaim_account_get_connection(account);
|
|
419 qd = (qq_data *) gc->proto_data;
|
|
420 qd->server_ip = g_strdup(host);
|
|
421 qd->server_port = port;
|
|
422
|
14195
|
423 if(use_tcp)
|
14837
|
424 return (gaim_proxy_connect(NULL, account, host, port, func, data) == NULL);
|
14192
|
425 else
|
|
426 return _qq_udp_proxy_connect(account, host, port, func, data);
|
|
427 }
|
|
428
|
|
429 /* establish a generic QQ connection
|
14195
|
430 * TCP/UDP, and direct/redirected */
|
|
431 gint qq_connect(GaimAccount *account, const gchar *host, guint16 port,
|
|
432 gboolean use_tcp, gboolean is_redirect)
|
14192
|
433 {
|
|
434 GaimConnection *gc;
|
|
435
|
|
436 g_return_val_if_fail(host != NULL, -1);
|
|
437 g_return_val_if_fail(port > 0, -1);
|
|
438
|
|
439 gc = gaim_account_get_connection(account);
|
|
440 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, -1);
|
|
441
|
|
442 if (is_redirect)
|
|
443 _qq_common_clean(gc);
|
|
444
|
|
445 return _proxy_connect_full(account, host, port, _qq_got_login, gc, use_tcp);
|
|
446 }
|
|
447
|
|
448 /* clean up the given QQ connection and free all resources */
|
|
449 void qq_disconnect(GaimConnection *gc)
|
|
450 {
|
|
451 qq_data *qd;
|
|
452
|
|
453 g_return_if_fail(gc != NULL);
|
|
454
|
|
455 _qq_common_clean(gc);
|
|
456
|
|
457 qd = gc->proto_data;
|
|
458 g_free(qd->inikey);
|
|
459 g_free(qd->pwkey);
|
|
460 g_free(qd->session_key);
|
14632
|
461 g_free(qd->session_md5);
|
14192
|
462 g_free(qd->my_ip);
|
|
463 g_free(qd);
|
|
464
|
|
465 gc->proto_data = NULL;
|
|
466 }
|
|
467
|
|
468 /* send packet with proxy support */
|
|
469 gint qq_proxy_write(qq_data *qd, guint8 *data, gint len)
|
|
470 {
|
|
471 guint8 *buf;
|
|
472 gint ret;
|
|
473
|
|
474 g_return_val_if_fail(qd != NULL && qd->fd >= 0 && data != NULL && len > 0, -1);
|
|
475
|
|
476 /* TCP sock5 may be processed twice
|
|
477 * so we need to check qd->use_tcp as well */
|
|
478 if ((!qd->use_tcp) && qd->proxy_type == GAIM_PROXY_SOCKS5) { /* UDP sock5 */
|
|
479 buf = g_newa(guint8, len + 10);
|
|
480 buf[0] = 0x00;
|
|
481 buf[1] = 0x00; /* reserved */
|
|
482 buf[2] = 0x00; /* frag */
|
|
483 buf[3] = 0x01; /* type */
|
|
484 g_memmove(buf + 4, &(qd->dest_sin.sin_addr.s_addr), 4);
|
|
485 g_memmove(buf + 8, &(qd->dest_sin.sin_port), 2);
|
|
486 g_memmove(buf + 10, data, len);
|
14195
|
487 errno = 0;
|
14192
|
488 ret = send(qd->fd, buf, len + 10, 0);
|
|
489 } else {
|
14195
|
490 errno = 0;
|
14192
|
491 ret = send(qd->fd, data, len, 0);
|
|
492 }
|
14195
|
493 if (ret == -1) {
|
|
494 gaim_connection_error(qd->gc, _("Socket send error"));
|
|
495 return ret;
|
|
496 } else if (errno == ECONNREFUSED) {
|
|
497 gaim_connection_error(qd->gc, _("Connection refused"));
|
|
498 return ret;
|
|
499 }
|
14192
|
500
|
|
501 return ret;
|
|
502 }
|
|
503
|
|
504 /* read packet input with proxy support */
|
|
505 gint qq_proxy_read(qq_data *qd, guint8 *data, gint len)
|
|
506 {
|
|
507 guint8 *buf;
|
|
508 gint bytes;
|
|
509 buf = g_newa(guint8, MAX_PACKET_SIZE + 10);
|
|
510
|
|
511 g_return_val_if_fail(qd != NULL && data != NULL && len > 0, -1);
|
|
512 g_return_val_if_fail(qd->fd > 0, -1);
|
|
513
|
|
514 bytes = read(qd->fd, buf, len + 10);
|
|
515 if (bytes < 0)
|
|
516 return -1;
|
|
517
|
|
518 if ((!qd->use_tcp) && qd->proxy_type == GAIM_PROXY_SOCKS5) { /* UDP sock5 */
|
|
519 if (bytes < 10)
|
|
520 return -1;
|
|
521 bytes -= 10;
|
|
522 g_memmove(data, buf + 10, bytes); /* cut off the header */
|
|
523 } else {
|
|
524 g_memmove(data, buf, bytes);
|
|
525 }
|
|
526
|
|
527 return bytes;
|
|
528 }
|