ソースを参照

Merge branch 'maint'

* maint:
  Auto initiate key exchange if the message is invalid.
  Add a reason when initiating FiSH key exchange
  Make server cycle time configurable and default it to 30.
  Disallow netative limit.
Bryan Drewery 10 年 前
コミット
8e2dbe0e85

+ 6 - 0
doc/UPDATES.md

@@ -21,6 +21,12 @@
     was relinked.
   * Raise netsplit timeout to 1000 seconds.
   * Indent BOTNET entries some in .whois.
+  * Disallow negative 'chanset limit' (#96).
+  * Raise server cycle time from 15 to 30 seconds and add
+    'set server-cycle-wait for configuring it. (#81)
+  * Show reason when initiating FiSH Key exchange
+  * Auto initiate FiSH key exchange (with fish-auto=1) when invalid message
+    received. (Invalid or unknown key) (#74)
 
 # 1.4.6
   * Disable demo TCL support by default to prevent confusion during build.

+ 1 - 0
doc/help.txt

@@ -1660,6 +1660,7 @@ See also: reload, backup
                          matching alias is used. Normal flag checking is done
                          after the alias is expanded. 
                          $bAliases may not reference other aliases.$b
+[N]  $bserver-cycle-wait$b   Amount of time in seconds to wait between server reconnections.
 [N]  $bserver-port$b         Default port to use for server connections.
 [N]  $bserver-port-ssl$b     Default port to use for SSL server connections.
 [B]  $bserver-use-ssl$b      Use SSL for IRC server connections?

+ 3 - 2
src/chanprog.cc

@@ -913,14 +913,15 @@ void notice(bd::String target, bd::String msg, int idx) {
 }
 
 
-void keyx(const bd::String &target) {
+void keyx(const bd::String &target, const char *reason) {
   bd::String myPublicKeyB64, myPrivateKey, sharedKey;
 
   DH1080_gen(myPrivateKey, myPublicKeyB64);
 
   fish_data_t* fishData = FishKeys.contains(target) ? FishKeys[target] : new fish_data_t;
   fishData->sharedKey.clear();
-  putlog(LOG_MSGS, "*", "[FiSH] Initiating DH1080 key-exchange with %s - sending my public key", target.c_str());
+  putlog(LOG_MSGS, "*", "[FiSH] Initiating DH1080 key-exchange with %s - "
+      "sending my public key (%s)", target.c_str(), reason);
   notice(target, "DH1080_INIT " + myPublicKeyB64, DP_HELP);
   fishData->myPublicKeyB64 = myPublicKeyB64;
   fishData->myPrivateKey = myPrivateKey;

+ 1 - 1
src/chanprog.h

@@ -33,7 +33,7 @@ void load_internal_users();
 void setup_HQ(int);
 void privmsg(bd::String target, bd::String msg, int idx);
 void notice(bd::String target, bd::String msg, int idx);
-void keyx(const bd::String& target);
+void keyx(const bd::String& target, const char *);
 void set_fish_key(char *, bd::String);
 struct userrec *check_chanlist(const char *);
 struct userrec *check_chanlist_hand(const char *);

+ 7 - 1
src/mod/channels.mod/chanmisc.cc

@@ -385,7 +385,13 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
           strlcpy(result, "channel limit needs argument", RESULT_LEN);
         return ERROR;
       }
-      if (chan->limitraise && !atoi(item[i]) && dolimit(chan)) //limitraise was disabled by the user
+      int limitraise = atoi(item[i]);
+      if (limitraise < 0) {
+        if (result)
+          strlcpy(result, "channel limit must be a positive number", RESULT_LEN);
+        return ERROR;
+      }
+      if (chan->limitraise && limitraise == 0 && dolimit(chan)) //limitraise was disabled by the user
         add_mode(chan, '-', 'l', "");
       chan->limitraise = atoi(item[i]);
       chan->limit_prot = 0;

+ 1 - 1
src/mod/server.mod/cmdsserv.cc

@@ -124,7 +124,7 @@ static void cmd_keyx(int idx, char *par) {
   }
 
   char *nick = newsplit(&par);
-  keyx(nick);
+  keyx(nick, "Requested");
   return;
 }
 

+ 8 - 4
src/mod/server.mod/servmsg.cc

@@ -164,6 +164,7 @@ static int check_bind_raw(char *from, char *code, char *msg)
     ++colon;
     if (colon) {
       if (!strncmp(colon, "+OK ", 4)) {
+        bool isValidCipherText;
         char *p = strchr(from, '!');
         const bool target_is_chan = strchr(CHANMETA, target[0]);
         bd::String ciphertext(colon), sharedKey, nick(from, p - from), key_target;
@@ -191,7 +192,7 @@ static int check_bind_raw(char *from, char *code, char *msg)
           // Decrypt the message before passing along to the binds
           const bd::String decrypted(egg_bf_decrypt(ciphertext, sharedKey));
           // Does the decrypted text make sense? If not, the key is probably invalid, reset it.
-          bool isValidCipherText = true;
+          isValidCipherText = true;
           for (size_t i = 0; i < decrypted.length(); ++i) {
             if (!isprint(decrypted[i])) {
               isValidCipherText = false;
@@ -208,6 +209,9 @@ static int check_bind_raw(char *from, char *code, char *msg)
             delete fishData;
           }
         }
+        if (fish_auto_keyx && !isValidCipherText && !target_is_chan) {
+          keyx(nick, "Invalid/Unknown key");
+        }
       }
     }
   }
@@ -799,7 +803,7 @@ static int gotmsg(char *from, char *msg)
         if (my_u && FishKeys.contains(nick)) {
           // FiSH paranoid mode. Invalidate the current key and re-key-exchange with the user.
           if (fish_paranoid) {
-            keyx(nick);
+            keyx(nick, "fish-paranoid is set");
           }
         }
       }
@@ -1978,7 +1982,7 @@ static int got718(char *from, char *msg)
         dprintf(DP_HELP, "ACCEPT %s\n", nick);
         dprintf(DP_HELP, "PRIVMSG %s :You have been accepted. Please send your message again.\n", nick);
         if (fish_auto_keyx) {
-          keyx(nick);
+          keyx(nick, "Callerid accepted");
         }
       } else {
         putlog(LOG_WALL, "*", "(CALLERID) !%s! (%s!%s) %s (User is not +o or +v)", u->handle, nick, uhost, msg);
@@ -2104,7 +2108,7 @@ static void connect_server(void)
     dcc[newidx].sock = -1;
     dcc[newidx].u.dns->cbuf = strdup(pass);
 
-    cycle_time = 15;		/* wait 15 seconds before attempting next server connect */
+    cycle_time = server_cycle_wait;		/* wait N seconds before attempting next server connect */
 
     /* I'm resolving... don't start another server connect request */
     resolvserv = 1;

+ 2 - 0
src/set.cc

@@ -75,6 +75,7 @@ char homechan[51] = "";
 char usermode[15] = "";
 bool fish_auto_keyx = 0;
 bool fish_paranoid = 0;
+int server_cycle_wait;
 
 ////// THIS MUST REMAIN SORTED: !LC_ALL=C sort
 // VAR("bad-process",	&badprocess,		VAR_INT|VAR_DETECTED,				0, 4, "ignore"),
@@ -126,6 +127,7 @@ static variable_t vars[] = {
  VAR("promisc",		&promisc,		VAR_INT|VAR_DETECTED,				0, 4, "ignore"),
  VAR("rbl-servers",	rbl_servers,		VAR_STRING|VAR_LIST|VAR_SHUFFLE|VAR_NOLHUB,	0, 0, DEFAULT_RBL),
  VAR("realname",	botrealname,		VAR_STRING|VAR_NOLHUB,				0, 0, "* I'm too lame to read BitchX.doc *"),
+ VAR("server-cycle-wait",&server_cycle_wait,	VAR_INT|VAR_NOLHUB,				5, 500, "30"),
  VAR("server-port",	&default_port,		VAR_INT|VAR_SHORT|VAR_NOLHUB,			0, 65535, "6667"),
  VAR("server-port-ssl",	&default_port_ssl,	VAR_INT|VAR_SHORT|VAR_NOLHUB,			0, 65535, "6697"),
  VAR("server-use-ssl",	&ssl_use,		VAR_INT|VAR_BOOL|VAR_NOLHUB,			0, 1, "0"),

+ 2 - 2
src/set.h

@@ -20,7 +20,7 @@
 #define VAR_SHUFFLE	BIT9
 /* no local */
 #define VAR_NOLOC	BIT10	
-/* no local hub */
+/* no hub local */
 #define VAR_NOLHUB	BIT11
 /* trigger cloak script changing? */
 #define VAR_CLOAK	BIT12
@@ -73,7 +73,7 @@ extern char		auth_key[], auth_prefix[2], motd[], alias[], rbl_servers[1024], gro
 extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext, use_deaf, use_callerid, fish_auto_keyx, fish_paranoid;
 extern int		cloak_script, fight_threshold, in_bots, set_noshare, dcc_autoaway,
 			kill_threshold, lag_threshold, op_bots, hijack, login, promisc, trace,
-                        ison_time, msgrate, msgburst;
+                        ison_time, msgrate, msgburst, server_cycle_wait;
 extern rate_t		op_requests, close_threshold;
 
 namespace bd {