diff src/proxy.c @ 8262:b5dbd1839716

[gaim-migrate @ 8985] this is jabber new-style file transfer receive support. this doesn't do much error checking or handling, but I managed to send pictures to myself from Exodus on my laptop in the living room, which would have taken twice as long were it not for VNC. i said i was going to bed 1, 2, and 3 hours ago. i should go to bed. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 15 Feb 2004 10:11:38 +0000
parents f50c059b6384
children 79b834d7c2a2
line wrap: on
line diff
--- a/src/proxy.c	Sun Feb 15 08:51:32 2004 +0000
+++ b/src/proxy.c	Sun Feb 15 10:11:38 2004 +0000
@@ -1314,7 +1314,7 @@
 	gaim_input_remove(phb->inpa);
 	gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read again.\n");
 
-	if (read(source, buf, 10) < 10) {
+	if (read(source, buf, 4) < 4) {
 		gaim_debug(GAIM_DEBUG_WARNING, "socks5 proxy", "or not...\n");
 		close(source);
 
@@ -1346,6 +1346,25 @@
 		return;
 	}
 
+	/* Skip past BND.ADDR */
+	switch(buf[3]) {
+		case 0x01: /* the address is a version-4 IP address, with a length of 4 octets */
+			lseek(source, 4, SEEK_CUR);
+			break;
+		case 0x03: /* the address field contains a fully-qualified domain name.  The first
+					  octet of the address field contains the number of octets of name that
+					  follow, there is no terminating NUL octet. */
+			read(source, buf+4, 1);
+			lseek(source, buf[4], SEEK_CUR);
+			break;
+		case 0x04: /* the address is a version-6 IP address, with a length of 16 octets */
+			lseek(source, 16, SEEK_CUR);
+			break;
+	}
+
+	/* Skip past BND.PORT */
+	lseek(source, 2, SEEK_CUR);
+
 	if (phb->account == NULL ||
 		gaim_account_get_connection(phb->account) != NULL) {
 
@@ -1763,6 +1782,24 @@
 									connection_host_resolved, phb);
 }
 
+int
+gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port,
+		GaimInputFunction func, gpointer data)
+{
+	struct PHB *phb;
+
+	phb = g_new0(struct PHB, 1);
+	phb->gpi = gpi;
+	phb->func = func;
+	phb->data = data;
+	phb->host = g_strdup(host);
+	phb->port = port;
+
+	return gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), gaim_proxy_info_get_port(gpi),
+									connection_host_resolved, phb);
+}
+
+
 static void
 proxy_pref_cb(const char *name, GaimPrefType type, gpointer value,
 			  gpointer data)