mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-07 02:23:12 +02:00
Rename client->local->since to client->local->fake_lag, since it is used
for fake lag calculations only (well, except for 1 corner case). As said, modules should use the new function: void add_fake_lag(Client *client, long msec)
This commit is contained in:
+2
-2
@@ -1342,8 +1342,8 @@ struct Client {
|
||||
struct LocalClient {
|
||||
int fd; /**< File descriptor, can be <0 if socket has been closed already. */
|
||||
SSL *ssl; /**< OpenSSL/LibreSSL struct for TLS connection */
|
||||
time_t since; /**< Time when user will next be allowed to send something (actually since<currenttime+10) */
|
||||
int since_msec; /**< Used for calculating 'since' penalty (modulo) */
|
||||
time_t fake_lag; /**< Time when user will next be allowed to send something (actually fake_lag<currenttime+10) */
|
||||
int fake_lag_msec; /**< Used for calculating 'fake_lag' penalty (modulo) */
|
||||
time_t firsttime; /**< Time user was created (connected on IRC) */
|
||||
time_t lasttime; /**< Last time any message was received */
|
||||
dbuf sendQ; /**< Outgoing send queue (data to be sent) */
|
||||
|
||||
+4
-4
@@ -367,7 +367,7 @@ void check_ping(Client *client)
|
||||
&& ((TStime() - client->local->lasttime) >= (2 * ping)))
|
||||
||
|
||||
/* Or isn't registered and time spent is larger than ping (CONNECTTIMEOUT).. */
|
||||
(!IsRegistered(client) && (TStime() - client->local->since >= ping))
|
||||
(!IsRegistered(client) && (TStime() - client->local->fake_lag >= ping))
|
||||
)
|
||||
{
|
||||
if (IsServer(client) || IsConnecting(client) ||
|
||||
@@ -517,8 +517,8 @@ void fix_timers(void)
|
||||
|
||||
list_for_each_entry(client, &lclient_list, lclient_node)
|
||||
{
|
||||
if (client->local->since > TStime())
|
||||
client->local->since = TStime();
|
||||
if (client->local->fake_lag > TStime())
|
||||
client->local->fake_lag = TStime();
|
||||
if (client->local->lasttime > TStime())
|
||||
client->local->lasttime = TStime();
|
||||
if (client->local->last > TStime())
|
||||
@@ -1140,7 +1140,7 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
me_hash = find_or_add(me.name);
|
||||
me.serv->up = me_hash;
|
||||
timeofday = time(NULL);
|
||||
me.local->lasttime = me.local->since = me.local->firsttime = me.serv->boottime = TStime();
|
||||
me.local->lasttime = me.local->fake_lag = me.local->firsttime = me.serv->boottime = TStime();
|
||||
me.serv->features.protocol = UnrealProtocol;
|
||||
safe_strdup(me.serv->features.software, version);
|
||||
add_to_client_hash_table(me.name, &me);
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ Client *make_client(Client *from, Client *servr)
|
||||
INIT_LIST_HEAD(&client->lclient_node);
|
||||
INIT_LIST_HEAD(&client->special_node);
|
||||
|
||||
client->local->since = client->local->lasttime =
|
||||
client->local->fake_lag = client->local->lasttime =
|
||||
client->lastnick = client->local->firsttime =
|
||||
client->local->last = TStime();
|
||||
client->local->class = NULL;
|
||||
|
||||
+2
-2
@@ -319,7 +319,7 @@ CMD_FUNC(cmd_nick_local)
|
||||
}
|
||||
|
||||
if (!ValidatePermissionsForPath("immune:nick-flood",client,NULL,NULL,NULL))
|
||||
cptr->local->since += 3; /* Nick-flood prot. -Donwulff */
|
||||
cptr->local->fake_lag += 3; /* Nick-flood prot. -Donwulff */
|
||||
|
||||
if ((acptr = find_client(nick, NULL)))
|
||||
{
|
||||
@@ -1128,7 +1128,7 @@ int _register_user(Client *client, char *nick, char *username, char *umode, char
|
||||
/* Give the user a fresh start as far as fake-lag is concerned.
|
||||
* Otherwise the user could be lagged up already due to all the CAP stuff.
|
||||
*/
|
||||
client->local->since = TStime();
|
||||
client->local->fake_lag = TStime();
|
||||
|
||||
RunHook2(HOOKTYPE_WELCOME, client, 999);
|
||||
|
||||
|
||||
+1
-1
@@ -179,7 +179,7 @@ CMD_FUNC(cmd_sasl)
|
||||
if (*parv[4] == 'F')
|
||||
{
|
||||
target->local->sasl_sent_time = 0;
|
||||
target->local->since += 7; /* bump fakelag due to failed authentication attempt */
|
||||
target->local->fake_lag += 7; /* bump fakelag due to failed authentication attempt */
|
||||
RunHookReturn2(HOOKTYPE_SASL_RESULT, target, 0, !=0);
|
||||
sendnumeric(target, ERR_SASLFAIL);
|
||||
}
|
||||
|
||||
+1
-1
@@ -971,7 +971,7 @@ int stats_uptime(Client *client, char *para)
|
||||
{
|
||||
time_t tmpnow;
|
||||
|
||||
tmpnow = TStime() - me.local->since;
|
||||
tmpnow = TStime() - me.local->fake_lag;
|
||||
sendnumeric(client, RPL_STATSUPTIME,
|
||||
tmpnow / 86400, (tmpnow / 3600) % 24, (tmpnow / 60) % 60,
|
||||
tmpnow % 60);
|
||||
|
||||
+8
-8
@@ -338,7 +338,7 @@ static void parse2(Client *cptr, Client **fromptr, MessageTag *mtags, int mtags_
|
||||
if (*ch == '\0')
|
||||
{
|
||||
if (!IsServer(cptr))
|
||||
cptr->local->since++; /* 1s fake lag */
|
||||
cptr->local->fake_lag++; /* 1s fake lag */
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -588,13 +588,13 @@ void parse_addlag(Client *client, int command_bytes, int mtags_bytes)
|
||||
int lag_penalty = settings->period[FLD_LAG_PENALTY];
|
||||
int lag_penalty_bytes = settings->limit[FLD_LAG_PENALTY];
|
||||
|
||||
client->local->since_msec += (1 + (command_bytes/lag_penalty_bytes) + (mtags_bytes/lag_penalty_bytes)) * lag_penalty;
|
||||
client->local->fake_lag_msec += (1 + (command_bytes/lag_penalty_bytes) + (mtags_bytes/lag_penalty_bytes)) * lag_penalty;
|
||||
|
||||
/* This code takes into account not only the msecs we just calculated
|
||||
* but also any leftover msec from previous lagging up.
|
||||
*/
|
||||
client->local->since += (client->local->since_msec / 1000);
|
||||
client->local->since_msec = client->local->since_msec % 1000;
|
||||
client->local->fake_lag += (client->local->fake_lag_msec / 1000);
|
||||
client->local->fake_lag_msec = client->local->fake_lag_msec % 1000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,9 +605,9 @@ void add_fake_lag(Client *client, long msec)
|
||||
if (!MyConnect(client))
|
||||
return;
|
||||
|
||||
client->local->since_msec += msec;
|
||||
client->local->since += (client->local->since_msec / 1000);
|
||||
client->local->since_msec = client->local->since_msec % 1000;
|
||||
client->local->fake_lag_msec += msec;
|
||||
client->local->fake_lag += (client->local->fake_lag_msec / 1000);
|
||||
client->local->fake_lag_msec = client->local->fake_lag_msec % 1000;
|
||||
}
|
||||
|
||||
/** Returns 1 if the client is lagged up and data should NOT be parsed.
|
||||
@@ -623,7 +623,7 @@ static int client_lagged_up(Client *client)
|
||||
return 0;
|
||||
if (ValidatePermissionsForPath("immune:lag",client,NULL,NULL,NULL))
|
||||
return 0;
|
||||
if (client->local->since - TStime() < 10)
|
||||
if (client->local->fake_lag - TStime() < 10)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ void send_proto(Client *client, ConfigItem_link *aconf)
|
||||
/* Second line */
|
||||
sendto_one(client, NULL, "PROTOCTL CHANMODES=%s%s,%s%s,%s%s,%s%s USERMODES=%s BOOTED=%lld PREFIX=%s SID=%s MLOCK TS=%lld EXTSWHOIS",
|
||||
CHPAR1, EXPAR1, CHPAR2, EXPAR2, CHPAR3, EXPAR3, CHPAR4, EXPAR4,
|
||||
umodestring, (long long)me.local->since, prefix->value,
|
||||
umodestring, (long long)me.local->fake_lag, prefix->value,
|
||||
me.id, (long long)TStime());
|
||||
|
||||
/* Third line */
|
||||
|
||||
+2
-2
@@ -993,8 +993,8 @@ void read_packet(int fd, int revents, void *data)
|
||||
}
|
||||
|
||||
client->local->lasttime = now;
|
||||
if (client->local->lasttime > client->local->since)
|
||||
client->local->since = client->local->lasttime;
|
||||
if (client->local->lasttime > client->local->fake_lag)
|
||||
client->local->fake_lag = client->local->lasttime;
|
||||
/* FIXME: Is this correct? I have my doubts. */
|
||||
ClearPingSent(client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user