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

* Remove old dns system

svn: 1469
Bryan Drewery 21 лет назад
Родитель
Сommit
06d7644d70
7 измененных файлов с 2 добавлено и 312 удалено
  1. 1 0
      doc/UPDATES
  2. 0 1
      src/Makefile.in
  3. 0 1
      src/dcc.c
  4. 1 4
      src/dcc.h
  5. 0 246
      src/dns.c
  6. 0 59
      src/dns.h
  7. 0 1
      src/mod/server.mod/server.c

+ 1 - 0
doc/UPDATES

@@ -59,6 +59,7 @@ This is a summary of ChangeLog basically.
 * Added chanint closed-invite, when set to 0, channel will NOT be +i.
 * cmd_su/cmd_relay no longer work through .botcmd
 * Added some simple dcc ip sanity checking back in.
+* All dns resolving is now asynchronous, all dns bugs now fixed.
 
 1.1.9
 

+ 0 - 1
src/Makefile.in

@@ -29,7 +29,6 @@ OBJS = auth.o \
 	dcc.o \
 	dccutil.o \
 	debug.o \
-	dns.o \
 	egg_timer.o \
 	flags.o \
 	garble.o \

+ 0 - 1
src/dcc.c

@@ -21,7 +21,6 @@
 #include "userrec.h"
 #include "userent.h"
 #include "match.h"
-#include "dns.h"
 #include "auth.h"
 #include "dccutil.h"
 #include "crypt.h"

+ 1 - 4
src/dcc.h

@@ -8,7 +8,6 @@
 #include "types.h"
 #include "crypt.h"
 #include "eggdrop.h"
-#include "dns.h"
 
 /* Public structure of all the dcc connections */
 struct dcc_table {
@@ -34,10 +33,8 @@ struct dcc_t {
     struct xfer_info *xfer;
     struct bot_info *bot;
     struct relay_info *relay;
-    struct dns_info *dns;
     struct dupwait_info *dupwait;
     int ident_sock;
-    int dns_id;
     void *other;
   } u;                          /* Special use depending on type        */
 
@@ -221,7 +218,7 @@ extern char			network[];
 extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_BOT_NEW,
  DCC_RELAY, DCC_RELAYING, DCC_FORK_RELAY, DCC_PRE_RELAY, DCC_CHAT_PASS,
  DCC_FORK_BOT, DCC_SOCKET, DCC_TELNET_ID, DCC_TELNET_NEW, DCC_TELNET_PW,
- DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_DNSWAIT, DCC_IDENTD, DCC_IDENTD_CONNECT;
+ DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_IDENTD, DCC_IDENTD_CONNECT;
 
 #ifdef HUB
 void send_timesync(int);

+ 0 - 246
src/dns.c

@@ -1,246 +0,0 @@
-/*
- * dns.c -- handles:
- *   DNS resolve calls and events
- *   provides the code used by the bot if the DNS module is not loaded
- *   DNS Tcl commands
- *
- */
-
-#include "common.h"
-#include "dccutil.h"
-#include "main.h"
-#include "net.h"
-#include "misc.h"
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "dns.h"
-
-devent_t	*dns_events = NULL;
-
-
-/*
- *   DCC functions
- */
-
-void dcc_dnswait(int idx, char *buf, int len)
-{
-  /* Ignore anything now. */
-}
-
-void eof_dcc_dnswait(int idx)
-{
-  putlog(LOG_MISC, "*", "Lost connection while resolving hostname [%s/%d]",
-	 iptostr(htonl(dcc[idx].addr)), dcc[idx].port);
-  killsock(dcc[idx].sock);
-  lostdcc(idx);
-}
-
-static void display_dcc_dnswait(int idx, char *buf)
-{
-  sprintf(buf, "dns   waited %lis", now - dcc[idx].timeval);
-}
-
-static void kill_dcc_dnswait(int idx, void *x)
-{
-  register struct dns_info *p = (struct dns_info *) x;
-
-  if (p) {
-    if (p->host)
-      free(p->host);
-    if (p->cbuf)
-      free(p->cbuf);
-    free(p);
-  }
-}
-
-struct dcc_table DCC_DNSWAIT =
-{
-  "DNSWAIT",
-  DCT_VALIDIDX,
-  eof_dcc_dnswait,
-  dcc_dnswait,
-  NULL,
-  NULL,
-  display_dcc_dnswait,
-  kill_dcc_dnswait,
-  NULL,
-  NULL
-};
-
-
-/*
- *   DCC events
- */
-
-/* Walk through every dcc entry and look for waiting DNS requests
- * of RES_HOSTBYIP for our IP address.
- */
-static void dns_dcchostbyip(in_addr_t ip, char *hostn, int ok, void *other)
-{
-  for (int idx = 0; idx < dcc_total; idx++) {
-    if (dcc[idx].type && (dcc[idx].type == &DCC_DNSWAIT) &&
-        (dcc[idx].u.dns->dns_type == RES_HOSTBYIP) &&
-        (dcc[idx].u.dns->ip == ip)) {
-      if (dcc[idx].u.dns->host)
-        free(dcc[idx].u.dns->host);
-      dcc[idx].u.dns->host = (char *) calloc(1, strlen(hostn) + 1);
-      strcpy(dcc[idx].u.dns->host, hostn);
-      if (ok)
-        dcc[idx].u.dns->dns_success(idx);
-      else
-        dcc[idx].u.dns->dns_failure(idx);
-    }
-  }
-}
-
-/* Walk through every dcc entry and look for waiting DNS requests
- * of RES_IPBYHOST for our hostname.
- */
-static void dns_dccipbyhost(in_addr_t ip, char *hostn, int ok, void *other)
-{
-  for (int idx = 0; idx < dcc_total; idx++) {
-    if (dcc[idx].type && (dcc[idx].type == &DCC_DNSWAIT) &&
-        (dcc[idx].u.dns->dns_type == RES_IPBYHOST) &&
-        !egg_strcasecmp(dcc[idx].u.dns->host, hostn)) {
-      dcc[idx].u.dns->ip = ip;
-      if (ok)
-        dcc[idx].u.dns->dns_success(idx);
-      else
-        dcc[idx].u.dns->dns_failure(idx);
-    }
-  }
-}
-
-devent_type DNS_DCCEVENT_HOSTBYIP = {
-  "DCCEVENT_HOSTBYIP",
-  dns_dcchostbyip
-};
-
-devent_type DNS_DCCEVENT_IPBYHOST = {
-  "DCCEVENT_IPBYHOST",
-  dns_dccipbyhost
-};
-
-void dcc_dnsipbyhost(char *hostn)
-{
-  devent_t *de = NULL;
-
-  for (de = dns_events; de; de = de->next) {
-    if (de->type && (de->type == &DNS_DCCEVENT_IPBYHOST) &&
-	(de->lookup == RES_IPBYHOST)) {
-      if (de->res_data.hostname &&
-	  !egg_strcasecmp(de->res_data.hostname, hostn))
-	/* No need to add anymore. */
-	return;
-    }
-  }
-
-  de = (devent_t *) calloc(1, sizeof(devent_t));
-
-  /* Link into list. */
-  de->next = dns_events;
-  dns_events = de;
-
-  de->type = &DNS_DCCEVENT_IPBYHOST;
-  de->lookup = RES_IPBYHOST;
-  de->res_data.hostname = strdup(hostn);
-
-  /* Send request. */
-//  dns_ipbyhost(hostn);
-}
-
-void dcc_dnshostbyip(in_addr_t ip)
-{
-  devent_t *de = NULL;
-
-  for (de = dns_events; de; de = de->next) {
-    if (de->type && (de->type == &DNS_DCCEVENT_HOSTBYIP) &&
-	(de->lookup == RES_HOSTBYIP)) {
-      if (de->res_data.ip_addr == ip)
-	/* No need to add anymore. */
-	return;
-    }
-  }
-
-  de = (devent_t *) calloc(1, sizeof(devent_t));
-
-  /* Link into list. */
-  de->next = dns_events;
-  dns_events = de;
-
-  de->type = &DNS_DCCEVENT_HOSTBYIP;
-  de->lookup = RES_HOSTBYIP;
-  de->res_data.ip_addr = ip;
-
-  /* Send request. */
-//  dns_hostbyip(ip);
-}
-
-
-
-/*
- *    Event functions
- */
-
-void call_hostbyip(in_addr_t ip, char *hostn, int ok)
-{
-  devent_t *de = dns_events, *ode = NULL, *nde = NULL;
-
-  while (de) {
-    nde = de->next;
-    if ((de->lookup == RES_HOSTBYIP) &&
-	(!de->res_data.ip_addr || (de->res_data.ip_addr == ip))) {
-      /* Remove the event from the list here, to avoid conflicts if one of
-       * the event handlers re-adds another event. */
-      if (ode)
-	ode->next = de->next;
-      else
-	dns_events = de->next;
-
-      if (de->type && de->type->event)
-	de->type->event(ip, hostn, ok, de->other);
-      else
-	putlog(LOG_MISC, "*", "(!) Unknown DNS event type found: %s",
-	       (de->type && de->type->name) ? de->type->name : "<empty>");
-      free(de);
-      de = ode;
-    }
-    ode = de;
-    de = nde;
-  }
-}
-
-void call_ipbyhost(char *hostn, in_addr_t ip, int ok)
-{
-  devent_t *de = dns_events, *ode = NULL, *nde = NULL;
-
-  while (de) {
-    nde = de->next;
-    if ((de->lookup == RES_IPBYHOST) &&
-	(!de->res_data.hostname ||
-	 !egg_strcasecmp(de->res_data.hostname, hostn))) {
-      /* Remove the event from the list here, to avoid conflicts if one of
-       * the event handlers re-adds another event. */
-      if (ode)
-	ode->next = de->next;
-      else
-	dns_events = de->next;
-
-      if (de->type && de->type->event)
-	de->type->event(ip, hostn, ok, de->other);
-      else
-	putlog(LOG_MISC, "*", "(!) Unknown DNS event type found: %s",
-	       (de->type && de->type->name) ? de->type->name : "<empty>");
-
-      if (de->res_data.hostname)
-	free(de->res_data.hostname);
-      free(de);
-      de = ode;
-    }
-    ode = de;
-    de = nde;
-  }
-}

+ 0 - 59
src/dns.h

@@ -1,59 +0,0 @@
-/*
- * dns.h
- *   stuff used by dns.c
- *
- */
-
-#ifndef _EGG_DNS_H
-#define _EGG_DNS_H
-
-#include "types.h"
-#include "dcc.h"
-
-/* Flags for dns_type
- */
-#define RES_HOSTBYIP  1         /* hostname to IP address               */
-#define RES_IPBYHOST  2         /* IP address to hostname               */
-
-struct dns_info {
-  struct dcc_table *type;       /* type of the dcc table we are making the
-                                   lookup for                              */
-  in_addr_t ip;                        /* IP address                              */
-  int ibuf;                     /* temporary buffer for one integer        */
-  void (*dns_success)(int);     /* is called if the dns request succeeds   */
-  void (*dns_failure)(int);     /* is called if it fails                   */
-  char *host;                   /* hostname                                */
-  char *cbuf;                   /* temporary buffer. Memory will be free'd
-                                   as soon as dns_info is free'd           */
-  char *cptr;                   /* temporary pointer                       */
-  char dns_type;                /* lookup type, e.g. RES_HOSTBYIP          */
-};
-
-typedef struct {
-  char *name;
-  void (*event)(in_addr_t, char *, int, void *);
-} devent_type;
-
-typedef struct {
-  char *proc;			/* Tcl proc			  */
-  char *paras;			/* Additional parameters	  */
-} devent_tclinfo_t;
-
-typedef struct devent_str {
-  struct devent_str *next;	/* Pointer to next dns_event	  */
-  devent_type	*type;
-  union {
-    in_addr_t		ip_addr;	/* IP address			  */
-    char	*hostname; 	/* Hostname			  */
-  } res_data;
-  void		*other;		/* Data specific to the event type */
-  u_8bit_t	lookup;		/* RES_IPBYHOST or RES_HOSTBYIP	  */
-} devent_t;
-
-void call_hostbyip(in_addr_t, char *, int);
-void call_ipbyhost(char *, in_addr_t, int);
-void dcc_dnshostbyip(in_addr_t);
-void dcc_dnsipbyhost(char *);
-
-
-#endif	/* _EGG_DNS_H */

+ 0 - 1
src/mod/server.mod/server.c

@@ -19,7 +19,6 @@
 #include "src/chanprog.h"
 #include "src/net.h"
 #include "src/auth.h"
-#include "src/dns.h"
 #include "src/adns.h"
 #include "src/socket.h"
 #include "src/egg_timer.h"