--- a/libtransmission/peer-mgr.c 2018-01-01 00:00:00.000000000 +0000
+++ b/libtransmission/peer-mgr.c 2018-01-01 00:00:00.000000000 +0000
@@ -1939,6 +1939,19 @@
tr_peerMsgsUpdateActive (msgs, TR_DOWN);
}
+static bool isUserAgentBad(const char* ua)
+{
+ static const char* blacklist[] = {"Thunder", "Xunlei"};
+ int i;
+
+ for (i = 0; i != sizeof(blacklist) / sizeof(blacklist[0]); ++i) {
+ // Performs bad, honestly.
+ if (!strncmp(blacklist[i], ua, strlen(blacklist[i]))) {
+ return true;
+ }
+ }
+ return false;
+}
/* FIXME: this is kind of a mess. */
static bool
@@ -2036,18 +2049,25 @@
tr_quark client;
tr_peerIo * io;
char buf[128];
+ const char* ua = "";
if (peer_id != NULL)
- client = tr_quark_new (tr_clientForId (buf, sizeof (buf), peer_id), TR_BAD_SIZE);
+ client = tr_quark_new ((ua = tr_clientForId (buf, sizeof (buf), peer_id)), TR_BAD_SIZE);
else
client = TR_KEY_NONE;
+ if (!isUserAgentBad(ua))
+ {
+ io = tr_handshakeStealIO (handshake); /* this steals its refcount too, which is
+ balanced by our unref in peerDelete () */
+ tr_peerIoSetParent (io, &s->tor->bandwidth);
+ createBitTorrentPeer (s->tor, io, atom, client);
- io = tr_handshakeStealIO (handshake); /* this steals its refcount too, which is
- balanced by our unref in peerDelete () */
- tr_peerIoSetParent (io, &s->tor->bandwidth);
- createBitTorrentPeer (s->tor, io, atom, client);
-
- success = true;
+ success = true;
+ }
+ else
+ {
+ tr_logAddDebug("Bad user agent \"%s\" (peer %s) tried to connect to us", ua, tr_atomAddrStr(atom));
+ }
}
}
}