Only activate a connection upon receiving it's public key if it's an

incoming connection. When it's outgoing, we need to receive an ack first.
This commit is contained in:
Guus Sliepen 2000-05-29 23:40:05 +00:00
parent 5654e156a3
commit a7ad161d2b
2 changed files with 15 additions and 13 deletions

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: net.c,v 1.31 2000/05/29 22:20:04 zarq Exp $ $Id: net.c,v 1.32 2000/05/29 23:40:05 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -973,7 +973,7 @@ cp
{ {
if(sscanf(cl->buffer, "%d", &request) == 1) if(sscanf(cl->buffer, "%d", &request) == 1)
{ {
if((request < 0 || request > 255) || request_handlers[request] == NULL) if((request < 0) || (request > 255) || (request_handlers[request] == NULL))
{ {
syslog(LOG_ERR, _("Unknown request: %s"), cl->buffer); syslog(LOG_ERR, _("Unknown request: %s"), cl->buffer);
return -1; return -1;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: protocol.c,v 1.26 2000/05/29 21:01:25 zarq Exp $ $Id: protocol.c,v 1.27 2000/05/29 23:40:05 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -451,19 +451,21 @@ cp
if(cl->status.outgoing) if(cl->status.outgoing)
send_public_key(cl); send_public_key(cl);
else else
send_ack(cl); {
send_ack(cl);
/* Okay, before we active the connection, we check if there is another entry /* Okay, before we active the connection, we check if there is another entry
in the connection list with the same vpn_ip. If so, it presumably is an in the connection list with the same vpn_ip. If so, it presumably is an
old connection that has timed out but we don't know it yet. Because our old connection that has timed out but we don't know it yet. Because our
conn_list entry is not active, lookup_conn will skip ourself. */ conn_list entry is not active, lookup_conn will skip ourself. */
while(old=lookup_conn(cl->vpn_ip)) while(old=lookup_conn(cl->vpn_ip))
terminate_connection(old); terminate_connection(old);
cl->status.active = 1; cl->status.active = 1;
notify_others(cl, NULL, send_add_host); notify_others(cl, NULL, send_add_host);
notify_one(cl); notify_one(cl);
}
cp cp
return 0; return 0;
} }