Network Blocking Mechanism
Relevant source files
The following files were used as context for generating this wiki page:
The Network Blocking Mechanism in this project is not a real-time network filter or firewall. Instead, it is a system of scripts designed to preemptively disable the Cursor application's network-dependent features, primarily its auto-update and authentication capabilities. This is achieved by modifying, deleting, and creating specific files within the Cursor application's installation and configuration directories.
The core of this mechanism is the AutoUpdateDisabler class, which orchestrates a series of file system operations to cripple the update functionality. Other scripts, such as those for resetting the application, also contribute by patching JavaScript files to remove or alter network-related UI elements and functions.
Detailed Sections
Auto-Update Disabling
The primary component for network blocking is the auto-update disabler. It follows a multi-step process to ensure the Cursor application cannot contact its update servers or execute the update process. The main logic is encapsulated in the AutoUpdateDisabler class.
Sources: disable_auto_update.py
Disabling Flow
The following diagram illustrates the sequence of operations performed by the disable_auto_update.py script.
This diagram shows the step-by-step process of the auto-update disabler.
Sources: disable_auto_update.py:202-219
Key Operations
- Kill Cursor Processes: Before modifying any files, the script ensures all running Cursor processes are terminated. It uses
taskkillon Windows andpkillon macOS/Linux.
Sources: disable_auto_update.py:100-113 - Remove Updater Directory: The script deletes the
cursor-updaterdirectory, which contains the application's update logic.
Sources: disable_auto_update.py:115-135 - Clear
update.yml: Theapp-update.ymlorupdate.ymlfile, which contains update server information, is cleared by writing an empty string to it.
Sources: disable_auto_update.py:137-158 - Create Blocking Files: To prevent Cursor from recreating the updater directory and files, the script creates empty files with the same names and sets them to read-only.
- An empty file is created at the
updater_path. - A dummy
update.ymlis created and made read-only.
Sources: disable_auto_update.py:160-200
- An empty file is created at the
- Remove Update URLs: The script reads the
product.jsonfile, removes hardcoded update URLs using regular expressions, and writes the modified content back.
Sources: disable_auto_update.py:65-98
URL and Function Patching
Several scripts modify the application's core JavaScript files to remove or alter functionality related to network communication, such as trial validation, token limits, and displaying "Upgrade to Pro" buttons.
Target Files and Modifications
| File | Function Modified | Modification Description |
|---|---|---|
workbench.desktop.main.js | getEffectiveTokenLimit | The function is patched to return a very large number (e.g., 9,000,000), effectively bypassing the token limit for AI features. |
workbench.desktop.main.js | UI Components | The "Upgrade to Pro" button is replaced with a link to the project's GitHub repository. The "Pro Trial" badge is changed to "Pro". |
main.js | getMachineId, getMacMachineId | The functions are modified to alter how machine IDs are generated, which is a method to bypass trial detection mechanisms. |
Sources: reset_machine_manual.py:347-386, reset_machine_manual.py:421-443, totally_reset_cursor.py:433-472
URL Removal from product.json
The _remove_update_url function in disable_auto_update.py specifically targets and removes the following URLs from product.json to prevent the application from checking for updates:
https://api2.cursor.sh/aiserver.v1.AuthService/DownloadUpdatehttps://api2.cursor.sh/updateshttp://cursorapi.com/updates
Sources: disable_auto_update.py:76-80
File System Targets
The blocking mechanism relies on precise paths to locate and modify Cursor's files. These paths are determined based on the operating system.
| OS | File/Directory | Default Path |
|---|---|---|
| Windows | Updater Directory | %LOCALAPPDATA%\cursor-updater |
update.yml | %LOCALAPPDATA%\Programs\Cursor\resources\app\update.yml | |
product.json | %LOCALAPPDATA%\Programs\Cursor\resources\app\product.json | |
| macOS | Updater Directory | ~/Library/Application Support/cursor-updater |
app-update.yml | /Applications/Cursor.app/Contents/Resources/app-update.yml | |
product.json | /Applications/Cursor.app/Contents/Resources/app/product.json | |
| Linux | Updater Directory | ~/.config/cursor-updater |
app-update.yml | ~/.config/cursor/resources/app-update.yml | |
product.json | ~/.config/cursor/resources/app/product.json |
Sources: disable_auto_update.py:27-63
Conclusion
The network blocking mechanism is a file-based approach that surgically disables the Cursor application's ability to perform updates and certain authentications. By killing related processes, removing updater files, creating read-only blocking files, and patching hardcoded URLs and functions out of JavaScript source files, the system effectively isolates the application from its parent servers. This method is persistent across application restarts but may need to be reapplied if the application is reinstalled or manually repaired.