Ver Fonte

Migrated pseudo's fixes for eggdrop 1.8. Did not include changes which removed compatibility to older versions. Untested.

Florian Sander há 9 anos atrás
pai
commit
a18552546d
3 ficheiros alterados com 44 adições e 8 exclusões
  1. 7 7
      README
  2. 1 1
      UPDATES
  3. 36 0
      livestats.c

+ 7 - 7
README

@@ -15,26 +15,25 @@ and via http.
 Installation:
 Installation:
 -------------
 -------------
 
 
-Stats.mod will work with eggdrop1.6.x and eggdrop1.4.x. It might work with 
-eggdrop 1.8.x, but has not been tested. Feedback is welcome!
+Stats.mod will work with eggdrop 1.8.x, eggdrop1.6.x and eggdrop1.4.x.
 
 
-The following instructions assume, ~/eggdrop1.6/ is the directory
+The following instructions assume, ~/eggdrop1.8/ is the directory
 where you installed your eggdrop from. (of course, other source dirs
 where you installed your eggdrop from. (of course, other source dirs
 will work as well)
 will work as well)
 Unfortunately, you need to compile stats.mod within your eggdrop source,
 Unfortunately, you need to compile stats.mod within your eggdrop source,
 so if you removed your original compile directory, you'll have to
 so if you removed your original compile directory, you'll have to
 compile the whole bot again... sorry.
 compile the whole bot again... sorry.
 
 
-Put stats.mod.1.3.4.tar.gz in ~/eggdrop1.6/src/mod/,
+Put stats.mod.1.3.4.tar.gz in ~/eggdrop1.8/src/mod/,
 and unpack it (tar xfz stats.mod.1.3.4.tar.gz). Change directory
 and unpack it (tar xfz stats.mod.1.3.4.tar.gz). Change directory
-back to ~/eggdrop1.6/. Type 'make config' (on eggdrop 1.4, you can skip
+back to ~/eggdrop1.8/. Type 'make config' (on eggdrop 1.4, you can skip
 that part) Type 'make', wait until compiling
 that part) Type 'make', wait until compiling
 is done and use 'make install' to install the bot and stats.mod.
 is done and use 'make install' to install the bot and stats.mod.
 
 
-Don't forget to copy the language files from ~/eggdrop1.6/src/mod/stats.mod/ to
+Don't forget to copy the language files from ~/eggdrop1.8/src/mod/stats.mod/ to
 ~/eggdrop/language/ !
 ~/eggdrop/language/ !
 
 
-All settings can be found in ~/eggdrop1.6/src/mod/stats.mod/stats.conf
+All settings can be found in ~/eggdrop1.8/src/mod/stats.mod/stats.conf
 I suggest to copy it to your eggdrop directory (probably ~/eggdrop/),
 I suggest to copy it to your eggdrop directory (probably ~/eggdrop/),
 edit it to fit your needs and put a 'source stats.conf' at the end of
 edit it to fit your needs and put a 'source stats.conf' at the end of
 your eggdrop config file. This will execute the config file with every
 your eggdrop config file. This will execute the config file with every
@@ -235,4 +234,5 @@ Thanks to:
 - Fabian for teaching me plenty of things
 - Fabian for teaching me plenty of things
 - Johoho and Fox_Muld for various bug reports and suggestions
 - Johoho and Fox_Muld for various bug reports and suggestions
 - dw for the idea of livestats and for many bug reports
 - dw for the idea of livestats and for many bug reports
+- Pseudo for fixing compatibility to eggdrop 1.8
 - the eggdev team for developing eggdrop
 - the eggdev team for developing eggdrop

+ 1 - 1
UPDATES

@@ -1,7 +1,7 @@
 Changes in Stats.mod: (since v1.0.1)
 Changes in Stats.mod: (since v1.0.1)
 --------------------
 --------------------
 1.3.4
 1.3.4
-- Now also works with eggdrop 1.8.
+- Now also works with eggdrop 1.8 (thanks to pseudo!).
 
 
 1.3.3
 1.3.3
 - fixed bug which could crash the bot in certain cases
 - fixed bug which could crash the bot in certain cases

+ 36 - 0
livestats.c

@@ -319,6 +319,41 @@ static void out_livestats(int idx, char *buf, void *x)
 
 
 static void livestats_accept(int idx, char *buf, int len)
 static void livestats_accept(int idx, char *buf, int len)
 {
 {
+#if EGG_IS_MIN_VER(10800)
+  int i, j = 0;
+  sockname_t name;
+  unsigned short port;
+
+  Context;
+  if (dcc_total + 1 >= max_dcc) {
+    j = answer(dcc[idx].sock, &name, &port, 0);
+    if (j != -1) {
+      dprintf(-j, "Sorry, too many connections already.\r\n");
+      killsock(j);
+    }
+    return;
+  }
+  if ((i = new_dcc(&LIVESTATS, sizeof(struct stats_clientinfo))) == (-1)) {
+    putlog(LOG_MISC, "*", "Error accepting livestats connection. DCC table is full.");
+    return;
+  }
+  dcc[i].sock = answer(dcc[idx].sock, &dcc[i].sockname,
+                       (short unsigned *) &dcc[i].port, 0);
+  if (dcc[i].sock < 0) {
+    putlog(LOG_MISC, "*", "Stats.mod: Error accepting livestats connection: %s", strerror(errno));
+    lostdcc(i);
+    return;
+  }
+  strcpy(dcc[i].nick, "httpstats");
+  strcpy(dcc[i].host, iptostr(&dcc[idx].sockname.addr.sa));
+  dcc[i].timeval = now;
+  dcc[i].status = 0;
+  ((struct stats_clientinfo *) dcc[i].u.other)->traffic = 0;
+  ((struct stats_clientinfo *) dcc[i].u.other)->code = 200;
+  ((struct stats_clientinfo *) dcc[i].u.other)->browser = NULL;
+  ((struct stats_clientinfo *) dcc[i].u.other)->referer = NULL;
+  ((struct stats_clientinfo *) dcc[i].u.other)->cmd = NULL;
+#else
   unsigned long ip;
   unsigned long ip;
   unsigned short port;
   unsigned short port;
   int j = 0, sock, i;
   int j = 0, sock, i;
@@ -362,6 +397,7 @@ static void livestats_accept(int idx, char *buf, int len)
   ((struct stats_clientinfo *) dcc[i].u.other)->browser = NULL;
   ((struct stats_clientinfo *) dcc[i].u.other)->browser = NULL;
   ((struct stats_clientinfo *) dcc[i].u.other)->referer = NULL;
   ((struct stats_clientinfo *) dcc[i].u.other)->referer = NULL;
   ((struct stats_clientinfo *) dcc[i].u.other)->cmd = NULL;
   ((struct stats_clientinfo *) dcc[i].u.other)->cmd = NULL;
+#endif
 }
 }
 
 
 static int mlstat_time = 0, mlstat_thr = 0;
 static int mlstat_time = 0, mlstat_thr = 0;