211
211
purple_gnome_proxy_get_info(void)
213
213
static PurpleProxyInfo info = {0, NULL, 0, NULL, NULL};
215
if ((path = g_find_program_in_path("gconftool-2"))) {
220
/* See whether to use a proxy. */
221
if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode", &tmp,
223
return purple_global_proxy_get_info();
224
if (!strcmp(tmp, "none\n")) {
225
info.type = PURPLE_PROXY_NONE;
228
} else if (strcmp(tmp, "manual\n")) {
230
return purple_global_proxy_get_info();
234
info.type = PURPLE_PROXY_HTTP;
236
/* Free the old fields */
242
g_free(info.username);
243
info.username = NULL;
246
g_free(info.password);
247
info.password = NULL;
250
/* Get the new ones */
251
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host", &info.host,
253
return purple_global_proxy_get_info();
254
g_strchomp(info.host);
256
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user", &info.username,
258
return purple_global_proxy_get_info();
259
g_strchomp(info.username);
261
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password", &info.password,
263
return purple_global_proxy_get_info();
264
g_strchomp(info.password);
266
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port", &tmp,
268
return purple_global_proxy_get_info();
269
info.port = atoi(tmp);
216
tmp = g_find_program_in_path("gconftool-2");
218
return purple_global_proxy_get_info();
222
/* Check whether to use a proxy. */
223
if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode",
224
&tmp, NULL, NULL, NULL))
225
return purple_global_proxy_get_info();
227
if (!strcmp(tmp, "none\n")) {
228
info.type = PURPLE_PROXY_NONE;
274
return purple_global_proxy_get_info();
233
if (strcmp(tmp, "manual\n")) {
234
/* Unknown setting. Fallback to using our global proxy settings. */
236
return purple_global_proxy_get_info();
241
/* If we get this far then we know we're using an HTTP proxy */
242
info.type = PURPLE_PROXY_HTTP;
244
/* Free the old fields */
250
g_free(info.username);
251
info.username = NULL;
254
g_free(info.password);
255
info.password = NULL;
258
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host",
259
&info.host, NULL, NULL, NULL))
260
return purple_global_proxy_get_info();
261
g_strchomp(info.host);
262
if (*info.host == '\0')
264
purple_debug_info("proxy", "Gnome proxy settings are set to "
265
"'manual' but no proxy server is specified. Using "
266
"Pidgin's proxy settings instead.\n");
268
return purple_global_proxy_get_info();
271
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user",
272
&info.username, NULL, NULL, NULL))
275
return purple_global_proxy_get_info();
277
g_strchomp(info.username);
279
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password",
280
&info.password, NULL, NULL, NULL))
283
g_free(info.username);
284
return purple_global_proxy_get_info();
286
g_strchomp(info.password);
288
if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port",
289
&tmp, NULL, NULL, NULL))
292
g_free(info.username);
293
g_free(info.password);
294
return purple_global_proxy_get_info();
296
info.port = atoi(tmp);
276
301
/**************************************************************************
1101
1126
if(connect_data->read_len < len) {
1102
1127
if(connect_data->read_buf_len < len) {
1103
1128
/* it's not just that we haven't read enough, it's that we haven't tried to read enough yet */
1104
purple_debug_info("s5", "reallocing from %d to %d\n", connect_data->read_buf_len, len);
1129
purple_debug_info("s5", "reallocing from %" G_GSIZE_FORMAT
1130
" to %d\n", connect_data->read_buf_len, len);
1105
1131
connect_data->read_buf_len = len;
1106
1132
connect_data->read_buffer = g_realloc(connect_data->read_buffer, connect_data->read_buf_len);
1330
1356
purple_debug(PURPLE_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n");
1332
1358
if (connect_data->read_buffer == NULL) {
1333
connect_data->read_buf_len = 20;
1359
/* A big enough butfer to read the message header (2 bytes) and at least one complete attribute and value (1 + 1 + 255). */
1360
connect_data->read_buf_len = 259;
1334
1361
connect_data->read_buffer = g_malloc(connect_data->read_buf_len);
1335
1362
connect_data->read_len = 0;
1365
if (connect_data->read_buf_len - connect_data->read_len == 0) {
1366
/*If the stuff below is right, this shouldn't be possible. */
1367
purple_debug_error("socks5 proxy", "This is about to suck because the read buffer is full (shouldn't happen).\n");
1338
1370
len = read(connect_data->fd, connect_data->read_buffer + connect_data->read_len,
1339
1371
connect_data->read_buf_len - connect_data->read_len);
1376
1408
for (currentav = 0; currentav < navas; currentav++) {
1377
if (connect_data->read_len - (cmdbuf - connect_data->read_buffer) < 2)
1379
if (connect_data->read_len - (cmdbuf - connect_data->read_buffer) < cmdbuf[1])
1410
len = connect_data->read_len - (cmdbuf - connect_data->read_buffer);
1411
/* We don't have enough data to even know how long the next attribute is,
1412
* or we don't have the full length of the next attribute. */
1413
if (len < 2 || len < (cmdbuf[1] + 2)) {
1414
/* Clear out the attributes that have been read - decrease the attribute count */
1415
connect_data->read_buffer[1] = navas - currentav;
1416
/* Move the unprocessed data into the first attribute position */
1417
memmove((connect_data->read_buffer + 2), cmdbuf, len);
1418
/* Decrease the read count accordingly */
1419
connect_data->read_len = len + 2;
1381
1423
buf = cmdbuf + 2;
1425
if (cmdbuf[1] == 0) {
1426
purple_debug_error("socks5 proxy", "Attribute %x Value length of 0; ignoring.\n", cmdbuf[0]);
1382
1431
switch (cmdbuf[0]) {
1433
purple_debug_info("socks5 proxy", "Received STATUS of %x\n", buf[0]);
1384
1434
/* Did auth work? */
1385
1435
if (buf[0] == 0x00) {
1386
1436
purple_input_remove(connect_data->inpa);
1495
purple_debug_info("socks5 proxy", "Received unused command %x, length=%d\n", cmdbuf[0], cmdbuf[1]);
1445
1497
cmdbuf = buf + cmdbuf[1];
1447
1500
/* Fell through. We ran out of CHAP events to process, but haven't
1448
1501
* succeeded or failed authentication - there may be more to come.
1449
1502
* If this is the case, come straight back here. */
1504
/* We've processed all the available attributes, so get ready for a whole new message */
1505
g_free(connect_data->read_buffer);
1506
connect_data->read_buffer = NULL;