sing-box
sing-box copied to clipboard
Feature request: Resilient remote rule-set initialization to prevent startup failure
Is your feature request related to a problem? Please describe.
Currently, sing-box fails to start if a remote rule-set is defined but cannot be fetched during initialization (e.g., on a "cold start" where no local path exists yet). This creates a "chicken and egg" problem (circular dependency):
- The core needs rule-sets to route traffic correctly.
- To download these rule-sets via
download_detour, a functional outbound/proxy is often required. - If the download fails (due to network issues or proxy not being ready), the entire core fails to start, preventing the very connection needed to fetch the rules.
Describe the solution you'd like
I would like to propose two possible scenarios to resolve this:
Scenario 1: Criticality Flag (critical: false)
Add an optional critical boolean field to the rule-set configuration (defaulting to true for backward compatibility).
- If
critical: falseand the rule-set fails to load/download at startup, sing-box should initialize it as an "empty" set, log a warning, and continue starting the core. - The rule-set should then be updated in the background as soon as the network/proxy becomes available.
Scenario 2: Staged/Phase-based Startup
Implement a more sophisticated initialization sequence:
- Phase 1: Network & Outbounds. Initialize the networking stack and outbounds (especially those used in
download_detour). - Phase 2: Resource Fetching. Fetch remote rule-sets. During this phase, incoming traffic from
inboundscan be queued or dropped to prevent leaks. - Phase 3: Full Operation. Once rules are loaded, open the inbounds for user traffic.
Describe alternatives you've considered
- Manual Provisioning: Manually downloading
.srsfiles viacurlbefore starting sing-box. This is difficult to manage on embedded systems (routers) or mobile devices. - Direct Detour: Setting
download_detourtodirect. This fails if the rule-set source (e.g., GitHub) is blocked by the local ISP(gov)/firewall.
Additional context
This change would significantly improve the user experience for:
- New installations (provisioning nodes without pre-shipped cache).
- Unreliable network environments where a cold boot might happen without an active internet connection.
- Users who rely on complex routing rules that require external lists to function.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days