Small fixes:

- Fix compiler warnings (one was a real (but harmless) bug)
- Don't send PING packets if there is UDP traffic
- Correctly terminate strings containing salt for PING/PONG packets
This commit is contained in:
Guus Sliepen 2001-05-25 08:36:11 +00:00
parent bfc5d6014e
commit 4dee76522e
3 changed files with 13 additions and 8 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: meta.c,v 1.1.2.16 2001/03/12 23:58:19 guus Exp $ $Id: meta.c,v 1.1.2.17 2001/05/25 08:36:11 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -93,7 +93,6 @@ int receive_meta(connection_t *cl)
int oldlen, i; int oldlen, i;
int lenin = 0; int lenin = 0;
char inbuf[MAXBUFSIZE]; char inbuf[MAXBUFSIZE];
char *bufp;
int decrypted = 0; int decrypted = 0;
cp cp
if(getsockopt(cl->meta_socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0) if(getsockopt(cl->meta_socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0)

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.35.4.105 2001/05/07 19:08:43 guus Exp $ $Id: net.c,v 1.35.4.106 2001/05/25 08:36:11 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -848,11 +848,13 @@ cp
cfg = get_config_val(upstreamcfg, config_connectto); cfg = get_config_val(upstreamcfg, config_connectto);
if(!cfg) if(!cfg)
if(upstreamcfg == config)
{ {
/* No upstream IP given, we're listen only. */ if(upstreamcfg == config)
signal(SIGALRM, SIG_IGN); {
return; /* No upstream IP given, we're listen only. */
signal(SIGALRM, SIG_IGN);
return;
}
} }
else else
{ {
@ -1075,6 +1077,8 @@ cp
return; return;
} }
cl->last_ping_time = time(NULL);
receive_udppacket(cl, &pkt); receive_udppacket(cl, &pkt);
cp cp
} }

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.28.4.89 2001/05/24 21:52:26 guus Exp $ $Id: protocol.c,v 1.28.4.90 2001/05/25 08:36:11 guus Exp $
*/ */
#include "config.h" #include "config.h"
@ -1068,6 +1068,7 @@ cp
cl->last_ping_time = time(NULL); cl->last_ping_time = time(NULL);
RAND_bytes(salt, SALTLEN); RAND_bytes(salt, SALTLEN);
bin2hex(salt, salt, SALTLEN); bin2hex(salt, salt, SALTLEN);
salt[SALTLEN*2] = '\0';
cp cp
return send_request(cl, "%d %s", PING, salt); return send_request(cl, "%d %s", PING, salt);
} }
@ -1084,6 +1085,7 @@ int send_pong(connection_t *cl)
cp cp
RAND_bytes(salt, SALTLEN); RAND_bytes(salt, SALTLEN);
bin2hex(salt, salt, SALTLEN); bin2hex(salt, salt, SALTLEN);
salt[SALTLEN*2] = '\0';
cp cp
return send_request(cl, "%d %s", PONG, salt); return send_request(cl, "%d %s", PONG, salt);
} }