comparison src/protocols/toc/toc.c @ 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 3196d9044a45
children 858979ab3867
comparison
equal deleted inserted replaced
4596:7e1591c6d0d8 4597:1969709eee1e
121 void *data; 121 void *data;
122 }; 122 };
123 123
124 struct toc_data { 124 struct toc_data {
125 int toc_fd; 125 int toc_fd;
126 char toc_ip[20];
126 int seqno; 127 int seqno;
127 int state; 128 int state;
128 }; 129 };
129 130
130 struct sflap_hdr { 131 struct sflap_hdr {
213 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) 214 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond)
214 { 215 {
215 struct gaim_connection *gc = data; 216 struct gaim_connection *gc = data;
216 struct toc_data *tdt; 217 struct toc_data *tdt;
217 char buf[80]; 218 char buf[80];
219 struct sockaddr_in name;
220 socklen_t namelen;
218 221
219 if (!g_slist_find(connections, data)) { 222 if (!g_slist_find(connections, data)) {
220 toc_soc_close(source); 223 toc_soc_close(source);
221 return; 224 return;
222 } 225 }
228 hide_login_progress(gc, "Unable to connect."); 231 hide_login_progress(gc, "Unable to connect.");
229 signoff(gc); 232 signoff(gc);
230 return; 233 return;
231 } 234 }
232 tdt->toc_fd = source; 235 tdt->toc_fd = source;
236
237 /*
238 * Copy the IP that we're connected to. We need this because "GOTO_URL"'s
239 * should open on the exact server we're connected to. toc.oscar.aol.com
240 * doesn't work because that hostname resolves to multiple IP addresses.
241 */
242 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0)
243 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip));
244 else if (gc->account && gc->account->proto_opt[USEROPT_AUTH][0])
245 strncpy(tdt->toc_ip, gc->account->proto_opt[USEROPT_AUTH], sizeof(tdt->toc_ip));
246 else
247 strncpy(tdt->toc_ip, TOC_HOST, sizeof(tdt->toc_ip));
233 248
234 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); 249 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n");
235 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { 250 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) {
236 hide_login_progress(gc, "Disconnected."); 251 hide_login_progress(gc, "Disconnected.");
237 signoff(gc); 252 signoff(gc);
806 char *name, *url, tmp[256]; 821 char *name, *url, tmp[256];
807 822
808 name = strtok(NULL, ":"); 823 name = strtok(NULL, ":");
809 url = strtok(NULL, ":"); 824 url = strtok(NULL, ":");
810 825
811 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", 826 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip,
812 gc->account->proto_opt[USEROPT_AUTH][0] ?
813 gc->account->proto_opt[USEROPT_AUTH] : TOC_HOST,
814 gc->account->proto_opt[USEROPT_AUTHPORT][0] ? 827 gc->account->proto_opt[USEROPT_AUTHPORT][0] ?
815 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, 828 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT,
816 url); 829 url);
817 grab_url(tmp, FALSE, toc_got_info, NULL); 830 grab_url(tmp, FALSE, toc_got_info, NULL);
818 } else if (!strcasecmp(c, "DIR_STATUS")) { 831 } else if (!strcasecmp(c, "DIR_STATUS")) {