Просмотр исходного кода

Merge branch 'knock_flags'

* knock_flags:
  * Add error output with chanset 'flood-exempt' and 'knock'
  * Remove help entry for +/-knock
  * Remove old +knock and replace with 'knock' to accept Op/Voice/User/None
Bryan Drewery 16 лет назад
Родитель
Сommit
812669dccb

+ 1 - 0
doc/UPDATES

@@ -47,6 +47,7 @@
 * Fix segfault with /KNOCK on csircd
 * Fix segfault with /KNOCK on csircd
 * SHELLHASH and Owner passwords in the PackConfig can now be salted-sha1. '+' + RAND(5) + '$' + SHA1(RAND(5) + 'password')
 * SHELLHASH and Owner passwords in the PackConfig can now be salted-sha1. '+' + RAND(5) + '$' + SHA1(RAND(5) + 'password')
 * Fix restart causing bot to change nick (this was a regression in jupenick)
 * Fix restart causing bot to change nick (this was a regression in jupenick)
+* Removed 'chanset +knock' and replaced with 'chanset knock (Op|Voice|User)', see 'help chaninfo'
 
 
 1.2.16.1
 1.2.16.1
 * Fix linux compile errors
 * Fix linux compile errors

+ 5 - 3
doc/help.txt

@@ -388,6 +388,11 @@ See also: link
                           Once the ban is removed, then the exempt will be
                           Once the ban is removed, then the exempt will be
                           removed the next time the bot checks. Please note
                           removed the next time the bot checks. Please note
                           that this is an IRCnet feature.
                           that this is an IRCnet feature.
+        $bknock$b         Allow auto-inviting on /KNOCK?
+                              None/0         Don't invite on /KNOCK
+                              Op/1           Ops (+o) are invited on /KNOCK
+                              Voice/2        Voices (+v) are invited on /KNOCK
+                              User/3         Users (not +dk) are invited on /KNOCK
         $bflood-exempt$b      Should clients be exempt from flood checks based
         $bflood-exempt$b      Should clients be exempt from flood checks based
                               on their channel status? (not deop/kick floods)
                               on their channel status? (not deop/kick floods)
                               Valid values are:
                               Valid values are:
@@ -447,9 +452,6 @@ See also: link
                        can be useful to make the bot leave a channel without
                        can be useful to make the bot leave a channel without
                        losing its settings, channel-specific user flags,
                        losing its settings, channel-specific user flags,
                        channel bans, and without affecting sharing.
                        channel bans, and without affecting sharing.
-        $bknock$b          Bots which are +y will auto-invite any user who
-                       does a /knock on the channel.
-                       This will invite any user who is not set to auto-kick.
         $bmeankicks$b      Use mean/offensive kicks/bans in the channel.
         $bmeankicks$b      Use mean/offensive kicks/bans in the channel.
         $bnodesynch$b      Allow non-ops to perform channel modes? This can stop
         $bnodesynch$b      Allow non-ops to perform channel modes? This can stop
                        the bot from fighting with services such as ChanServ, or
                        the bot from fighting with services such as ChanServ, or

+ 3 - 2
src/chan.h

@@ -25,6 +25,7 @@ typedef struct memstruct {
 
 
 #define FLOOD_EXEMPT_OP	1
 #define FLOOD_EXEMPT_OP	1
 #define FLOOD_EXEMPT_VOICE 2
 #define FLOOD_EXEMPT_VOICE 2
+#define FLOOD_EXEMPT_USER 3
 
 
 #define CHANMETA "#&!+"
 #define CHANMETA "#&!+"
 #define NICKVALID "[{}]^`|\\_-"
 #define NICKVALID "[{}]^`|\\_-"
@@ -176,6 +177,7 @@ struct chanset_t {
   int mop;
   int mop;
   int voice_non_ident;
   int voice_non_ident;
   interval_t auto_delay;
   interval_t auto_delay;
+  int knock_flags;
 /* Chanint template 
 /* Chanint template 
  *int temp;
  *int temp;
  */
  */
@@ -227,7 +229,7 @@ struct chanset_t {
 #define CHAN_CLOSED         BIT3	/* Only users +o can join */
 #define CHAN_CLOSED         BIT3	/* Only users +o can join */
 #define CHAN_BITCH          BIT4	/* be a tightwad with ops             */
 #define CHAN_BITCH          BIT4	/* be a tightwad with ops             */
 #define CHAN_TAKE 	    BIT5	/* When a bot gets opped, take the chan */
 #define CHAN_TAKE 	    BIT5	/* When a bot gets opped, take the chan */
-#define CHAN_KNOCK 	    BIT6	/* Auto invite qualifying people when they knock */
+//#define CHAN_KNOCK 	    BIT6	/* Auto invite qualifying people when they knock */
 #define CHAN_BOTBITCH       BIT7        /* only let bots be opped? */
 #define CHAN_BOTBITCH       BIT7        /* only let bots be opped? */
 #define CHAN_BACKUP         BIT8	/* Join the BOT_BACKUP bots when set */
 #define CHAN_BACKUP         BIT8	/* Join the BOT_BACKUP bots when set */
 #define CHAN_SECRET         BIT9	/* don't advertise channel on botnet  */
 #define CHAN_SECRET         BIT9	/* don't advertise channel on botnet  */
@@ -300,7 +302,6 @@ struct chanset_t *findchan_by_dname(const char *name);
 #define channel_privchan(chan) (chan->status & CHAN_PRIVATE)
 #define channel_privchan(chan) (chan->status & CHAN_PRIVATE)
 #define channel_autoop(chan) (chan->status & CHAN_AUTOOP)
 #define channel_autoop(chan) (chan->status & CHAN_AUTOOP)
 #define channel_nomassjoin(chan) (chan->status & CHAN_NOMASSJOIN)
 #define channel_nomassjoin(chan) (chan->status & CHAN_NOMASSJOIN)
-#define channel_knock(chan) (chan->status & CHAN_KNOCK)
 #define channel_meankicks(chan) (chan->status & CHAN_MEANKICKS)
 #define channel_meankicks(chan) (chan->status & CHAN_MEANKICKS)
 #define channel_rbl(chan) (chan->status & CHAN_RBL)
 #define channel_rbl(chan) (chan->status & CHAN_RBL)
 /* Chanflag template
 /* Chanflag template

+ 0 - 2
src/mod/channels.mod/channels.c

@@ -882,8 +882,6 @@ void channels_report(int idx, int details)
           i += my_strcpy(s + i, "voice ");
           i += my_strcpy(s + i, "voice ");
         if (channel_autoop(chan))
         if (channel_autoop(chan))
           i += my_strcpy(s + i, "autoop ");
           i += my_strcpy(s + i, "autoop ");
-        if (channel_knock(chan))
-          i += my_strcpy(s + i, "knock ");
         if (channel_meankicks(chan))
         if (channel_meankicks(chan))
           i += my_strcpy(s + i, "meankicks ");
           i += my_strcpy(s + i, "meankicks ");
         if (channel_rbl(chan))
         if (channel_rbl(chan))

+ 3 - 3
src/mod/channels.mod/cmdschan.c

@@ -1182,7 +1182,7 @@ static void show_int(int idx, char *work, int *cnt, const char *desc, int state,
 #define SHOW_FLAG(name, state) show_flag(idx, work, &cnt, name, state, sizeof(work))
 #define SHOW_FLAG(name, state) show_flag(idx, work, &cnt, name, state, sizeof(work))
 #define SHOW_INT(desc, state, yes, no) show_int(idx, work, &cnt, desc, state, yes, no, sizeof(work))
 #define SHOW_INT(desc, state, yes, no) show_int(idx, work, &cnt, desc, state, yes, no, sizeof(work))
 #define P_STR deflag == P_KICK ? "Kick" : (deflag == P_DEOP ? "Deop" : (deflag == P_DELETE ? "Remove" : NULL))
 #define P_STR deflag == P_KICK ? "Kick" : (deflag == P_DEOP ? "Deop" : (deflag == P_DELETE ? "Remove" : NULL))
-#define F_STR chan->flood_exempt_mode == FLOOD_EXEMPT_OP ? "Op" : (chan->flood_exempt_mode == FLOOD_EXEMPT_VOICE ? "Voice" : NULL)
+#define F_STR(x) x == FLOOD_EXEMPT_OP ? "Op" : (x == FLOOD_EXEMPT_VOICE ? "Voice" : (x == FLOOD_EXEMPT_USER ? "User" : NULL))
 static void cmd_chaninfo(int idx, char *par)
 static void cmd_chaninfo(int idx, char *par)
 {
 {
   char *chname = NULL, work[512] = "";
   char *chname = NULL, work[512] = "";
@@ -1242,7 +1242,6 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_FLAG("enforcebans", 	channel_enforcebans(chan));
     SHOW_FLAG("enforcebans", 	channel_enforcebans(chan));
     SHOW_FLAG("fastop",		channel_fastop(chan));
     SHOW_FLAG("fastop",		channel_fastop(chan));
     SHOW_FLAG("inactive",	channel_inactive(chan));
     SHOW_FLAG("inactive",	channel_inactive(chan));
-    SHOW_FLAG("knock",          channel_knock(chan));
     SHOW_FLAG("meankicks",	channel_meankicks(chan));
     SHOW_FLAG("meankicks",	channel_meankicks(chan));
     SHOW_FLAG("nodesynch",	channel_nodesynch(chan));
     SHOW_FLAG("nodesynch",	channel_nodesynch(chan));
     SHOW_FLAG("nomassjoin",	channel_nomassjoin(chan));
     SHOW_FLAG("nomassjoin",	channel_nomassjoin(chan));
@@ -1281,9 +1280,10 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!");
     SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!");
     SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!");
     SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!");
     SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever");
     SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever");
-    SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR, "None");
+    SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR(chan->flood_exempt_mode), "None");
     SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't");
     SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't");
     SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever");
     SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever");
+    SHOW_INT("Knock: ", chan->knock_flags, F_STR(chan->knock_flags), "None");
     SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled");
     SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled");
     deflag = chan->manop;
     deflag = chan->manop;
     SHOW_INT("Manop: ", chan->manop, P_STR, "Ignore");
     SHOW_INT("Manop: ", chan->manop, P_STR, "Ignore");

+ 29 - 4
src/mod/channels.mod/tclchan.c

@@ -476,6 +476,29 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
         return ERROR;
         return ERROR;
       }
       }
       chan->mop = deflag_translate(item[i]);
       chan->mop = deflag_translate(item[i]);
+    } else if (!strcmp(item[i], "knock")) {
+      i++;
+      if (i >= items) {
+        if (result)
+          strlcpy(result, "channel knock needs argument", RESULT_LEN);
+        return ERROR;
+      }
+      if (!str_isdigit(item[i])) {
+        if (!strcasecmp("Op",  item[i]))
+          chan->knock_flags = FLOOD_EXEMPT_OP;
+        else if (!strcasecmp("Voice", item[i]))
+          chan->knock_flags = FLOOD_EXEMPT_VOICE;
+        else if (!strcasecmp("User", item[i]))
+          chan->knock_flags = FLOOD_EXEMPT_USER;
+        else if (!strcasecmp("None", item[i]))
+          chan->knock_flags = 0;
+        else {
+          if (result)
+            strlcpy(result, "channel knock only accepts Op|Voice|User|None", RESULT_LEN);
+          return ERROR;
+        }
+      } else
+        chan->knock_flags = atoi(item[i]);
     } else if (!strcmp(item[i], "flood-exempt")) {
     } else if (!strcmp(item[i], "flood-exempt")) {
       i++;
       i++;
       if (i >= items) {
       if (i >= items) {
@@ -490,6 +513,11 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
           chan->flood_exempt_mode = FLOOD_EXEMPT_VOICE;
           chan->flood_exempt_mode = FLOOD_EXEMPT_VOICE;
         else if (!strcasecmp("None", item[i]))
         else if (!strcasecmp("None", item[i]))
           chan->flood_exempt_mode = 0;
           chan->flood_exempt_mode = 0;
+        else {
+          if (result)
+            strlcpy(result, "channel flood-exempt only accepts Op|Voice|None", RESULT_LEN);
+          return ERROR;
+        }
       } else
       } else
         chan->flood_exempt_mode = atoi(item[i]);
         chan->flood_exempt_mode = atoi(item[i]);
     } else if (!strcmp(item[i], "flood-lock-time")) {
     } else if (!strcmp(item[i], "flood-lock-time")) {
@@ -599,10 +627,6 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
       chan->status |= CHAN_NOMASSJOIN;
       chan->status |= CHAN_NOMASSJOIN;
     else if (!strcmp(item[i], "-nomassjoin"))
     else if (!strcmp(item[i], "-nomassjoin"))
       chan->status &= ~CHAN_NOMASSJOIN;
       chan->status &= ~CHAN_NOMASSJOIN;
-    else if (!strcmp(item[i], "+knock"))
-      chan->status |= CHAN_KNOCK;
-    else if (!strcmp(item[i], "-knock"))
-      chan->status &= ~CHAN_KNOCK;
     else if (!strcmp(item[i], "+meankicks"))
     else if (!strcmp(item[i], "+meankicks"))
       chan->status |= CHAN_MEANKICKS;
       chan->status |= CHAN_MEANKICKS;
     else if (!strcmp(item[i], "-meankicks"))
     else if (!strcmp(item[i], "-meankicks"))
@@ -925,6 +949,7 @@ int channel_add(char *result, char *newname, char *options)
 /* Chanint template
 /* Chanint template
  *  chan->temp = 0;
  *  chan->temp = 0;
  */
  */
+    chan->knock_flags = 0;
     chan->flood_lock_time = 120;
     chan->flood_lock_time = 120;
     chan->flood_exempt_mode = 0;
     chan->flood_exempt_mode = 0;
     chan->flood_pub_thr = gfld_chan_thr;
     chan->flood_pub_thr = gfld_chan_thr;

+ 4 - 17
src/mod/channels.mod/userchan.c

@@ -731,11 +731,11 @@ flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 closed-ban %d closed-invite %d closed-private %d ban-time %d \
 closed-ban %d closed-invite %d closed-private %d ban-time %d \
 exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
 exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
-flood-exempt %d flood-lock-time %d \
+flood-exempt %d flood-lock-time %d knock %d \
 %cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
-%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %cknock %crbl %c%s}\n",
+%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %crbl %c%s}\n",
 	chan->dname,
 	chan->dname,
 	w,
 	w,
         chan->added_by,
         chan->added_by,
@@ -770,6 +770,7 @@ flood-exempt %d flood-lock-time %d \
         chan->auto_delay,
         chan->auto_delay,
         chan->flood_exempt_mode,
         chan->flood_exempt_mode,
         chan->flood_lock_time,
         chan->flood_lock_time,
+        chan->knock_flags,
  	PLSMNS(channel_meankicks(chan)),
  	PLSMNS(channel_meankicks(chan)),
  	PLSMNS(channel_enforcebans(chan)),
  	PLSMNS(channel_enforcebans(chan)),
 	PLSMNS(channel_dynamicbans(chan)),
 	PLSMNS(channel_dynamicbans(chan)),
@@ -790,7 +791,6 @@ flood-exempt %d flood-lock-time %d \
         PLSMNS(channel_botbitch(chan)),
         PLSMNS(channel_botbitch(chan)),
         PLSMNS(channel_backup(chan)),
         PLSMNS(channel_backup(chan)),
         PLSMNS(channel_nomassjoin(chan)),
         PLSMNS(channel_nomassjoin(chan)),
-        PLSMNS(channel_knock(chan)),
         PLSMNS(channel_rbl(chan)),
         PLSMNS(channel_rbl(chan)),
 	HAVE_TAKE ? PLSMNS(channel_take(chan)) : ' ',
 	HAVE_TAKE ? PLSMNS(channel_take(chan)) : ' ',
         HAVE_TAKE ? "take " : " "
         HAVE_TAKE ? "take " : " "
@@ -838,15 +838,11 @@ exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
-%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %cknock %c%s}\n",
+%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %c%s}\n",
 	chan->dname,
 	chan->dname,
 	w,
 	w,
         chan->added_by,
         chan->added_by,
         (long)chan->added_ts,
         (long)chan->added_ts,
-/* Chanchar template
- *      temp,
- * also include temp %s in dprintf.
- */
 	chan->bad_cookie,
 	chan->bad_cookie,
 	chan->manop,
 	chan->manop,
 	chan->mdop,
 	chan->mdop,
@@ -859,10 +855,6 @@ exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
         chan->flood_deop_thr, chan->flood_deop_time,
         chan->flood_deop_thr, chan->flood_deop_time,
 	chan->flood_nick_thr, chan->flood_nick_time,
 	chan->flood_nick_thr, chan->flood_nick_time,
         chan->closed_ban,
         chan->closed_ban,
-/* Chanint template
- *      chan->temp,
- * also include temp %d in dprintf
- */
         chan->closed_invite,
         chan->closed_invite,
         chan->closed_private,
         chan->closed_private,
         chan->ban_time,
         chan->ban_time,
@@ -889,13 +881,8 @@ exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
         PLSMNS(channel_botbitch(chan)),
         PLSMNS(channel_botbitch(chan)),
         PLSMNS(channel_backup(chan)),
         PLSMNS(channel_backup(chan)),
         PLSMNS(channel_nomassjoin(chan)),
         PLSMNS(channel_nomassjoin(chan)),
-        PLSMNS(channel_knock(chan)),
 	HAVE_TAKE ? PLSMNS(channel_take(chan)) : ' ',
 	HAVE_TAKE ? PLSMNS(channel_take(chan)) : ' ',
         HAVE_TAKE ? "take " : " "
         HAVE_TAKE ? "take " : " "
-/* Chanflag template
- * also include a %ctemp above.
- *      PLSMNS(channel_temp(chan)),
- */
     );
     );
   }
   }
 }
 }

+ 7 - 2
src/mod/irc.mod/chan.c

@@ -1647,7 +1647,7 @@ static int got710(char *from, char *msg)
 
 
   chan = findchan(chname);
   chan = findchan(chname);
 
 
-  if (!channel_knock(chan) || !dovoice(chan))
+  if (!chan->knock_flags || !dovoice(chan))
     return 0;
     return 0;
 
 
   struct userrec *u = get_user_by_host(uhost);
   struct userrec *u = get_user_by_host(uhost);
@@ -1661,8 +1661,13 @@ static int got710(char *from, char *msg)
 
 
   get_user_flagrec(u, &fr, chan->dname, chan);
   get_user_flagrec(u, &fr, chan->dname, chan);
 
 
-  if (chan_kick(fr) || glob_kick(fr))
+  // PASSING: +o and op || +v and op/voice || user
+  if (!((chan->knock_flags == FLOOD_EXEMPT_OP && chk_op(fr, chan)) ||
+       (chan->knock_flags == FLOOD_EXEMPT_VOICE && (chk_op(fr, chan) || chk_voice(fr, chan))) ||
+       (chan->knock_flags == FLOOD_EXEMPT_USER)) ||
+      chan_kick(fr) || glob_kick(fr)) {
     return 0;
     return 0;
+  }
 
 
 //  dprintf(DP_HELP, "PRIVMSG %s :%s knocked, inviting.. (%s)\n", chname, nick, u ? u->handle : "");
 //  dprintf(DP_HELP, "PRIVMSG %s :%s knocked, inviting.. (%s)\n", chname, nick, u ? u->handle : "");
   cache_invite(chan, nick, uhost, u ? u->handle : NULL, 0, 0);
   cache_invite(chan, nick, uhost, u ? u->handle : NULL, 0, 0);