Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI/CD with Lazarus IDE on multiple operating systems.

permissions:
contents: write

on:
push:
pull_request:
workflow_dispatch:
# Automatic cron build every 6 months to check if everything still works.
schedule:
- cron: "0 0 1 1/6 *"

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up an array to perform the following three build configurations.
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: windows-latest
LAZBUILD_WITH_PATH: c:/lazarus/lazbuild
RELEASE_ZIP_FILE: trackereditor_windows_amd64.zip
LAZ_OPT:
- os: ubuntu-latest
LAZBUILD_WITH_PATH: lazbuild
RELEASE_ZIP_FILE: trackereditor_linux_amd64.zip
LAZ_OPT:
- os: macos-latest
LAZBUILD_WITH_PATH: /Applications/Lazarus/lazbuild
RELEASE_ZIP_FILE: trackereditor_UNSIGNED_macOS_Intel_64.zip
LAZ_OPT: --widgetset=cocoa

steps:
- uses: actions/checkout@v4

- name: show LAZBUILD_WITH_PATH (deprecated)
if: ${{ matrix.LAZBUILD_WITH_PATH }}
shell: bash
run: echo ${{ matrix.LAZBUILD_WITH_PATH }}

- name: Install Lazarus IDE
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt install -y lazarus zip
elif [ "$RUNNER_OS" == "Windows" ]; then
choco install lazarus zip
# https://wiki.overbyte.eu/wiki/index.php/ICS_Download#Download_OpenSSL_Binaries
curl -L -O --output-dir enduser https://github.com/GerryFerdinandus/Renesas-RX-GCC/releases/latest/download/libssl-3-x64.dll
curl -L -O --output-dir enduser https://github.com/GerryFerdinandus/Renesas-RX-GCC/releases/latest/download/libcrypto-3-x64.dll
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install --cask lazarus
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash

- name: Build Release version
# Build trackereditor project (Release mode)
run: ${{ matrix.LAZBUILD_WITH_PATH }} --build-mode=Release ${{ matrix.LAZ_OPT }} source/project/tracker_editor/trackereditor.lpi
shell: bash

- name: Build Unit Test
# Build unit test project (Debug mode)
run: ${{ matrix.LAZBUILD_WITH_PATH }} --build-mode=Debug ${{ matrix.LAZ_OPT }} source/project/unit_test/tracker_editor_test.lpi
shell: bash

- name: Run Unit Test on Windows
if: matrix.os == 'windows-latest'
# Also remove all the extra file created by test.
# We do not what it in the ZIP release files.
# Undo all changes made by testing.
run: |
set -e
enduser/test_trackereditor -a --format=plain
set +e

# remove file created by unit test
rm -f enduser/console_log.txt
rm -f enduser/export_trackers.txt
git reset --hard
shell: bash

- name: Create a zip file for Linux release.
if: matrix.os == 'ubuntu-latest'
run: zip -j ${{ matrix.RELEASE_ZIP_FILE }} enduser/*.txt enduser/trackereditor
shell: bash

- name: Create a zip file for Windows release.
if: matrix.os == 'windows-latest'
run: |
zip -j ${{ matrix.RELEASE_ZIP_FILE }} enduser/*.txt enduser/trackereditor.exe enduser/*.dll
shell: bash

- name: Create a zip file for macOS .app release. (unsigned macOS app)
if: matrix.os == 'macos-latest'
run: |
# copy everything into enduser/macos/app folder
#
# Move the executable to the application bundle
mv enduser/trackereditor enduser/macos/app/trackereditor.app/Contents/MacOS
# Move the trackers list to application bundle
mv enduser/add_trackers.txt enduser/macos/app/trackereditor.app/Contents/MacOS
mv enduser/remove_trackers.txt enduser/macos/app/trackereditor.app/Contents/MacOS
# move all the *.txt file
mv enduser/*.txt enduser/macos/app
# zip only the app folder with extra text file.
/usr/bin/ditto -c -k "enduser/macos/app" "${{ matrix.RELEASE_ZIP_FILE }}"
shell: bash

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
path: ${{ matrix.RELEASE_ZIP_FILE }}
if-no-files-found: error # 'warn'. error

- name: Zip file release to end user
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
*.zip
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "travis-lazarus"]
path = travis-lazarus
url = https://github.com/GerryFerdinandus/travis-lazarus.git
Binary file removed enduser/libeay32.dll
Binary file not shown.
Binary file removed enduser/ssleay32.dll
Binary file not shown.
1 change: 1 addition & 0 deletions source/code/bencode.pas
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ constructor TBEncoded.Create(Stream: TStream);
var
X: char;
begin
Result := '';
// loop until we come across it
X := ' ';
repeat
Expand Down
61 changes: 32 additions & 29 deletions source/code/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TFormTrackerModify = class(TForm)
procedure FormDestroy(Sender: TObject);

//Drag and drop '*.torrent' files/directory or 'tracker.txt'
procedure FormDropFiles(Sender: TObject; const FileNames: array of UTF8String);
procedure FormDropFiles(Sender: TObject; const FileNames: array of utf8string);

//At start of the program the form will be show/hide
procedure FormShow(Sender: TObject);
Expand Down Expand Up @@ -166,10 +166,10 @@ TFormTrackerModify = class(TForm)
FLogFile, FTrackerFile: TextFile;
FProcessTimeStart, FProcessTimeTotal: TDateTime;
FControlerGridTorrentData: TControlerGridTorrentData;
function CheckForAnnounce(const TrackerURL: UTF8String): boolean;
function CheckForAnnounce(const TrackerURL: utf8string): boolean;
procedure AppendTrackersToMemoNewTrackers(TrackerList: TStringList);
procedure ShowUserErrorMessage(const ErrorText: string; const FormText: string = '');
function TrackerWithURLAndAnnounce(const TrackerURL: UTF8String): boolean;
function TrackerWithURLAndAnnounce(const TrackerURL: utf8string): boolean;
procedure UpdateTorrent;
procedure ShowHourGlassCursor(HourGlass: boolean);
procedure ViewUpdateBegin;
Expand All @@ -182,13 +182,13 @@ TFormTrackerModify = class(TForm)
procedure UpdateViewRemoveTracker;
function ReloadAllTorrentAndRefreshView: boolean;
function AddTorrentFileList(TorrentFileNameStringList: TStringList): boolean;
function ReadAddTrackerFileFromUser(const FileName: UTF8String): boolean;
function LoadTorrentViaDir(const Dir: UTF8String): boolean;
function DecodeTorrentFile(const FileName: UTF8String): boolean;
function ReadAddTrackerFileFromUser(const FileName: utf8string): boolean;
function LoadTorrentViaDir(const Dir: utf8string): boolean;
function DecodeTorrentFile(const FileName: utf8string): boolean;
procedure UpdateTrackerInsideFileList;
procedure UpdateTorrentTrackerList;
procedure ShowTrackerInsideFileList;
function TestConnectionSSL: Boolean;
function TestConnectionSSL: boolean;

procedure CheckedOnOffAllTrackers(Value: boolean);
function CopyUserInputNewTrackersToList(Temporary_SkipAnnounceCheck: boolean =
Expand All @@ -204,18 +204,19 @@ TFormTrackerModify = class(TForm)

implementation

uses fphttpclient, LCLIntf, lazutf8, LazFileUtils, trackerlist_online;
uses fphttpclient, LCLIntf, lazutf8, LazFileUtils, trackerlist_online, LCLVersion;

const
RECOMENDED_TRACKERS: array[0..2] of UTF8String =
RECOMENDED_TRACKERS: array[0..2] of utf8string =
(
'udp://tracker.coppersurfer.tk:6969/announce',
'udp://tracker.opentrackr.org:1337/announce',
'wss://tracker.openwebtorrent.com'
);

//program name and version (http://semver.org/)
FORM_CAPTION = 'Bittorrent tracker editor (1.33.0.beta.6)';
FORM_CAPTION = 'Bittorrent tracker editor (1.33.0.beta.6/LCL ' +
lcl_version + '/FPC ' + {$I %FPCVERSION%} + ')';

GROUPBOX_PRESENT_TRACKERS_CAPTION =
'Present trackers in all torrent files. Select the one that you want to keep. And added to all torrent files.';
Expand Down Expand Up @@ -471,7 +472,7 @@ procedure TFormTrackerModify.MenuItemOnlineCheckSubmitNewTrackonClick(Sender: TO

procedure TFormTrackerModify.AppendTrackersToMemoNewTrackers(TrackerList: TStringList);
var
tracker: UTF8String;
tracker: utf8string;
begin
//Append all the trackers to MemoNewTrackers
MemoNewTrackers.Lines.BeginUpdate;
Expand Down Expand Up @@ -521,7 +522,7 @@ procedure TFormTrackerModify.MenuItemOnlineCheckDownloadNewTrackonClick(
end;
end;

function TFormTrackerModify.CheckForAnnounce(const TrackerURL: UTF8String): boolean;
function TFormTrackerModify.CheckForAnnounce(const TrackerURL: utf8string): boolean;
begin
Result := (not FTrackerList.SkipAnnounceCheck) and
(not WebTorrentTrackerURL(TrackerURL)) and (not FDragAndDropStartUp);
Expand All @@ -547,7 +548,7 @@ procedure TFormTrackerModify.ShowUserErrorMessage(const ErrorText: string;
end;

function TFormTrackerModify.TrackerWithURLAndAnnounce(
const TrackerURL: UTF8String): boolean;
const TrackerURL: utf8string): boolean;
begin
//Validate the begin of the URL
Result := ValidTrackerURL(TrackerURL);
Expand Down Expand Up @@ -874,7 +875,7 @@ procedure TFormTrackerModify.UpdateTorrent;

procedure TFormTrackerModify.SaveTrackerFinalListToFile;
var
TrackerStr: UTF8String;
TrackerStr: utf8string;
begin
//Create the tracker text file. The old one will be overwritten
AssignFile(FTrackerFile, FFolderForTrackerListLoadAndSave + FILE_NAME_EXPORT_TRACKERS);
Expand All @@ -894,7 +895,7 @@ procedure TFormTrackerModify.SaveTrackerFinalListToFile;

procedure TFormTrackerModify.ConsoleModeOrDragAndDropStartupMode;
var
FileNameOrDirStr: UTF8String;
FileNameOrDirStr: utf8string;
StringList: TStringList;
MustExitWithErrorCode: boolean;
begin
Expand Down Expand Up @@ -1030,7 +1031,7 @@ procedure TFormTrackerModify.ConsoleModeOrDragAndDropStartupMode;

procedure TFormTrackerModify.UpdateViewRemoveTracker;
var
TrackerStr: UTF8String;
TrackerStr: utf8string;
i: integer;
begin
{
Expand Down Expand Up @@ -1083,7 +1084,7 @@ procedure TFormTrackerModify.UpdateViewRemoveTracker;



function TFormTrackerModify.DecodeTorrentFile(const FileName: UTF8String): boolean;
function TFormTrackerModify.DecodeTorrentFile(const FileName: utf8string): boolean;
begin
//Called when user add torrent files
//False if something is wrong with decoding torrent.
Expand All @@ -1097,7 +1098,7 @@ function TFormTrackerModify.DecodeTorrentFile(const FileName: UTF8String): boole

procedure TFormTrackerModify.UpdateTorrentTrackerList;
var
TrackerStr: UTF8String;
TrackerStr: utf8string;
begin
//Copy the trackers found in one torrent file to FTrackerList.TrackerFromInsideTorrentFilesList
for TrackerStr in FDecodePresentTorrent.TrackerList do
Expand Down Expand Up @@ -1131,7 +1132,7 @@ procedure TFormTrackerModify.CheckedOnOffAllTrackers(Value: boolean);
function TFormTrackerModify.CopyUserInputNewTrackersToList(
Temporary_SkipAnnounceCheck: boolean): boolean;
var
TrackerStrLoop, TrackerStr, ErrorStr: UTF8String;
TrackerStrLoop, TrackerStr, ErrorStr: utf8string;
begin
{
Called after 'update torrent' is selected.
Expand Down Expand Up @@ -1256,7 +1257,7 @@ procedure TFormTrackerModify.LoadTrackersTextFileAddTrackers(

procedure TFormTrackerModify.LoadTrackersTextFileRemoveTrackers;
var
filename: UTF8String;
filename: utf8string;
begin
filename := FFolderForTrackerListLoadAndSave + FILE_NAME_REMOVE_TRACKERS;
try
Expand Down Expand Up @@ -1350,7 +1351,7 @@ procedure TFormTrackerModify.MenuHelpVisitNewTrackonClick(Sender: TObject);


function TFormTrackerModify.ReadAddTrackerFileFromUser(
const FileName: UTF8String): boolean;
const FileName: utf8string): boolean;
var
TrackerFileList: TStringList;
begin
Expand Down Expand Up @@ -1436,7 +1437,7 @@ procedure TFormTrackerModify.MenuUpdateTorrentSortClick(Sender: TObject);



function TFormTrackerModify.LoadTorrentViaDir(const Dir: UTF8String): boolean;
function TFormTrackerModify.LoadTorrentViaDir(const Dir: utf8string): boolean;
var
TorrentFilesNameStringList: TStringList;
begin
Expand All @@ -1454,7 +1455,7 @@ function TFormTrackerModify.LoadTorrentViaDir(const Dir: UTF8String): boolean;


procedure TFormTrackerModify.FormDropFiles(Sender: TObject;
const FileNames: array of UTF8String);
const FileNames: array of utf8string);
var
Count: integer;
TorrentFileNameStringList, //for the torrent files
Expand All @@ -1466,7 +1467,7 @@ procedure TFormTrackerModify.FormDropFiles(Sender: TObject;
//ViewUpdateBegin must be called one time. Keep track of it.
ViewUpdateBeginActiveOneTimeOnly: boolean;

FileNameOrDirStr: UTF8String;
FileNameOrDirStr: utf8string;
begin
//Drag and drop a folder or files?

Expand Down Expand Up @@ -1598,7 +1599,7 @@ function TFormTrackerModify.AddTorrentFileList(TorrentFileNameStringList:
//This called from 'add folder' or 'drag and drop'
var
Count: integer;
TorrentFileNameStr: UTF8String;
TorrentFileNameStr: utf8string;
begin
{ Every torrent file must be decoded for the tracker list inside.
This torrent tracker list is add to FTrackerList.TrackerFromInsideTorrentFilesList.
Expand Down Expand Up @@ -1639,7 +1640,7 @@ function TFormTrackerModify.AddTorrentFileList(TorrentFileNameStringList:

function TFormTrackerModify.ReloadAllTorrentAndRefreshView: boolean;
var
TorrentFileStr: UTF8String;
TorrentFileStr: utf8string;
begin
{
This is called after updating the torrent.
Expand Down Expand Up @@ -1703,7 +1704,7 @@ procedure TFormTrackerModify.ViewUpdateBegin;
procedure TFormTrackerModify.ViewUpdateOneTorrentFileDecoded;
var
RowIndex: integer;
TorrentFileNameStr, PrivateStr: UTF8String;
TorrentFileNameStr, PrivateStr: utf8string;
DateTimeStr: string;
begin
//Called after loading torrent file.
Expand Down Expand Up @@ -1821,7 +1822,7 @@ procedure TFormTrackerModify.ShowHourGlassCursor(HourGlass: boolean);

end;

function TFormTrackerModify.TestConnectionSSL: Boolean;
function TFormTrackerModify.TestConnectionSSL: boolean;
begin
Result := ParamCount = 1;
if Result then
Expand All @@ -1832,12 +1833,14 @@ function TFormTrackerModify.TestConnectionSSL: Boolean;
begin
// Check if there is SLL connection
try
TFPCustomHTTPClient.SimpleGet('https://raw.githubusercontent.com/gerryferdinandus/bittorrent-tracker-editor/master/.travis.yml');
TFPCustomHTTPClient.SimpleGet(
'https://raw.githubusercontent.com/gerryferdinandus/bittorrent-tracker-editor/master/README.md');
except
//No SLL or no internet connection.
System.ExitCode := 1;
end;
end;
end;
end;

end.
Loading