SagerNet / SagerNet/sing-box

Feature Request: Allow Manually Skipping a Matched Route Rule and Continue Matching

Open
#3,616 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
38.2k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

Why

In sing-box, route rules are strictly terminal: once a rule matches, routing stops.

Current mechanisms (selector outbound or clash_mode) only allow switching outbounds or modes, but do not allow temporarily disabling a rule itself or letting traffic continue matching subsequent rules.

This makes some common routing scenarios unnecessarily complex and inflexible.


Example: SSH Rule That Should Be Temporarily Bypassable
Route Configuration (Current)
{
  "route": {
    "rules": [
      {
        "protocol": "ssh",
        "outbound": "current_selector"
      },
      {
        "ip_cidr": ["A"],
        "outbound": "A"
      },
      {
        "ip_cidr": ["B"],
        "outbound": "B"
      },
      {
        "ip_cidr": ["/*some conditions*/"],
        "outbound": "ts-out"
      },
    ]
  }
}
{
  "outbounds": [
    {
      "type": "selector",
      "tag": "ssh_selector",
      "outbounds": ["A", "B", "ts-out", "reject"]
    }
    // ... some outbounds
  ]
}
Current Behavior
  • All SSH traffic always matches the first rule
  • The selector can only choose a fixed outbound
  • SSH traffic cannot fall through to later rules
  • To “disable” the SSH rule, users must duplicate routing logic inside the selector

Desired Behavior

If a special skip / bypass outbound (or equivalent mechanism) existed:

{
  "type": "bypass"
}

Then the selector could expose:

{
  "type": "selector",
  "tag": "ssh_selector",
  "outbounds": ["ssh_proxy", "bypass"]
}

Behavior:

  • Selecting ssh_proxy → SSH-specific routing
  • Selecting bypass → ignore the SSH rule and continue matching:

Use Cases
  • Temporarily disabling protocol- or port-based rules
  • Debugging routing behavior via clash API
  • Avoiding duplicated downstream rules
  • Fine-grained runtime control beyond clash_mode

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing sing-box route-rule matching, selector outbound behavior, and the Clash API controls described in the issue. Define how a bypass selection continues matching subsequent rules, then verify the SSH example and the listed runtime-control use cases without duplicating downstream routing logic.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.