changeset 4597:1969709eee1e

[gaim-migrate @ 4882] You know how when you get info with TOC it only works 25% of the time? This fixes that! I wrote the patch, but George Vulov was the one who realized what was going on. Here's his post from the forums: I was looking at the gaim TOC source and I noticed that when gaim receives a GOTO_URL command, it appends the given url to "http://toc.oscar.aol.com";. However, toc.oscar.aol.com resolves to different servers at different times, so when one is logged on using TOC for over 10 mins and requests someone's info, "<H1>The requested URL 901450_722937 was not found on this server</H1>" comes up. gaim should request the info from the specific toc server it is connected to, instead of using toc.oscar.aol.com So basically... we lookup the IP address of our connection socket and keep that in TOC's protocol data. Then, when we get someone's info, open http://64.12.163.214:port/bleh instead of http://toc.oscar.aol.com:port/bleh Thanks George, you da man. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 21 Feb 2003 05:53:40 +0000
parents 7e1591c6d0d8
children a064e437d5eb
files src/protocols/toc/toc.c
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/toc/toc.c	Fri Feb 21 04:33:56 2003 +0000
+++ b/src/protocols/toc/toc.c	Fri Feb 21 05:53:40 2003 +0000
@@ -123,6 +123,7 @@
 
 struct toc_data {
 	int toc_fd;
+	char toc_ip[20];
 	int seqno;
 	int state;
 };
@@ -215,6 +216,8 @@
 	struct gaim_connection *gc = data;
 	struct toc_data *tdt;
 	char buf[80];
+	struct sockaddr_in name;
+	socklen_t namelen;
 
 	if (!g_slist_find(connections, data)) {
 		toc_soc_close(source);
@@ -231,6 +234,18 @@
 	}
 	tdt->toc_fd = source;
 
+	/*
+	 * Copy the IP that we're connected to.  We need this because "GOTO_URL"'s 
+	 * should open on the exact server we're connected to.  toc.oscar.aol.com 
+	 * doesn't work because that hostname resolves to multiple IP addresses.
+	 */
+	if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0)
+		strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip));
+	else if (gc->account && gc->account->proto_opt[USEROPT_AUTH][0])
+		strncpy(tdt->toc_ip, gc->account->proto_opt[USEROPT_AUTH], sizeof(tdt->toc_ip));
+	else
+		strncpy(tdt->toc_ip, TOC_HOST, sizeof(tdt->toc_ip));
+
 	debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n");
 	if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) {
 		hide_login_progress(gc, "Disconnected.");
@@ -808,9 +823,7 @@
 		name = strtok(NULL, ":");
 		url = strtok(NULL, ":");
 
-		g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s",
-				gc->account->proto_opt[USEROPT_AUTH][0] ?
-					gc->account->proto_opt[USEROPT_AUTH] : TOC_HOST,
+		g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip,
 				gc->account->proto_opt[USEROPT_AUTHPORT][0] ?
 					atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT,
 				url);