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

Merge branch 'fix-laston' into maint

* fix-laston:
  Only share LASTON to hubs.
  Fix LASTON not being shared
Bryan Drewery пре 8 година
родитељ
комит
0599a3ceab
4 измењених фајлова са 28 додато и 3 уклоњено
  1. 1 0
      doc/UPDATES.md
  2. 25 0
      src/mod/share.mod/share.cc
  3. 1 0
      src/mod/share.mod/share.h
  4. 1 3
      src/userent.cc

+ 1 - 0
doc/UPDATES.md

@@ -6,6 +6,7 @@
   * Reduce compilation spam.
   * Fix OpenSSL 1.1 build (API) and forward-runtime (ABI) compatibility. (#116)
   * Properly honor exemptions when kicking matched RBL clients
+  * Fix LASTON not being shared
 
 # 1.4.8
   * Support Debian/Ubuntu's libssl1.0.0[:i386] package.

+ 25 - 0
src/mod/share.mod/share.cc

@@ -1241,6 +1241,31 @@ shareout_prot(struct userrec *u, const char *format, ...)
   q_resync(s);
 }
 
+void
+shareout_hub(const char *format, ...)
+{
+  char s[601] = "";
+  int l;
+  va_list va;
+
+  va_start(va, format);
+
+  strlcpy(s, "s ", 3);
+  if ((l = egg_vsnprintf(s + 2, 509, format, va)) < 0)
+    s[2 + (l = 509)] = 0;
+  va_end(va);
+
+  for (int i = 0; i < dcc_total; i++) {
+    if (dcc[i].type && (dcc[i].type->flags & DCT_BOT) &&
+       (dcc[i].status & STAT_SHARE) && !(dcc[i].status & (STAT_GETTING | STAT_SENDING)) &&
+       /* only send to hubs */
+       dcc[i].hub) {
+      tputs(dcc[i].sock, s, l + 2);
+    }
+  }
+  q_resync(s);
+}
+
 static void
 shareout_but(int x, const char *format, ...)
 {

+ 1 - 0
src/mod/share.mod/share.h

@@ -16,6 +16,7 @@
 void sharein(int, char *);
 void shareout(const char *, ...) __attribute__((format(printf, 1, 2)));
 void shareout_prot(struct userrec *, const char *, ...) __attribute__((format(printf, 2, 3)));
+void shareout_hub(const char *, ...) __attribute__((format(printf, 1, 2)));
 void finish_share(int);
 void dump_resync(int);
 void share_report(int, int);

+ 1 - 3
src/userent.cc

@@ -724,10 +724,8 @@ static bool laston_set(struct userrec *u, struct user_entry *e, void *buf)
     e->u.extra = (struct laston_info *) buf;
   }
 
-  /* FIXME: laston sharing is disabled until a better solution is found
   if (!noshare)
-    shareout("c LASTON %s %s %li\n", u->handle, li->lastonplace ? li->lastonplace : "-", (long) li->laston);
-  */
+    shareout_hub("c LASTON %s %s %li\n", u->handle, li->lastonplace ? li->lastonplace : "-", (long) li->laston);
 
   return 1;
 }