diff --git a/.github/patches/allowCustom.py b/.github/patches/allowCustom.py new file mode 100644 index 0000000..d8cc3f4 --- /dev/null +++ b/.github/patches/allowCustom.py @@ -0,0 +1,67 @@ +import os +import shutil + +def remove_line_block(filepath, start_phrase, lines_to_remove_after_start): + """ + Removes a starting line and a fixed number of lines immediately following it. + + :param filepath: The path to the file to modify. + :param start_phrase: The unique string to identify the first line of the block. + :param lines_to_remove_after_start: The number of lines to remove after the starting line. + """ + + # 1. Configuration for the removal logic + # The starting line is: const KEY: &str = "5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM="; + # The block contains this line plus 8 following lines, so we want to skip 9 lines in total. + total_lines_to_skip = 1 + lines_to_remove_after_start # 1 (start line) + 8 (following lines) = 9 + + lines_to_keep = [] + skip_count = 0 + + # 2. Read and filter the file content + try: + with open(filepath, 'r') as file: + for line in file: + + # If we are currently in the process of skipping lines, decrement the counter and continue + if skip_count > 0: + skip_count -= 1 + continue + + # Check if the line matches the start phrase (we use .strip() to ignore indentation/whitespace) + if line.strip().startswith(start_phrase.strip()): + # Start skipping the block (including the current line) + skip_count = total_lines_to_skip - 1 + # Note: We subtract 1 because the 'continue' will handle the first line removal immediately + continue + + # If we are not skipping, keep the line + lines_to_keep.append(line) + + except FileNotFoundError: + print(f"Error: File not found at {filepath}") + return + + # 3. Write the remaining lines back to the file (with backup) + try: + # Create a backup just in case + backup_filepath = filepath + '.bak' + shutil.copyfile(filepath, backup_filepath) + + with open(filepath, 'w') as file: + file.writelines(lines_to_keep) + + print(f"✅ Success! Removed the 9-line block starting with '{start_phrase.strip()}' from {filepath}.") + print(f"A backup of the original file was saved as {backup_filepath}.") + + except IOError as e: + print(f"An error occurred while writing to the file: {e}") + +def main(): + file_path = 'src/common.rs' + start_phrase = 'const KEY: &str = "5Qbwsde3unUcJBtrx9ZkvUmwFNoExHzpryHuPUdqlWM=";' + lines_to_remove_after_start = 8 + remove_line_block(file_path, start_phrase, lines_to_remove_after_start) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/.github/patches/cycle_monitor.diff b/.github/patches/cycle_monitor.diff index 9381b23..2f0c554 100644 --- a/.github/patches/cycle_monitor.diff +++ b/.github/patches/cycle_monitor.diff @@ -2,7 +2,7 @@ diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/deskt index 839ea1a81..9cee52263 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart -@@ -437,6 +437,7 @@ class _RemoteToolbarState extends State { +@@ -317,6 +317,7 @@ class _RemoteToolbarState extends State { borderRadius: borderRadius, child: _DraggableShowHide( id: widget.id, @@ -10,7 +10,7 @@ index 839ea1a81..9cee52263 100644 sessionId: widget.ffi.sessionId, dragging: _dragging, fractionX: _fractionX, -@@ -2234,6 +2235,7 @@ class RdoMenuButton extends StatelessWidget { +@@ -2460,6 +2460,7 @@ class RdoMenuButton extends StatelessWidget { class _DraggableShowHide extends StatefulWidget { final String id; @@ -18,7 +18,7 @@ index 839ea1a81..9cee52263 100644 final SessionID sessionId; final RxDouble fractionX; final RxBool dragging; -@@ -2246,6 +2248,7 @@ class _DraggableShowHide extends StatefulWidget { +@@ -2472,6 +2472,7 @@ class _DraggableShowHide extends StatefulWidget { const _DraggableShowHide({ Key? key, required this.id, @@ -26,7 +26,7 @@ index 839ea1a81..9cee52263 100644 required this.sessionId, required this.fractionX, required this.dragging, -@@ -2357,6 +2360,7 @@ class _DraggableShowHideState extends State<_DraggableShowHide> { +@@ -2583,6 +2583,7 @@ class _DraggableShowHideState extends State<_DraggableShowHide> { mainAxisSize: MainAxisSize.min, children: [ _buildDraggable(context), @@ -34,7 +34,7 @@ index 839ea1a81..9cee52263 100644 Obx(() => buttonWrapper( () { widget.setFullscreen(!isFullscreen.value); -@@ -2463,3 +2467,50 @@ Widget _buildPointerTrackWidget(Widget child, FFI? ffi) { +@@ -2689,3 +2689,50 @@ Widget _buildPointerTrackWidget(Widget child, FFI? ffi) { ), ); } diff --git a/.github/workflows/generator-windows.yml b/.github/workflows/generator-windows.yml index 06bd36a..6a72daa 100644 --- a/.github/workflows/generator-windows.yml +++ b/.github/workflows/generator-windows.yml @@ -229,7 +229,6 @@ jobs: sed -i -e 's|Purslane Ltd|${{ fromJson(inputs.extras).compname }}|' ./flutter/windows/runner/Runner.rc sed -i -e 's|Purslane Ltd|${{ fromJson(inputs.extras).compname }}|' ./Cargo.toml sed -i -e 's|Purslane Ltd|${{ fromJson(inputs.extras).compname }}|' ./libs/portable/Cargo.toml - sed -i -e 's|Purslane Ltd.|${{ fromJson(inputs.extras).compname }}|' ./res/setup.nsi - name: change url to custom if: fromJson(inputs.extras).urlLink != 'https://rustdesk.com' @@ -243,7 +242,6 @@ jobs: sed -i -e "s|const url = 'https://rustdesk.com/';|const url = '${{ fromJson(inputs.extras).urlLink }}';|" ./flutter/lib/mobile/pages/settings_page.dart sed -i -e "s|launchUrlString('https://rustdesk.com/privacy.html')|launchUrlString('${{ fromJson(inputs.extras).urlLink }}/privacy.html')|" ./flutter/lib/mobile/pages/settings_page.dart sed -i -e "s|https://rustdesk.com/privacy.html|${{ fromJson(inputs.extras).urlLink }}/privacy.html|" ./flutter/lib/desktop/pages/install_page.dart - #sed -i -e "s|https://rustdesk.com/|${{fromJson(inputs.extras).urlLink }}|" ./res/setup.nsi - name: change download link to custom if: fromJson(inputs.extras).downloadLink != 'https://rustdesk.com/download' @@ -267,8 +265,8 @@ jobs: - name: allow custom.txt continue-on-error: true run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/bryangerlach/rdgen/refs/heads/master/.github/patches/allowCustom.diff -OutFile allowCustom.diff - git apply allowCustom.diff + Invoke-WebRequest -Uri https://raw.githubusercontent.com/bryangerlach/rdgen/refs/heads/master/.github/patches/allowCustom.py -OutFile allowCustom.py + python allowCustom.py # Remove Setup Server Tip Invoke-WebRequest -Uri https://raw.githubusercontent.com/bryangerlach/rdgen/refs/heads/master/.github/patches/removeSetupServerTip.diff -OutFile removeSetupServerTip.diff git apply removeSetupServerTip.diff