1
0
Эх сурвалжийг харах

fixup! Bot linking: Try each IP returned from DNS.

Bryan Drewery 5 сар өмнө
parent
commit
3eeed168b5
4 өөрчлөгдсөн 10 нэмэгдсэн , 63 устгасан
  1. 3 5
      src/botnet.cc
  2. 2 50
      src/dcc.cc
  3. 1 1
      src/dcc.h
  4. 4 7
      src/users.cc

+ 3 - 5
src/botnet.cc

@@ -922,7 +922,7 @@ int botunlink(int idx, const char *nick, const char *reason)
     dprintf(idx, "%s\n", "Unlinking all bots...");
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type && ((nick[0] == '*') || !strcasecmp(dcc[i].nick, nick))) {
-      if (dcc[i].type == &DCC_FORK_BOT || dcc[i].type == &DCC_BOT_CONNWAIT) {
+      if (dcc[i].type == &DCC_FORK_BOT) {
 	if (idx >= 0)
 	  dprintf(idx, "%s: %s -> %s.\n", "Killed link attempt to",
 		  dcc[i].nick, dcc[i].host);
@@ -1034,7 +1034,6 @@ int botlink(const char *linker, int idx, char *nick)
     for (i = 0; i < dcc_total; i++) {
       if (dcc[i].type && (dcc[i].user == u) &&
 	  ((dcc[i].type == &DCC_FORK_BOT) ||
-	   (dcc[i].type == &DCC_BOT_CONNWAIT) ||
 	   (dcc[i].type == &DCC_BOT_NEW))) {
 	if (idx >= 0)
 	  dprintf(idx, "Already linking to that bot\n");
@@ -1140,7 +1139,7 @@ static void botlink_dns_callback(int id, void *client_data, const char *host,
    * ownership of the dns_info from DCC_DNSWAIT without
    * reallocating it.
    */
-  dcc[i].type = &DCC_BOT_CONNWAIT;
+  // dcc[i].type = &DCC_BOT_CONNWAIT;
   dcc[i].u.dns->ips = new bd::Array<bd::String>(ips);
 #ifdef USE_IPV6
   dcc[i].u.dns->no_more_ipv6 = false;
@@ -1155,8 +1154,7 @@ static void botlink_dns_callback(int id, void *client_data, const char *host,
 void
 botlink_next_ip(int i)
 {
-  assert(dcc[i].type == &DCC_BOT_CONNWAIT ||
-      dcc[i].type == &DCC_FORK_BOT);
+  assert(dcc[i].type == &DCC_FORK_BOT);
   struct dns_info *di = dcc[i].u.dns;
   assert(di->ips->size() > 0);
   if (di->ip_from_dns_idx == -1 && di->no_more_ipv6 == true) {

+ 2 - 50
src/dcc.cc

@@ -247,8 +247,7 @@ greet_new_bot(int idx)
       egg_version);
 
   for (int i = 0; i < dcc_total; i++) {
-    if (dcc[i].type &&
-        (dcc[i].type == &DCC_FORK_BOT || dcc[i].type == &DCC_BOT_CONNWAIT)) {
+    if (dcc[i].type && dcc[i].type == &DCC_FORK_BOT) {
       killsock(dcc[i].sock);
       lostdcc(i);
     }
@@ -575,7 +574,7 @@ display_dcc_bot(int idx, char *buf, size_t bufsiz)
 static void
 display_dcc_fork_bot(int idx, char *buf, size_t bufsiz)
 {
-  simple_snprintf(buf, bufsiz, "fork  bot");
+  simple_snprintf(buf, bufsiz, "conn  bot");
 }
 
 struct dcc_table DCC_BOT = {
@@ -591,53 +590,6 @@ struct dcc_table DCC_BOT = {
   NULL
 };
 
-static void dcc_bot_connwait_eof(int idx)
-{
-	putlog(LOG_MISC, "*", "Lost connection while connecting to [%s/%d]",
-	    iptostr(htonl(dcc[idx].addr)), dcc[idx].port);
-	killsock(dcc[idx].sock);
-	lostdcc(idx);
-}
-
-static void dcc_bot_connwait(int idx, char *buf, int len)
-{
-	/* Ignore anything now. */
-}
-
-static void dcc_bot_connwait_timeout(int idx)
-{
-}
-
-static void
-dcc_bot_connwait_display(int idx, char *buf, size_t bufsiz)
-{
-  simple_snprintf(buf, bufsiz, "conn  bot");
-}
-
-static void
-dcc_bot_connwait_free(int idx, void *x)
-{
-  /* free's dcc[idx].u.other (dns_info) */
-  struct dns_info *di = (struct dns_info *)x;
-
-  free_dns_info(di);
-  assert(di == dcc[idx].u.other);
-  dcc[idx].u.other = NULL;
-}
-
-struct dcc_table DCC_BOT_CONNWAIT = {
-  "BOT_CONNWAIT",
-  0,
-  dcc_bot_connwait_eof,
-  dcc_bot_connwait,
-  &connect_timeout,
-  dcc_bot_connwait_timeout,
-  dcc_bot_connwait_display,
-  dcc_bot_connwait_free,
-  NULL,
-  NULL
-};
-
 static void
 fork_bot_eof(int i)
 {

+ 1 - 1
src/dcc.h

@@ -238,7 +238,7 @@ 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_IDENTD, DCC_IDENTD_CONNECT,
- DCC_DNSWAIT, DCC_BOT_CONNWAIT;
+ DCC_DNSWAIT;
 
 void send_timesync(int);
 void failed_link(int);

+ 4 - 7
src/users.cc

@@ -1011,7 +1011,7 @@ static void autolink_cycle_hub(char *start)
    if (dcc[i].type) {
     if (dcc[i].type == &DCC_BOT_NEW)
       return;
-    if (dcc[i].type == &DCC_FORK_BOT || dcc[i].type == &DCC_BOT_CONNWAIT)
+    if (dcc[i].type == &DCC_FORK_BOT)
       return;
     if (dcc[i].type == &DCC_BOT) {
       if (dcc[i].status & (STAT_OFFEREDU | STAT_GETTINGU | STAT_SENDINGU))
@@ -1137,8 +1137,7 @@ static void autolink_cycle_leaf(char *start)
 
   for (int i = 0; i < dcc_total; i++) {
    if (dcc[i].type) {
-    if (dcc[i].type == &DCC_BOT_NEW || dcc[i].type == &DCC_FORK_BOT ||
-        dcc[i].type == &DCC_BOT_CONNWAIT)
+    if ((dcc[i].type == &DCC_BOT_NEW) || (dcc[i].type == &DCC_FORK_BOT))
       return;
     if (dcc[i].hub && dcc[i].type == &DCC_BOT) {
       strlcpy(curhub, dcc[i].nick, sizeof(curhub));
@@ -1211,8 +1210,7 @@ void autolink_cycle()
       // Make sure not already trying for the localhub
       for (int i = 0; i < dcc_total; i++) {
        if (dcc[i].type) {
-         if (dcc[i].type == &DCC_BOT_NEW || dcc[i].type == &DCC_FORK_BOT ||
-             dcc[i].type == &DCC_BOT_CONNWAIT)
+        if ((dcc[i].type == &DCC_BOT_NEW) || (dcc[i].type == &DCC_FORK_BOT))
           return;
        }
       }
@@ -1230,8 +1228,7 @@ void check_stale_dcc_users()
     
 
     if (dcc[i].user == NULL && !(dcc[i].user = get_user_by_handle(userlist, dcc[i].nick))) { /* Removed user */
-      if (dcc[i].type == &DCC_BOT || dcc[i].type == &DCC_FORK_BOT ||
-          dcc[i].type == &DCC_BOT_NEW || dcc[i].type == &DCC_BOT_CONNWAIT)
+      if (dcc[i].type == &DCC_BOT || dcc[i].type == &DCC_FORK_BOT || dcc[i].type == &DCC_BOT_NEW)
         botunlink(i, dcc[i].nick, "No longer a valid bot.");
       else if (dcc[i].type == &DCC_CHAT) {
         if (!backgrd && term_z && !strcmp(dcc[i].nick, "HQ"))