Преглед изворни кода

Fix eggdrop 1.8 compatibility

Michael Ortmann пре 5 година
родитељ
комит
3f0e4d9dc3
3 измењених фајлова са 21 додато и 32 уклоњено
  1. 4 0
      UPDATES
  2. 13 20
      core/mini_httpd.c
  3. 4 12
      stats.c

+ 4 - 0
UPDATES

@@ -1,5 +1,9 @@
 Changes in Stats.mod: (since v1.0.1)
 Changes in Stats.mod: (since v1.0.1)
 --------------------
 --------------------
+1.5.0
+- Now also works with eggdrop 1.8. stats 1.4.1 does not work with
+  eggdrop 1.8-rc1+ / git ac1b6ed3f4f949affd7090a053787fb664f4e292+.
+
 1.4.1
 1.4.1
 - Now also works with eggdrop 1.8.
 - Now also works with eggdrop 1.8.
 
 

+ 13 - 20
core/mini_httpd.c

@@ -611,42 +611,35 @@ static void out_http(int idx, char *buf, void *x)
  */
  */
 static void httpd_accept(int idx, char *buf, int len)
 static void httpd_accept(int idx, char *buf, int len)
 {
 {
-  unsigned long ip;
+  sockname_t name;
   unsigned short port;
   unsigned short port;
   int j = 0, sock, i;
   int j = 0, sock, i;
-  char s[UHOSTLEN];
 
 
   Context;
   Context;
-  if (dcc_total + 1 >= max_dcc) {
-    j = answer(dcc[idx].sock, s, &ip, &port, 0);
+  if (dcc_total + 1 > max_dcc && increase_socks_max()) {
+    j = answer(dcc[idx].sock, &name, &port, 0);
     if (j != -1) {
     if (j != -1) {
       dprintf(-j, "Sorry, too many connections already.\r\n");
       dprintf(-j, "Sorry, too many connections already.\r\n");
       killsock(j);
       killsock(j);
     }
     }
     return;
     return;
   }
   }
-  sock = answer(dcc[idx].sock, s, &ip, &port, 0);
-  if (sock < 0) {
-    neterror(s);
-    putlog(LOG_MISC, "*", "HTTPd: Error accepting connection: %s", s);
+  if ((i = new_dcc(&MHTTPD_CON_HTTP, sizeof(struct http_connection_data))) < 0) {
+    putlog(LOG_MISC, "*", "Stats HTTPd error: could not get new dcc.");
     return;
     return;
   }
   }
-  if ((i = new_dcc(&MHTTPD_CON_HTTP, sizeof(struct http_connection_data))) == (-1)) {
-    putlog(LOG_MISC, "*", "Error accepting http connection. DCC table is full.");
-    killsock(sock);
+  sock = answer(dcc[idx].sock, &dcc[i].sockname, &port, 0);
+  while ((sock == -1) && (errno == EAGAIN))
+    sock = answer(dcc[idx].sock, &dcc[i].sockname, &port, 0);
+  if (sock < 0) {
+    putlog(LOG_MISC, "*", "Stats HTTPd error: %s", strerror(errno));
     return;
     return;
   }
   }
   dcc[i].sock = sock;
   dcc[i].sock = sock;
-  dcc[i].addr = ip;
+  // dcc[idx].addr = 0;
   dcc[i].port = port;
   dcc[i].port = port;
-  strcpy(dcc[i].nick, "http");
-#ifndef OLDBOT
-  sprintf(s, "%s", iptostr(my_htonl(ip)));
-#else
-  sprintf(s, "%lu.%lu.%lu.%lu", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
-  	  (ip >> 8) & 0xff, ip & 0xff); /* dw */
-#endif
-  strcpy(dcc[i].host, s);
+  strcpy(dcc[i].nick, "statshttp");
+  // strcpy(dcc[i].host, iptostr(&dcc[idx].sockname.addr.sa));
   dcc[i].timeval = now;
   dcc[i].timeval = now;
   dcc[i].status = 0;
   dcc[i].status = 0;
   // init http_connection_data struct
   // init http_connection_data struct

+ 4 - 12
stats.c

@@ -31,7 +31,7 @@
 
 
 #define MAKING_STATS
 #define MAKING_STATS
 #define MODULE_NAME "stats"
 #define MODULE_NAME "stats"
-#define MODULE_VERSION "1.4.1-dev"
+#define MODULE_VERSION "1.5.0"
 #ifndef NO_EGG
 #ifndef NO_EGG
 #include "../module.h"
 #include "../module.h"
 #include "../irc.mod/irc.h"
 #include "../irc.mod/irc.h"
@@ -467,7 +467,7 @@ char *stats_start(Function * global_funcs)
   chanlangs = NULL;
   chanlangs = NULL;
   slang_glob_init();
   slang_glob_init();
   Context;
   Context;
-  module_register(MODULE_NAME, stats_table, 1, 4);
+  module_register(MODULE_NAME, stats_table, 1, 5);
   if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0)))
   if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0)))
     return "You need the irc module to use the stats module.";
     return "You need the irc module to use the stats module.";
   if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0)))
   if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0)))
@@ -475,16 +475,8 @@ char *stats_start(Function * global_funcs)
   if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0)))
   if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0)))
     return "You need the channels module to use the stats module.";
     return "You need the channels module to use the stats module.";
   if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
   if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
-    if (!module_depend(MODULE_NAME, "eggdrop", 107, 0)) {
-      if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
-        if (!module_depend(MODULE_NAME, "eggdrop", 105, 0)) {
-          if (!module_depend(MODULE_NAME, "eggdrop", 104, 0)) {
-            module_undepend(MODULE_NAME);
-            return "Sorry, stats.mod doesn't work with this eggdrop version.";
-          }
-        }
-      }
-    }
+    module_undepend(MODULE_NAME);
+    return "Sorry, stats.mod requires Eggdrop 1.8.0 or later.";
   }
   }
 #ifndef OLDBOT
 #ifndef OLDBOT
   livestats_timeout = 10;
   livestats_timeout = 10;