random_ping: stop producing negative values that become 16 chars
This commit is contained in:
parent
84d0b55e76
commit
da20854e83
3 changed files with 5 additions and 5 deletions
|
@ -254,7 +254,7 @@ struct LocalUser
|
||||||
*/
|
*/
|
||||||
int sent_parsed; /* how many messages we've parsed in this second */
|
int sent_parsed; /* how many messages we've parsed in this second */
|
||||||
time_t last_knock; /* time of last knock */
|
time_t last_knock; /* time of last knock */
|
||||||
unsigned long random_ping;
|
uint32_t random_ping;
|
||||||
|
|
||||||
/* target change stuff */
|
/* target change stuff */
|
||||||
/* targets we're aware of (fnv32(use_id(target_p))):
|
/* targets we're aware of (fnv32(use_id(target_p))):
|
||||||
|
|
|
@ -367,9 +367,9 @@ register_local_user(struct Client *client_p, struct Client *source_p)
|
||||||
{
|
{
|
||||||
if(!(source_p->flags & FLAGS_PINGSENT) && source_p->localClient->random_ping == 0)
|
if(!(source_p->flags & FLAGS_PINGSENT) && source_p->localClient->random_ping == 0)
|
||||||
{
|
{
|
||||||
source_p->localClient->random_ping = (unsigned long) (rand() * rand()) << 1;
|
source_p->localClient->random_ping = (uint32_t)(((rand() * rand()) << 1) | 1);
|
||||||
sendto_one(source_p, "PING :%08lX",
|
sendto_one(source_p, "PING :%08X",
|
||||||
(unsigned long) source_p->localClient->random_ping);
|
(unsigned int) source_p->localClient->random_ping);
|
||||||
source_p->flags |= FLAGS_PINGSENT;
|
source_p->flags |= FLAGS_PINGSENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ mr_pong(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
|
||||||
{
|
{
|
||||||
if(ConfigFileEntry.ping_cookie && source_p->flags & FLAGS_SENTUSER && source_p->name[0])
|
if(ConfigFileEntry.ping_cookie && source_p->flags & FLAGS_SENTUSER && source_p->name[0])
|
||||||
{
|
{
|
||||||
unsigned long incoming_ping = strtoul(parv[1], NULL, 16);
|
uint32_t incoming_ping = strtoul(parv[1], NULL, 16);
|
||||||
if(incoming_ping)
|
if(incoming_ping)
|
||||||
{
|
{
|
||||||
if(source_p->localClient->random_ping == incoming_ping)
|
if(source_p->localClient->random_ping == incoming_ping)
|
||||||
|
|
Loading…
Reference in a new issue