target change: use fnv32 hash of UID instead of pointer to identify clients
This way, the information remains valid after a split. For clients on TS5 servers, the nick is used; this is not much of a problem because these are on pseudoservers and not assumed to change nick much at all.
This commit is contained in:
parent
cb57dfe520
commit
4d17e288b4
|
@ -11,8 +11,8 @@ yourself.
|
||||||
|
|
||||||
You will have a set number of 'slots', each different client you message
|
You will have a set number of 'slots', each different client you message
|
||||||
will take up one slot. A client doing a nick change will not use a new slot,
|
will take up one slot. A client doing a nick change will not use a new slot,
|
||||||
however a client leaving the network and reconnecting will. You will
|
however a client disconnecting from the server it is on and reconnecting
|
||||||
receive 1 new slot roughly every minute.
|
will. You will receive 1 new slot roughly every minute.
|
||||||
|
|
||||||
When all slots are filled, messages to new clients will not be accepted.
|
When all slots are filled, messages to new clients will not be accepted.
|
||||||
Messages to clients already filling a slot will be accepted. If all slots
|
Messages to clients already filling a slot will be accepted. If all slots
|
||||||
|
|
|
@ -290,7 +290,7 @@ struct LocalUser
|
||||||
auth_request_t *auth_request;
|
auth_request_t *auth_request;
|
||||||
|
|
||||||
/* target change stuff */
|
/* target change stuff */
|
||||||
void *targets[10]; /* targets were aware of */
|
uint32_t targets[10]; /* targets were aware of (fnv32(use_id(target_p))) */
|
||||||
unsigned int targinfo[2]; /* cyclic array, no in use */
|
unsigned int targinfo[2]; /* cyclic array, no in use */
|
||||||
time_t target_last; /* last time we cleared a slot */
|
time_t target_last; /* last time we cleared a slot */
|
||||||
|
|
||||||
|
|
|
@ -566,6 +566,7 @@ static int
|
||||||
add_target(struct Client *source_p, struct Client *target_p)
|
add_target(struct Client *source_p, struct Client *target_p)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
uint32_t hashv;
|
||||||
|
|
||||||
/* can msg themselves or services without using any target slots */
|
/* can msg themselves or services without using any target slots */
|
||||||
if(source_p == target_p || IsService(target_p))
|
if(source_p == target_p || IsService(target_p))
|
||||||
|
@ -579,13 +580,15 @@ add_target(struct Client *source_p, struct Client *target_p)
|
||||||
if(source_p->localClient->target_last > CurrentTime && IsOper(target_p))
|
if(source_p->localClient->target_last > CurrentTime && IsOper(target_p))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
hashv = fnv_hash_upper(use_id(target_p), 32);
|
||||||
|
|
||||||
if(USED_TARGETS(source_p))
|
if(USED_TARGETS(source_p))
|
||||||
{
|
{
|
||||||
/* hunt for an existing target */
|
/* hunt for an existing target */
|
||||||
for(i = PREV_FREE_TARGET(source_p), j = USED_TARGETS(source_p);
|
for(i = PREV_FREE_TARGET(source_p), j = USED_TARGETS(source_p);
|
||||||
j; --j, PREV_TARGET(i))
|
j; --j, PREV_TARGET(i))
|
||||||
{
|
{
|
||||||
if(source_p->localClient->targets[i] == target_p)
|
if(source_p->localClient->targets[i] == hashv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +627,7 @@ add_target(struct Client *source_p, struct Client *target_p)
|
||||||
SetTGChange(source_p);
|
SetTGChange(source_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
source_p->localClient->targets[FREE_TARGET(source_p)] = target_p;
|
source_p->localClient->targets[FREE_TARGET(source_p)] = hashv;
|
||||||
NEXT_TARGET(FREE_TARGET(source_p));
|
NEXT_TARGET(FREE_TARGET(source_p));
|
||||||
++USED_TARGETS(source_p);
|
++USED_TARGETS(source_p);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue