Skip to content

Commit 7d24260

Browse files
[Issue GerryFerdinandus#27] add support for '/announce.php'
also update the unit test
1 parent 79d15fb commit 7d24260

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

source/code/main.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,13 +1004,13 @@ function TFormTrackerModify.CopyUserInputNewTrackersToList: boolean;
10041004
Result := TrackerURLWithAnnounce(TrackerStr);
10051005
if not Result then
10061006
begin
1007-
ErrorStr := 'ERROR: Tracker URL must end with /announce';
1007+
ErrorStr := 'ERROR: Tracker URL must end with /announce or /announce.php';
10081008
end;
10091009
end;
10101010
end
10111011
else
10121012
begin
1013-
ErrorStr := 'ERROR: Tracker URL must begin with http:// or udp://';
1013+
ErrorStr := 'ERROR: Tracker URL must begin with http://, http:// or udp://';
10141014
end;
10151015

10161016
if Result then

source/code/torrent_miscellaneous.pas

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,11 @@ function DecodeConsoleUpdateParameter(const ConsoleUpdateParameter: UTF8String;
709709
function TrackerURLWithAnnounce(const TrackerURL: UTF8String): boolean;
710710
const
711711
ANNOUNCE_STRING: string = '/announce';
712+
ANNOUNCE_PHP_STRING: string = '/announce.php';
712713
begin
713714
//TrackerURL must end with ANNOUNCE_STRING
714-
Result := RightStr(TrackerURL, length(ANNOUNCE_STRING)) = ANNOUNCE_STRING;
715+
Result := (RightStr(TrackerURL, length(ANNOUNCE_STRING)) = ANNOUNCE_STRING) or
716+
(RightStr(TrackerURL, length(ANNOUNCE_PHP_STRING)) = ANNOUNCE_PHP_STRING)
715717
end;
716718

717719
end.

source/project/unit_test/tracker_editor_test.lpi

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<CONFIG>
33
<ProjectOptions>
4-
<Version Value="9"/>
4+
<Version Value="10"/>
55
<PathDelim Value="\"/>
66
<General>
77
<SessionStorage Value="None"/>
@@ -13,9 +13,6 @@
1313
<i18n>
1414
<EnableI18N LFM="False"/>
1515
</i18n>
16-
<VersionInfo>
17-
<StringTable ProductVersion=""/>
18-
</VersionInfo>
1916
<BuildModes Count="3">
2017
<Item1 Name="Default" Default="True"/>
2118
<Item2 Name="Debug">

source/test/test_start_up_parameter.pas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,28 +363,34 @@ procedure TTestStartUpParameter.Test_Tracker_UserInput_All_Different_URL;
363363
TrackerURL: string;
364364
const
365365
ANNOUNCE = '/announce';
366+
ANNOUNCE_PHP = '/announce.php';
366367
begin
367368
//Test if all the tracker update mode is working
368369
for TrackerListOrder in TTrackerListOrder do
369370
begin
370371
TrackerURL := 'udp://test.com';
371372
Add_One_URL(TrackerListOrder, TrackerURL, False);
372373
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE, True);
374+
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE_PHP, True);
373375

374376
TrackerURL := 'http://test.com';
375377
Add_One_URL(TrackerListOrder, TrackerURL, False);
376378
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE, True);
379+
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE_PHP, True);
377380

378381
TrackerURL := 'https://test.com';
379382
Add_One_URL(TrackerListOrder, TrackerURL, False);
380383
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE, True);
384+
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE_PHP, True);
381385

382-
//webtorrent does NOT have announce
386+
//webtorrent may have NOT announce
383387
TrackerURL := 'ws://test.com';
384388
Add_One_URL(TrackerListOrder, TrackerURL, True);
389+
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE, True);
385390

386391
TrackerURL := 'wss://test.com';
387392
Add_One_URL(TrackerListOrder, TrackerURL, True);
393+
Add_One_URL(TrackerListOrder, TrackerURL + ANNOUNCE, True);
388394
end;
389395
end;
390396

0 commit comments

Comments
 (0)