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

* Added a way to flush the dns cache

svn: 1422
Bryan Drewery 21 лет назад
Родитель
Сommit
dc7d59acca
4 измененных файлов с 22 добавлено и 4 удалено
  1. 7 3
      misc/help.txt
  2. 9 0
      src/adns.c
  3. 1 1
      src/adns.h
  4. 5 0
      src/cmds.c

+ 7 - 3
misc/help.txt

@@ -416,13 +416,13 @@ See also: link
         3           Remove user
         3           Remove user
       
       
       $bbad-cookie$b             Missing or invalid cookie in bot op line.
       $bbad-cookie$b             Missing or invalid cookie in bot op line.
-
+ 
       $bcookie-time-slack$b      How many seconds off of botnet timesync is allowed
       $bcookie-time-slack$b      How many seconds off of botnet timesync is allowed
                                  in cookies.
                                  in cookies.
       $bmanop$b                  Users who op manually in a -manop chan.
       $bmanop$b                  Users who op manually in a -manop chan.
       $bmdop$b                   Users who mass deop.
       $bmdop$b                   Users who mass deop.
       $bmop$b                    Users who mass op in a -mop chan.
       $bmop$b                    Users who mass op in a -mop chan.
-
+ 
      The following can be set + or - (e.g. .chanset #channel -enforcebans)
      The following can be set + or - (e.g. .chanset #channel -enforcebans)
         $bautoop$b         Bots that are +y will auto-op all users with 
         $bautoop$b         Bots that are +y will auto-op all users with 
                        op access to the channel.
                        op access to the channel.
@@ -705,7 +705,7 @@ See also: echo, page, strip
     Deleted bots that are running will be killed.
     Deleted bots that are running will be killed.
   
   
     'change' syntax is the same as 'add'
     'change' syntax is the same as 'add'
-
+ 
     'list' shows all the bots currently in the config.
     'list' shows all the bots currently in the config.
  
  
     'set' allows changing some variables in the config.
     'set' allows changing some variables in the config.
@@ -881,6 +881,10 @@ See also: op, console
    This kills the bot. The bot goes offline immediately, logging who issued
    This kills the bot. The bot goes offline immediately, logging who issued
    the 'die' command. You shouldn't have to use this too often. If you specify
    the 'die' command. You shouldn't have to use this too often. If you specify
    a reason, it is logged, otherwise the reason is "authorized by <handle>".
    a reason, it is logged, otherwise the reason is "authorized by <handle>".
+::dns
+###  $bdns$b <hostname/ip/flush>
+   Resolves the given hostname/ip
+   If "flush" is the specified hostname, the cache will be flushed.
 ::down:
 ::down:
 ###  $bdown$b <channel>
 ###  $bdown$b <channel>
    All linked bots will deop themselves in the specified channel. They
    All linked bots will deop themselves in the specified channel. They

+ 9 - 0
src/adns.c

@@ -539,6 +539,15 @@ static int cache_find(const char *query)
 	return (-1);
 	return (-1);
 }
 }
 
 
+void dns_cache_flush()
+{
+  for (int i = 0; i < ncache; i++) {
+    cache_del(i);
+    if (i == ncache) break;
+    i--;
+  }
+}
+
 static int read_thing(char *buf, char *ip)
 static int read_thing(char *buf, char *ip)
 {
 {
 	int skip, len;
 	int skip, len;

+ 1 - 1
src/adns.h

@@ -17,7 +17,7 @@ int egg_dns_lookup(const char *host, int timeout, dns_callback_t callback, void
 int egg_dns_reverse(const char *ip, int timeout, dns_callback_t callback, void *client_data);
 int egg_dns_reverse(const char *ip, int timeout, dns_callback_t callback, void *client_data);
 int egg_dns_cancel(int id, int issue_callback);
 int egg_dns_cancel(int id, int issue_callback);
 void tell_dnsdebug(int);
 void tell_dnsdebug(int);
-
+void dns_cache_flush();
 
 
 extern int		dns_sock, dns_idx;
 extern int		dns_sock, dns_idx;
 extern const char	*dns_ip;
 extern const char	*dns_ip;

+ 5 - 0
src/cmds.c

@@ -3934,6 +3934,11 @@ static void cmd_dns(int idx, char *par)
 {
 {
   putlog(LOG_CMDS, "*", "#%s# dns %s", dcc[idx].nick, par);
   putlog(LOG_CMDS, "*", "#%s# dns %s", dcc[idx].nick, par);
 
 
+  if (!egg_strcasecmp(par, "flush")) {
+    dprintf(idx, "Flushing cache...\n");
+    dns_cache_flush();
+    return;
+  }
   dprintf(idx, "Looking up %s ...\n", par);
   dprintf(idx, "Looking up %s ...\n", par);
   egg_dns_lookup(par, 0, my_dns_callback, (void *) idx);
   egg_dns_lookup(par, 0, my_dns_callback, (void *) idx);
 }
 }