summaryrefslogtreecommitdiff
path: root/src/irc/irc-dcc.c
diff options
context:
space:
mode:
authorEmmanuel Bouthenot <kolter@openics.org>2005-08-04 19:01:29 +0000
committerEmmanuel Bouthenot <kolter@openics.org>2005-08-04 19:01:29 +0000
commitace03b808d28fe19b734d8716e8988ab292aa25f (patch)
tree8d3c12267f167a8cbdfa4b0c5b29232a9ecb67ad /src/irc/irc-dcc.c
parent428cfbc297ef6d964dc5480caaa1c6fd2f8aa294 (diff)
downloadweechat-ace03b808d28fe19b734d8716e8988ab292aa25f.zip
add half (due to dcc) dcc support with proxies (only in ipv4 )
Diffstat (limited to 'src/irc/irc-dcc.c')
-rw-r--r--src/irc/irc-dcc.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c
index 1309a2475..985bedcb5 100644
--- a/src/irc/irc-dcc.c
+++ b/src/irc/irc-dcc.c
@@ -34,6 +34,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
#include "../common/weechat.h"
#include "irc.h"
@@ -233,6 +235,8 @@ int
dcc_connect (t_irc_dcc *ptr_dcc)
{
struct sockaddr_in addr;
+ struct hostent *hostent;
+ char *ip4;
if (ptr_dcc->type == DCC_CHAT_SEND)
ptr_dcc->status = DCC_WAITING;
@@ -245,12 +249,12 @@ dcc_connect (t_irc_dcc *ptr_dcc)
if (ptr_dcc->sock == -1)
return 0;
}
- if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
- return 0;
-
+
/* for sending (chat or file), listen to socket for a connection */
if (DCC_IS_SEND(ptr_dcc->type))
- {
+ {
+ if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
+ return 0;
if (listen (ptr_dcc->sock, 1) == -1)
return 0;
if (fcntl (ptr_dcc->sock, F_SETFL, 0) == -1)
@@ -260,11 +264,35 @@ dcc_connect (t_irc_dcc *ptr_dcc)
/* for receiving (chat or file), connect to listening host */
if (DCC_IS_RECV(ptr_dcc->type))
{
- memset (&addr, 0, sizeof (addr));
- addr.sin_port = htons (ptr_dcc->port);
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl (ptr_dcc->addr);
- connect (ptr_dcc->sock, (struct sockaddr *) &addr, sizeof (addr));
+ if (cfg_proxy_use)
+ {
+ memset (&addr, 0, sizeof (addr));
+ addr.sin_addr.s_addr = htonl (ptr_dcc->addr);
+ ip4 = inet_ntoa(addr.sin_addr);
+
+ memset (&addr, 0, sizeof (addr));
+ addr.sin_port = htons (cfg_proxy_port);
+ addr.sin_family = AF_INET;
+ if ((hostent = gethostbyname (cfg_proxy_address)) == NULL)
+ return 0;
+ memcpy(&(addr.sin_addr),*(hostent->h_addr_list), sizeof(struct in_addr));
+
+ if (connect (ptr_dcc->sock, (struct sockaddr *) &addr, sizeof (addr)) == -1)
+ return 0;
+ if (pass_proxy(ptr_dcc->sock, ip4, ptr_dcc->port, ptr_dcc->server->username) == -1)
+ return 0;
+ }
+ else
+ {
+ memset (&addr, 0, sizeof (addr));
+ addr.sin_port = htons (ptr_dcc->port);
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl (ptr_dcc->addr);
+ if (connect (ptr_dcc->sock, (struct sockaddr *) &addr, sizeof (addr)) == -1)
+ return 0;
+ }
+ if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
+ return 0;
}
return 1;