From fd6c38d22e8f54fae198d4bdd98c6b1dd37589a9 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 7 Jan 2004 07:54:38 +0000 Subject: If we can't connect to server using given IP, show the IP to user in the error message. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3197 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/servers.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/servers.c b/src/core/servers.c index 85bc203b..ca18914a 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -171,7 +171,10 @@ static void server_real_connect(SERVER_REC *server, IPADDR *ip, const char *unix_socket) { GIOChannel *handle; - IPADDR *own_ip; + IPADDR *own_ip = NULL; + const char *errmsg; + char *errmsg2; + char ipaddr[MAX_IP_LEN]; int port; g_return_if_fail(ip != NULL || unix_socket != NULL); @@ -197,12 +200,22 @@ server->connrec->ssl_cafile, server->connrec->ssl_capath, server->connrec->ssl_v if (handle == NULL) { /* failed */ - if (errno == EADDRNOTAVAIL || - (server->connrec->use_ssl && errno == ENOSYS)) + errmsg = g_strerror(errno); + errmsg2 = NULL; + if (errno == EADDRNOTAVAIL) { + if (own_ip != NULL) { + /* show the IP which is causing the error */ + net_ip2host(own_ip, ipaddr); + errmsg2 = g_strconcat(errmsg, ": ", ipaddr, NULL); + } + server->no_reconnect = TRUE; + } + if (server->connrec->use_ssl && errno == ENOSYS) server->no_reconnect = TRUE; server->connection_lost = TRUE; - server_connect_failed(server, g_strerror(errno)); + server_connect_failed(server, errmsg2 ? errmsg2 : errmsg); + g_free(errmsg2); } else { server->handle = net_sendbuffer_create(handle, 0); server->connect_tag = -- cgit v1.2.3