# HG changeset patch
# User Christian Hammond <chipx86@chipx86.com>
# Date 1058862231 0
# Node ID 1bf6fd117797f3d75dd9afe386790e8969e6e07c
# Parent  0a902bd3e17035a53dd4cd62425e6c815840c6b8
[gaim-migrate @ 6767]
IRC should now use the new IP code. Or it'll break horribly and nobody's
DCC sends will work. One of those.

committer: Tailor Script <tailor@pidgin.im>

diff -r 0a902bd3e170 -r 1bf6fd117797 src/protocols/irc/irc.c
--- a/src/protocols/irc/irc.c	Tue Jul 22 08:22:08 2003 +0000
+++ b/src/protocols/irc/irc.c	Tue Jul 22 08:23:51 2003 +0000
@@ -2566,29 +2566,6 @@
 		*se = "offline";
 }
 
-static int 
-getlocalip(char *ip) /* Thanks, libfaim */
-{
-	struct hostent *hptr;
-	char localhost[129];
-	long unsigned add;
-	
-	/* XXX if available, use getaddrinfo() */
-	/* XXX allow client to specify which IP to use for multihomed boxes */
-	
-	if (gethostname(localhost, 128) < 0)
-		return -1;
-
-	if (!(hptr = gethostbyname(localhost)))
-		return -1;
-	
-	memcpy(&add, hptr->h_addr_list[0], 4);
-	add = htonl(add);
-	g_snprintf(ip, 11, "%lu", add);
-
-	return 0;
-}
-
 static void 
 dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition)
 {
@@ -2851,6 +2828,7 @@
 	int len;
 	struct sockaddr_in addr;
 	char buf[IRC_BUF_LEN];
+	const char *ip;
 	
 	/* Create a socket */
 	chat = g_new0 (struct dcc_chat, 1);
@@ -2869,7 +2847,10 @@
 	len = sizeof (addr);
 	getsockname (chat->fd, (struct sockaddr *) &addr, &len);
 	chat->port = ntohs (addr.sin_port);
-	getlocalip(chat->ip_address);
+
+	ip = gaim_xfers_get_ip_for_account(gaim_connection_get_account(gc));
+	strncpy(chat->ip_address, ip, INET6_ADDRSTRLEN);
+
 	chat->inpa =
 		gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected,
 				chat);