X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprotocol.c;h=aab226600a8b01ce48830f22bdc18ca538c0aea7;hp=17eb3bdf57b7b05f8c34c3c11b067afa7e12496d;hb=6bd93e4c064578b545cb6dcaa28fffb229c929ff;hpb=9a0a50cd3cf2570b39e00edf1a92123acbac41b4 diff --git a/src/protocol.c b/src/protocol.c index 17eb3bdf..aab22660 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol.c,v 1.28.4.94 2001/06/09 10:00:34 guus Exp $ + $Id: protocol.c,v 1.28.4.97 2001/07/01 21:42:13 guus Exp $ */ #include "config.h" @@ -227,22 +227,22 @@ cp return -1; } - /* First check if the host we connected to is already in our + /* First check if the host is already in our connection list. If so, we are probably making a loop, which is not desirable. */ - if(cl->status.outgoing) + if((old = lookup_id(cl->name))) { - if((old = lookup_id(cl->name))) + if(debug_lvl >= DEBUG_CONNECTIONS) + syslog(LOG_NOTICE, _("%s (%s) is already in our connection list"), cl->name, cl->hostname); + if(cl->status.outgoing) { - if(debug_lvl >= DEBUG_CONNECTIONS) - syslog(LOG_NOTICE, _("Uplink %s (%s) is already in our connection list"), cl->name, cl->hostname); cl->status.outgoing = 0; old->status.outgoing = 1; - terminate_connection(cl); - return 0; } + terminate_connection(cl); + return 0; } /* Now we can add the name to the id tree */ @@ -253,8 +253,14 @@ cp node = avl_unlink(connection_tree, cl); cl->port = port; - avl_insert_node(connection_tree, node); - + if(!avl_insert_node(connection_tree, node)) + { + old = avl_search_node(connection_tree, node)->data; + syslog(LOG_ERR, _("%s is listening on %s:%hd, which is already in use by %s!"), + cl->name, cl->hostname, cl->port, old->name); + return -1; + } + /* Read in the public key, so that we can send a metakey */ if(read_rsa_public_key(cl))