From f16ea39889c0fd65f3e533cf40cc3a0a33ac1c33 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 3 Nov 2026 06:02:47 +0100 Subject: Let a user pick their cluster's own multicast group --- tests/integration/test_livesync.py | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/integration/test_livesync.py') diff --git a/tests/integration/test_livesync.py b/tests/integration/test_livesync.py index 3a9ee58..52e871f 100644 --- a/tests/integration/test_livesync.py +++ b/tests/integration/test_livesync.py @@ -164,3 +164,45 @@ class LiveSyncUnconfigured(TrackerTestCase): for i in range(200): self.tracker.announce(self.hash_for("no-cluster-%d" % i), port=6881 + i, left=0) self.assertEqual(self.tracker.torrent_count(), 200) + + +# RFC 2365 sets 239.192.0.0/14 aside for exactly this kind of use +OWN_GROUP = "239.192.0.7" + + +@unittest.skipUnless(has_livesync(), "this build has no WANT_SYNC_LIVE") +class LiveSyncGroup(TrackerTestCase): + config = ("livesync.cluster.group %s\n" + "livesync.cluster.listen 127.0.0.1:{livesync_port}\n" + "livesync.cluster.node_ip 127.0.0.1\n" % OWN_GROUP) + + def test_the_configured_group_is_joined(self): + info_hash = self.hash_for("own-group") + self.tracker.livesync_send(packet(SYNC_PEER4, [(info_hash, peer4("10.1.3.1", 6881, FLAG_SEEDING))]), + group=OWN_GROUP) + self.assertTrue(self.tracker.wait_until(lambda: self.tracker.torrent_count() == 1)) + + def test_the_default_group_is_left_alone(self): + """A cluster that picked its own group should not hear the one every + other opentracker is on.""" + info_hash = self.hash_for("not-our-group") + self.tracker.livesync_send(packet(SYNC_PEER4, [(info_hash, peer4("10.1.3.2", 6881, FLAG_SEEDING))])) + self.assertFalse(self.tracker.wait_until(lambda: self.tracker.torrent_count() != 0, timeout=1)) + + +@unittest.skipUnless(has_livesync(), "this build has no WANT_SYNC_LIVE") +class LiveSyncGroupRefused(TrackerTestCase): + """A unicast address is not a group. The line is refused like any other + bad config line, which leaves the default standing.""" + + config = ("livesync.cluster.group 10.0.0.1\n" + "livesync.cluster.listen 127.0.0.1:{livesync_port}\n" + "livesync.cluster.node_ip 127.0.0.1\n") + + def test_the_line_is_refused(self): + self.assertIn("Parse error", self.tracker.output()) + + def test_and_the_default_group_still_works(self): + info_hash = self.hash_for("fallback-group") + self.tracker.livesync_send(packet(SYNC_PEER4, [(info_hash, peer4("10.1.3.3", 6881, FLAG_SEEDING))])) + self.assertTrue(self.tracker.wait_until(lambda: self.tracker.torrent_count() == 1)) -- cgit v1.3