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
014e2aa049
commit
3f6e258775
3 changed files with 8 additions and 5 deletions
|
@ -11,8 +11,8 @@ yourself.
|
|||
|
||||
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,
|
||||
however a client leaving the network and reconnecting will. You will
|
||||
receive 1 new slot roughly every minute.
|
||||
however a client disconnecting from the server it is on and reconnecting
|
||||
will. You will receive 1 new slot roughly every minute.
|
||||
|
||||
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
|
||||
|
|
|
@ -290,7 +290,7 @@ struct LocalUser
|
|||
auth_request_t *auth_request;
|
||||
|
||||
/* 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 */
|
||||
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)
|
||||
{
|
||||
int i, j;
|
||||
uint32_t hashv;
|
||||
|
||||
/* can msg themselves or services without using any target slots */
|
||||
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))
|
||||
return 1;
|
||||
|
||||
hashv = fnv_hash_upper(use_id(target_p), 32);
|
||||
|
||||
if(USED_TARGETS(source_p))
|
||||
{
|
||||
/* hunt for an existing target */
|
||||
for(i = PREV_FREE_TARGET(source_p), j = USED_TARGETS(source_p);
|
||||
j; --j, PREV_TARGET(i))
|
||||
{
|
||||
if(source_p->localClient->targets[i] == target_p)
|
||||
if(source_p->localClient->targets[i] == hashv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -624,7 +627,7 @@ add_target(struct Client *source_p, struct Client *target_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));
|
||||
++USED_TARGETS(source_p);
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue