|
|
|
@ -330,15 +330,16 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
@@ -330,15 +330,16 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
|
|
|
|
|
|
|
|
|
|
#define DCC_USE_PROXY() (prefs.hex_net_proxy_host[0] && prefs.hex_net_proxy_type>0 && prefs.hex_net_proxy_type<5 && prefs.hex_net_proxy_use!=1) |
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
static void |
|
|
|
|
dcc_connect_sok (struct DCC *dcc) |
|
|
|
|
{ |
|
|
|
|
int sok; |
|
|
|
|
struct sockaddr_in addr; |
|
|
|
|
|
|
|
|
|
sok = socket (AF_INET, SOCK_STREAM, 0); |
|
|
|
|
if (sok == -1) |
|
|
|
|
return -1; |
|
|
|
|
dcc->sok = socket(AF_INET, SOCK_STREAM, 0); |
|
|
|
|
if (dcc->sok == -1) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memset (&addr, 0, sizeof (addr)); |
|
|
|
|
addr.sin_family = AF_INET; |
|
|
|
@ -346,8 +347,9 @@ dcc_connect_sok (struct DCC *dcc)
@@ -346,8 +347,9 @@ dcc_connect_sok (struct DCC *dcc)
|
|
|
|
|
{ |
|
|
|
|
if (!dcc_lookup_proxy (prefs.hex_net_proxy_host, &addr)) |
|
|
|
|
{ |
|
|
|
|
closesocket (sok); |
|
|
|
|
return -1; |
|
|
|
|
closesocket (dcc->sok); |
|
|
|
|
dcc->sok = - 1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
addr.sin_port = htons (prefs.hex_net_proxy_port); |
|
|
|
|
} |
|
|
|
@ -357,10 +359,14 @@ dcc_connect_sok (struct DCC *dcc)
@@ -357,10 +359,14 @@ dcc_connect_sok (struct DCC *dcc)
|
|
|
|
|
addr.sin_addr.s_addr = htonl (dcc->addr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
set_nonblocking (sok); |
|
|
|
|
connect (sok, (struct sockaddr *) &addr, sizeof (addr)); |
|
|
|
|
set_nonblocking (dcc->sok); |
|
|
|
|
connect (dcc->sok, (struct sockaddr *) &addr, sizeof (addr)); |
|
|
|
|
|
|
|
|
|
return sok; |
|
|
|
|
#ifdef WIN32 |
|
|
|
|
dcc->channel = g_io_channel_win32_new_socket (dcc->sok); |
|
|
|
|
#else |
|
|
|
|
dcc->channel = g_io_channel_unix_new (dcc->sok); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -368,16 +374,22 @@ dcc_close (struct DCC *dcc, int dccstat, int destroy)
@@ -368,16 +374,22 @@ dcc_close (struct DCC *dcc, int dccstat, int destroy)
|
|
|
|
|
{ |
|
|
|
|
if (dcc->wiotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dcc->iotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dcc->channel != NULL) |
|
|
|
|
{ |
|
|
|
|
g_io_channel_unref (dcc->channel); |
|
|
|
|
dcc->channel = NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dcc->sok != -1) |
|
|
|
|
{ |
|
|
|
|
closesocket (dcc->sok); |
|
|
|
@ -609,13 +621,15 @@ dcc_read_chat (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
@@ -609,13 +621,15 @@ dcc_read_chat (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
|
|
|
|
{ |
|
|
|
|
if (dcc->throttled) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!dcc->iotag) |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc); |
|
|
|
|
{ |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read_chat, dcc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
len = recv (dcc->sok, lbuf, sizeof (lbuf) - 2, 0); |
|
|
|
|
if (len < 1) |
|
|
|
@ -748,13 +762,15 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
@@ -748,13 +762,15 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
|
|
|
|
if (need_ack) |
|
|
|
|
dcc_send_ack (dcc); |
|
|
|
|
|
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!dcc->iotag) |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read, dcc); |
|
|
|
|
{ |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read, dcc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
n = recv (dcc->sok, buf, sizeof (buf), 0); |
|
|
|
|
if (n < 1) |
|
|
|
@ -868,7 +884,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
@@ -868,7 +884,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
|
|
|
|
|
|
|
|
|
|
if (dcc->iotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -881,24 +897,22 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
@@ -881,24 +897,22 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
|
|
|
|
|
switch (dcc->type) |
|
|
|
|
{ |
|
|
|
|
case TYPE_RECV: |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read, dcc); |
|
|
|
|
EMIT_SIGNAL (XP_TE_DCCCONRECV, dcc->serv->front_session, |
|
|
|
|
dcc->nick, host, dcc->file, NULL, 0); |
|
|
|
|
break; |
|
|
|
|
case TYPE_SEND: |
|
|
|
|
/* passive send */ |
|
|
|
|
dcc->fastsend = prefs.hex_dcc_fast_send; |
|
|
|
|
if (dcc->fastsend) |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE, dcc_send_data, dcc); |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_ack, dcc); |
|
|
|
|
dcc_send_data (NULL, 0, (gpointer)dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read_ack, dcc); |
|
|
|
|
dcc_send_data (NULL, 0, (gpointer) dcc); |
|
|
|
|
EMIT_SIGNAL (XP_TE_DCCCONSEND, dcc->serv->front_session, |
|
|
|
|
dcc->nick, host, dcc->file, NULL, 0); |
|
|
|
|
break; |
|
|
|
|
case TYPE_CHATSEND: /* pchat */ |
|
|
|
|
dcc_open_query (dcc->serv, dcc->nick); |
|
|
|
|
case TYPE_CHATRECV: /* normal chat */ |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read_chat, dcc); |
|
|
|
|
dcc->dccchat = malloc (sizeof (struct dcc_chat)); |
|
|
|
|
dcc->dccchat->pos = 0; |
|
|
|
|
EMIT_SIGNAL (XP_TE_DCCCONCHAT, dcc->serv->front_session, |
|
|
|
@ -932,7 +946,7 @@ read_proxy (struct DCC *dcc)
@@ -932,7 +946,7 @@ read_proxy (struct DCC *dcc)
|
|
|
|
|
fe_dcc_update (dcc); |
|
|
|
|
if (dcc->iotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
} |
|
|
|
|
return FALSE; |
|
|
|
@ -962,7 +976,7 @@ write_proxy (struct DCC *dcc)
@@ -962,7 +976,7 @@ write_proxy (struct DCC *dcc)
|
|
|
|
|
fe_dcc_update (dcc); |
|
|
|
|
if (dcc->wiotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
} |
|
|
|
|
return FALSE; |
|
|
|
@ -1000,15 +1014,14 @@ dcc_wingate_proxy_traverse (GIOChannel *source, GIOCondition condition, struct D
@@ -1000,15 +1014,14 @@ dcc_wingate_proxy_traverse (GIOChannel *source, GIOCondition condition, struct D
|
|
|
|
|
"%s %d\r\n", net_ip(dcc->addr), |
|
|
|
|
dcc->port); |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, |
|
|
|
|
dcc_wingate_proxy_traverse, dcc); |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_wingate_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
if (proxy->phase == 1) |
|
|
|
|
{ |
|
|
|
|
if (!read_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
dcc_connect_finished (source, 0, dcc); |
|
|
|
|
} |
|
|
|
@ -1039,8 +1052,7 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1039,8 +1052,7 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
memcpy (proxy->buffer, &sc, sizeof (sc)); |
|
|
|
|
proxy->buffersize = 8 + strlen (sc.username) + 1; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, |
|
|
|
|
dcc_socks_proxy_traverse, dcc); |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_socks_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1048,12 +1060,11 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1048,12 +1060,11 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
{ |
|
|
|
|
if (!write_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
proxy->buffersize = 8; |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, |
|
|
|
|
dcc_socks_proxy_traverse, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_socks_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1061,7 +1072,7 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1061,7 +1072,7 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
{ |
|
|
|
|
if (!read_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
if (proxy->buffer[1] == 90) |
|
|
|
|
dcc_connect_finished (source, 0, dcc); |
|
|
|
@ -1099,8 +1110,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1099,8 +1110,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
memcpy (proxy->buffer, &sc1, 3); |
|
|
|
|
proxy->buffersize = 3; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, |
|
|
|
|
dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1108,12 +1118,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1108,12 +1118,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
{ |
|
|
|
|
if (!write_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
proxy->buffersize = 2; |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, |
|
|
|
|
dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1121,7 +1130,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1121,7 +1130,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
{ |
|
|
|
|
if (!read_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
|
|
|
|
|
/* did the server say no auth required? */ |
|
|
|
@ -1155,8 +1164,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1155,8 +1164,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
|
|
|
|
|
proxy->buffersize = 3 + len_u + len_p; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, |
|
|
|
|
dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -1176,12 +1184,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1176,12 +1184,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
{ |
|
|
|
|
if (!write_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
proxy->buffersize = 2; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, |
|
|
|
|
dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1191,7 +1198,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1191,7 +1198,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
return TRUE; |
|
|
|
|
if (dcc->iotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
} |
|
|
|
|
if (proxy->buffer[1] != 0) |
|
|
|
@ -1219,8 +1226,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1219,8 +1226,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
proxy->buffer[9] = (dcc->port & 0xFF); |
|
|
|
|
proxy->buffersize = 10; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, |
|
|
|
|
dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1228,12 +1234,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1228,12 +1234,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
{ |
|
|
|
|
if (!write_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
proxy->buffersize = 4; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, |
|
|
|
|
dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_socks5_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1243,7 +1248,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1243,7 +1248,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
return TRUE; |
|
|
|
|
if (proxy->buffer[0] != 5 || proxy->buffer[1] != 0) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
if (proxy->buffer[1] == 2) |
|
|
|
|
PrintText (dcc->serv->front_session, "SOCKS\tProxy refused to connect to host (not allowed).\n"); |
|
|
|
@ -1274,7 +1279,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
@@ -1274,7 +1279,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
|
|
|
|
|
/* everything done? */ |
|
|
|
|
if (proxy->bufferused == proxy->buffersize) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
dcc_connect_finished (source, 0, dcc); |
|
|
|
|
} |
|
|
|
@ -1307,8 +1312,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1307,8 +1312,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
proxy->buffersize = n; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
memcpy (proxy->buffer, buf, proxy->buffersize); |
|
|
|
|
dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, |
|
|
|
|
dcc_http_proxy_traverse, dcc); |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_http_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1316,11 +1320,10 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1316,11 +1320,10 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
{ |
|
|
|
|
if (!write_proxy (dcc)) |
|
|
|
|
return TRUE; |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
proxy->bufferused = 0; |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, |
|
|
|
|
dcc_http_proxy_traverse, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_http_proxy_traverse, dcc); |
|
|
|
|
++proxy->phase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1332,7 +1335,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1332,7 +1335,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
if (proxy->bufferused < 12 || |
|
|
|
|
memcmp (proxy->buffer, "HTTP/", 5) || memcmp (proxy->buffer + 9, "200", 3)) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
PrintText (dcc->serv->front_session, proxy->buffer); |
|
|
|
|
dcc->dccstat = STAT_FAILED; |
|
|
|
@ -1362,7 +1365,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1362,7 +1365,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
else |
|
|
|
|
return TRUE; |
|
|
|
|
} |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
dcc_connect_finished (source, 0, dcc); |
|
|
|
|
} |
|
|
|
@ -1373,7 +1376,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
@@ -1373,7 +1376,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
|
|
|
|
|
static gboolean |
|
|
|
|
dcc_proxy_connect (GIOChannel *source, GIOCondition condition, struct DCC *dcc) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
|
|
|
|
|
if (!dcc_did_connect (source, condition, dcc)) |
|
|
|
@ -1432,7 +1435,7 @@ dcc_connect (struct DCC *dcc)
@@ -1432,7 +1435,7 @@ dcc_connect (struct DCC *dcc)
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
dcc->sok = dcc_connect_sok (dcc); |
|
|
|
|
dcc_connect_sok (dcc); |
|
|
|
|
if (dcc->sok == -1) |
|
|
|
|
{ |
|
|
|
|
dcc->dccstat = STAT_FAILED; |
|
|
|
@ -1440,9 +1443,13 @@ dcc_connect (struct DCC *dcc)
@@ -1440,9 +1443,13 @@ dcc_connect (struct DCC *dcc)
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (DCC_USE_PROXY ()) |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, dcc_proxy_connect, dcc); |
|
|
|
|
{ |
|
|
|
|
g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_proxy_connect, dcc); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, dcc_connect_finished, dcc); |
|
|
|
|
{ |
|
|
|
|
g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR | G_IO_PRI, dcc_connect_finished, dcc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fe_dcc_update (dcc); |
|
|
|
@ -1462,7 +1469,7 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
@@ -1462,7 +1469,7 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
|
|
|
|
|
|
|
|
|
if (dcc->throttled) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
@ -1472,8 +1479,6 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
@@ -1472,8 +1479,6 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
|
|
|
|
if (dcc->ack < (dcc->pos & 0xFFFFFFFF)) |
|
|
|
|
return TRUE; |
|
|
|
|
} |
|
|
|
|
else if (!dcc->wiotag) |
|
|
|
|
dcc->wiotag = fe_input_add (sok, FIA_WRITE, dcc_send_data, dcc); |
|
|
|
|
|
|
|
|
|
buf = malloc (prefs.hex_dcc_blocksize); |
|
|
|
|
if (!buf) |
|
|
|
@ -1501,13 +1506,18 @@ abortit:
@@ -1501,13 +1506,18 @@ abortit:
|
|
|
|
|
dcc->lasttime = time (0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* have we sent it all yet? */ |
|
|
|
|
if (dcc->pos >= dcc->size) |
|
|
|
|
if (dcc->pos < dcc->size) |
|
|
|
|
{ |
|
|
|
|
if (!dcc->wiotag) |
|
|
|
|
{ |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_HUP | G_IO_ERR, dcc_send_data, dcc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
/* it's all sent now, so remove the WRITE/SEND handler */ |
|
|
|
|
if (dcc->wiotag) |
|
|
|
|
{ |
|
|
|
|
fe_input_remove (dcc->wiotag); |
|
|
|
|
g_source_remove (dcc->wiotag); |
|
|
|
|
dcc->wiotag = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1606,7 +1616,7 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
@@ -1606,7 +1616,7 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
|
|
|
|
|
|
|
|
|
len = sizeof (CAddr); |
|
|
|
|
sok = accept (dcc->sok, (struct sockaddr *) &CAddr, &len); |
|
|
|
|
fe_input_remove (dcc->iotag); |
|
|
|
|
g_source_remove (dcc->iotag); |
|
|
|
|
dcc->iotag = 0; |
|
|
|
|
closesocket (dcc->sok); |
|
|
|
|
if (sok < 0) |
|
|
|
@ -1632,16 +1642,18 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
@@ -1632,16 +1642,18 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
|
|
|
|
{ |
|
|
|
|
case TYPE_SEND: |
|
|
|
|
if (dcc->fastsend) |
|
|
|
|
dcc->wiotag = fe_input_add (sok, FIA_WRITE, dcc_send_data, dcc); |
|
|
|
|
dcc->iotag = fe_input_add (sok, FIA_READ|FIA_EX, dcc_read_ack, dcc); |
|
|
|
|
dcc_send_data (NULL, 0, (gpointer)dcc); |
|
|
|
|
{ |
|
|
|
|
dcc->wiotag = g_io_add_watch (dcc->channel, G_IO_OUT | G_IO_ERR, dcc_send_data, dcc); |
|
|
|
|
} |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read_ack, dcc); |
|
|
|
|
dcc_send_data (NULL, 0, (gpointer) dcc); |
|
|
|
|
EMIT_SIGNAL (XP_TE_DCCCONSEND, dcc->serv->front_session, |
|
|
|
|
dcc->nick, host, dcc->file, NULL, 0); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case TYPE_CHATSEND: |
|
|
|
|
dcc_open_query (dcc->serv, dcc->nick); |
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_read_chat, dcc); |
|
|
|
|
dcc->dccchat = malloc (sizeof (struct dcc_chat)); |
|
|
|
|
dcc->dccchat->pos = 0; |
|
|
|
|
EMIT_SIGNAL (XP_TE_DCCCONCHAT, dcc->serv->front_session, |
|
|
|
@ -1759,7 +1771,7 @@ dcc_listen_init (struct DCC *dcc, session *sess)
@@ -1759,7 +1771,7 @@ dcc_listen_init (struct DCC *dcc, session *sess)
|
|
|
|
|
listen (dcc->sok, 1); |
|
|
|
|
set_blocking (dcc->sok); |
|
|
|
|
|
|
|
|
|
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_accept, dcc); |
|
|
|
|
dcc->iotag = g_io_add_watch (dcc->channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI, dcc_accept, dcc); |
|
|
|
|
|
|
|
|
|
return TRUE; |
|
|
|
|
} |
|
|
|
|