Przeglądaj źródła

* Hacked out dns.mod
* Fixed a small bug in msgcmds.c


svn: 655

Bryan Drewery 22 lat temu
rodzic
commit
7958355e4b
9 zmienionych plików z 23 dodań i 54 usunięć
  1. 1 0
      src/dns.c
  2. 0 2
      src/dns.h
  3. 1 1
      src/main.c
  4. 3 3
      src/mod/dns.mod/coredns.c
  5. 10 27
      src/mod/dns.mod/dns.c
  6. 7 0
      src/mod/dns.mod/dns.h
  7. 0 1
      src/mod/irc.mod/msgcmds.c
  8. 1 2
      src/mod/static.h
  9. 0 18
      src/modules.c

+ 1 - 0
src/dns.c

@@ -10,6 +10,7 @@
 #include "dccutil.h"
 #include "net.h"
 #include "misc.h"
+#include "src/mod/dns.mod/dns.h"
 #include <netdb.h>
 #include <setjmp.h>
 #include <sys/socket.h>

+ 0 - 2
src/dns.h

@@ -50,8 +50,6 @@ typedef struct devent_str {
   void		*other;		/* Data specific to the event type */
 } devent_t;
 
-extern void (*dns_hostbyip) (IP);
-extern void (*dns_ipbyhost) (char *);
 void block_dns_hostbyip(IP);
 void block_dns_ipbyhost(char *);
 void call_hostbyip(IP, char *, int);

+ 1 - 1
src/main.c

@@ -1198,7 +1198,7 @@ int main(int argc, char **argv)
     } /* localhub */
 #endif /* LEAF */
   }
-  module_load("dns");
+  dns_init();
   module_load("channels");
 #ifdef LEAF
   module_load("server");

+ 3 - 3
src/mod/dns.mod/coredns.c

@@ -824,7 +824,7 @@ static void parserespacket(u_8bit_t *s, int l)
 				ddebug1(RES_ERR "Unsupported rdata format for \"A\" type. (%u bytes)", rdatalength);
 				return;
 			    }
-			    my_memcpy(&rp->ip, (IP *) c, sizeof(IP));
+			    egg_memcpy(&rp->ip, (IP *) c, sizeof(IP));
 			    linkresolveip(rp);
 			    passrp(rp, ttl, T_A);
 			    return;
@@ -985,7 +985,7 @@ static void dns_check_expires(void)
 
 /* Start searching for a host-name, using it's ip-address.
  */
-static void dns_lookup(IP ip)
+void dns_hostbyip(IP ip)
 {
     struct resolve *rp;
 
@@ -1015,7 +1015,7 @@ static void dns_lookup(IP ip)
 
 /* Start searching for an ip-address, using it's host-name.
  */
-static void dns_forward(char *hostn)
+void dns_ipbyhost(char *hostn)
 {
     struct resolve *rp;
     struct in_addr inaddr;

+ 10 - 27
src/mod/dns.mod/dns.c

@@ -6,17 +6,18 @@
  *
  */
 
-#define MODULE_NAME "dns"
-
-#include "src/mod/module.h"
+#undef MAKING_MODS
 #include "dns.h"
+#include "src/common.h"
+#include "src/dccutil.h"
+#include "src/modules.h"
+#include "src/main.h"
+#include "src/types.h"
 
 static void dns_event_success(struct resolve *rp, int type);
 static void dns_event_failure(struct resolve *rp, int type);
 
 
-static Function *global = NULL;
-
 #include "coredns.c"
 
 
@@ -105,7 +106,7 @@ static struct dcc_table DCC_DNS =
  *    DNS module related code
  */
 
-static int dns_report(int idx, int details)
+int dns_report(int idx, int details)
 {
   if (details) {
     dprintf(idx, "    DNS resolver is active.\n");
@@ -113,38 +114,20 @@ static int dns_report(int idx, int details)
   return 0;
 }
 
-EXPORT_SCOPE char *dns_start();
-
-static Function dns_table[] =
-{
-  /* 0 - 3 */
-  (Function) dns_start,
-  (Function) NULL,
-  (Function) 0,
-  (Function) dns_report,
-  /* 4 - 7 */
-};
-
-char *dns_start(Function *global_funcs)
+void dns_init()
 {
   int idx;
 
-  global = global_funcs;
-  module_register(MODULE_NAME, dns_table, 1, 0);
-
   idx = new_dcc(&DCC_DNS, 0);
   if (idx < 0)
-    return "NO MORE DCC CONNECTIONS -- Can't create DNS socket.";
+    fatal("NO MORE DCC CONNECTIONS -- Can't create DNS socket.", 1);
   if (!init_dns_core()) {
     lostdcc(idx);
-    return "DNS initialisation failed.";
+    fatal("DNS initialisation failed.", 1);
   }
   dcc[idx].sock = resfd;
   dcc[idx].timeval = now;
   strcpy(dcc[idx].nick, "(dns)");
 
   add_hook(HOOK_SECONDLY, (Function) dns_check_expires);
-  add_hook(HOOK_DNS_HOSTBYIP, (Function) dns_lookup);
-  add_hook(HOOK_DNS_IPBYHOST, (Function) dns_forward);
-  return NULL;
 }

+ 7 - 0
src/mod/dns.mod/dns.h

@@ -19,6 +19,9 @@
 #ifndef _EGG_MOD_DNS_DNS_H
 #define _EGG_MOD_DNS_DNS_H
 
+#include "src/common.h"
+#include "src/types.h"
+
 struct resolve {
     struct resolve	*next;
     struct resolve	*previous;
@@ -60,4 +63,8 @@ enum resolve_states {
 # define ddebug4(x, x1, x2, x3, x4)
 #endif	/* !DEBUG_DNS */
 
+int dns_report(int, int);
+void dns_hostbyip(IP);
+void dns_ipbyhost(char *);
+
 #endif	/* _EGG_MOD_DNS_DNS_H */

+ 0 - 1
src/mod/irc.mod/msgcmds.c

@@ -263,7 +263,6 @@ static int msg_auth(char *nick, char *host, struct userrec *u, char *par)
       make_rand_str(rand, 50);
       strncpyz(auth[i].hash, makehash(u, rand), sizeof auth[i].hash);
       dprintf(DP_HELP, "PRIVMSG %s :-Auth %s %s\n", nick, rand, botnetnick);
-    }
   } else {
     putlog(LOG_CMDS, "*", "(%s!%s) !%s! failed -AUTH", nick, host, u->handle);
     removeauth(i);

+ 1 - 2
src/mod/static.h

@@ -7,7 +7,6 @@
 
 char *channels_start();
 char *compress_start();
-char *dns_start();
 #ifdef LEAF
 char *irc_start();
 char *server_start();
@@ -15,6 +14,7 @@ char *server_start();
 char *share_start();
 char *transfer_start();
 
+void dns_init();
 void console_init();
 void ctcp_init();
 void update_init();
@@ -24,7 +24,6 @@ static void link_statics()
 {
   check_static("channels", channels_start);
   check_static("compress", compress_start);
-  check_static("dns", dns_start);
 #ifdef LEAF
   check_static("irc", irc_start);
   check_static("server", server_start);

+ 0 - 18
src/modules.c

@@ -150,8 +150,6 @@ int (*rfc_casecmp) (const char *, const char *) = _rfc_casecmp;
 int (*rfc_ncasecmp) (const char *, const char *, int) = _rfc_ncasecmp;
 int (*rfc_toupper) (int) = _rfc_toupper;
 int (*rfc_tolower) (int) = _rfc_tolower;
-void (*dns_hostbyip) (IP) = block_dns_hostbyip;
-void (*dns_ipbyhost) (char *) = block_dns_ipbyhost;
 
 module_entry *module_list;
 dependancy *dependancy_list = NULL;
@@ -825,14 +823,6 @@ void add_hook(int hook_num, Function func)
 	rfc_toupper = _rfc_toupper;
       }
       break;
-    case HOOK_DNS_HOSTBYIP:
-      if (dns_hostbyip == block_dns_hostbyip)
-	dns_hostbyip = (void (*)(IP)) func;
-      break;
-    case HOOK_DNS_IPBYHOST:
-      if (dns_ipbyhost == block_dns_ipbyhost)
-	dns_ipbyhost = (void (*)(char *)) func;
-      break;
     }
 }
 
@@ -875,14 +865,6 @@ void del_hook(int hook_num, Function func)
       if (add_mode == (void (*)()) func)
 	add_mode = null_func;
       break;
-    case HOOK_DNS_HOSTBYIP:
-      if (dns_hostbyip == (void (*)(IP)) func)
-	dns_hostbyip = block_dns_hostbyip;
-      break;
-    case HOOK_DNS_IPBYHOST:
-      if (dns_ipbyhost == (void (*)(char *)) func)
-	dns_ipbyhost = block_dns_ipbyhost;
-      break;
     }
 }