public void AddTracker(string track) { Uri res; if(Uri.TryCreate(track , UriKind.Absolute , out res)) { if(res.Scheme == "udp") { var t = new UdpTracker(res); t.AnnounceComplete += TrackerAnnounceComplete; _trackers.Add(t); } else if(res.Scheme == Uri.UriSchemeHttp) { var t = new HTTPTracker(res); t.AnnounceComplete += TrackerAnnounceComplete; _trackers.Add(t); } } }
public void Setup() { keys = new List <BEncodedString> (); server = new MonoTorrent.Tracker.TrackerServer(); server.AllowUnregisteredTorrents = true; server.RegisterListener(listener); peerEndpoints = new List <IPEndPoint> { new IPEndPoint(IPAddress.Parse("123.123.123.123"), 12312), new IPEndPoint(IPAddress.Parse("254.254.254.254"), 3522), new IPEndPoint(IPAddress.Parse("1.1.1.1"), 123), new IPEndPoint(IPAddress.Parse("1.2.3.4"), 65000), }; tracker = (UdpTracker)TrackerFactory.Create(new Uri($"udp://127.0.0.1:{listener.EndPoint.Port}/announce/")); announceparams = announceparams.WithPort(listener.EndPoint.Port); listener.IgnoreAnnounces = false; listener.IgnoreConnects = false; listener.IgnoreErrors = false; listener.IgnoreScrapes = false; listener.IncompleteAnnounce = listener.IncompleteConnect = listener.IncompleteScrape = false; }