X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/d991e38239fcb4b495e364360310f2b6c59cac67..d25c6eb1b223d1a0993dde9a28c97ef95e54bceb:/src/packet.c diff --git a/src/packet.c b/src/packet.c index 1434f2c..6090b7d 100644 --- a/src/packet.c +++ b/src/packet.c @@ -31,7 +31,7 @@ #include "ircd.h" #include "parse.h" #include "packet.h" -#include "irc_string.h" +#include "match.h" #include "hook.h" #include "send.h" @@ -99,7 +99,12 @@ parse_client_queued(struct Client *client_p) { if(IsOper(client_p) && ConfigFileEntry.no_oper_flood) - checkflood = 0; + { + if (ConfigFileEntry.true_no_oper_flood) + checkflood = -1; + else + checkflood = 0; + } /* * Handle flood protection here - if we exceed our flood limit on * messages in this loop, we simply drop out of the loop prematurely. @@ -129,7 +134,7 @@ parse_client_queued(struct Client *client_p) /* allow opers 4 times the amount of messages as users. why 4? * why not. :) --fl_ */ - else if(client_p->localClient->sent_parsed >= (4 * client_p->localClient->allow_read)) + else if(client_p->localClient->sent_parsed >= (4 * client_p->localClient->allow_read) && checkflood != -1) break; dolen = rb_linebuf_get(&client_p->localClient-> @@ -181,10 +186,10 @@ flood_recalc(void *unused) { client_p = ptr->data; - if(unlikely(IsMe(client_p))) + if(rb_unlikely(IsMe(client_p))) continue; - if(unlikely(client_p->localClient == NULL)) + if(rb_unlikely(client_p->localClient == NULL)) continue; if(IsFloodDone(client_p)) @@ -200,7 +205,7 @@ flood_recalc(void *unused) parse_client_queued(client_p); - if(unlikely(IsAnyDead(client_p))) + if(rb_unlikely(IsAnyDead(client_p))) continue; } @@ -224,132 +229,6 @@ flood_recalc(void *unused) } } -/* - * read_ctrl_packet - Read a 'packet' of data from a servlink control - * link and process it. - */ -void -read_ctrl_packet(rb_fde_t *F, void *data) -{ - struct Client *server = data; - struct LocalUser *lserver = server->localClient; - struct SlinkRpl *reply; - int length = 0; - unsigned char tmp[2]; - unsigned char *len = tmp; - struct SlinkRplDef *replydef; -#ifdef USE_IODEBUG_HOOKS - hook_data_int hdata; -#endif - - s_assert(lserver != NULL); - if(IsAnyDead(server)) - return; - - reply = &lserver->slinkrpl; - - - if(!reply->command) - { - reply->gotdatalen = 0; - reply->readdata = 0; - reply->data = NULL; - - length = rb_read(F, tmp, 1); - - if(length <= 0) - { - if((length == -1) && rb_ignore_errno(errno)) - goto nodata; - error_exit_client(server, length); - return; - } - - reply->command = tmp[0]; - } - - for (replydef = slinkrpltab; replydef->handler; replydef++) - { - if((int)replydef->replyid == reply->command) - break; - } - - /* we should be able to trust a local slink process... - * and if it sends an invalid command, that's a bug.. */ - s_assert(replydef->handler); - - if((replydef->flags & SLINKRPL_FLAG_DATA) && (reply->gotdatalen < 2)) - { - /* we need a datalen u16 which we don't have yet... */ - length = rb_read(F, len, (2 - reply->gotdatalen)); - if(length <= 0) - { - if((length == -1) && rb_ignore_errno(errno)) - goto nodata; - error_exit_client(server, length); - return; - } - - if(reply->gotdatalen == 0) - { - reply->datalen = *len << 8; - reply->gotdatalen++; - length--; - len++; - } - if(length && (reply->gotdatalen == 1)) - { - reply->datalen |= *len; - reply->gotdatalen++; - if(reply->datalen > 0) - reply->data = rb_malloc(reply->datalen); - } - - if(reply->gotdatalen < 2) - return; /* wait for more data */ - } - - if(reply->readdata < reply->datalen) /* try to get any remaining data */ - { - length = rb_read(F, (reply->data + reply->readdata), - (reply->datalen - reply->readdata)); - if(length <= 0) - { - if((length == -1) && rb_ignore_errno(errno)) - goto nodata; - error_exit_client(server, length); - return; - } - - reply->readdata += length; - if(reply->readdata < reply->datalen) - return; /* wait for more data */ - } - -#ifdef USE_IODEBUG_HOOKS - hdata.client = server; - hdata.arg1 = NULL; - hdata.arg2 = reply->command; - hdata.data = NULL; - call_hook(h_iorecvctrl_id, &hdata); -#endif - - /* we now have the command and any data, pass it off to the handler */ - (*replydef->handler) (reply->command, reply->datalen, reply->data, server); - - /* reset SlinkRpl */ - if(reply->datalen > 0) - rb_free(reply->data); - reply->command = 0; - - if(IsAnyDead(server)) - return; - - nodata: - /* If we get here, we need to register for another COMM_SELECT_READ */ - rb_setselect(F, RB_SELECT_READ, read_ctrl_packet, server); -} - /* * read_packet - Read a 'packet' of data from a connection and process it. */