github.com/sagernet/sing-box@v1.2.7/docs/configuration/route/rule.zh.md (about)

     1  ### 结构
     2  
     3  ```json
     4  {
     5    "route": {
     6      "rules": [
     7        {
     8          "inbound": [
     9            "mixed-in"
    10          ],
    11          "ip_version": 6,
    12          "network": "tcp",
    13          "auth_user": [
    14            "usera",
    15            "userb"
    16          ],
    17          "protocol": [
    18            "tls",
    19            "http",
    20            "quic"
    21          ],
    22          "domain": [
    23            "test.com"
    24          ],
    25          "domain_suffix": [
    26            ".cn"
    27          ],
    28          "domain_keyword": [
    29            "test"
    30          ],
    31          "domain_regex": [
    32            "^stun\\..+"
    33          ],
    34          "geosite": [
    35            "cn"
    36          ],
    37          "source_geoip": [
    38            "private"
    39          ],
    40          "geoip": [
    41            "cn"
    42          ],
    43          "source_ip_cidr": [
    44            "10.0.0.0/24"
    45          ],
    46          "ip_cidr": [
    47            "10.0.0.0/24"
    48          ],
    49          "source_port": [
    50            12345
    51          ],
    52          "source_port_range": [
    53            "1000:2000",
    54            ":3000",
    55            "4000:"
    56          ],
    57          "port": [
    58            80,
    59            443
    60          ],
    61          "port_range": [
    62            "1000:2000",
    63            ":3000",
    64            "4000:"
    65          ],
    66          "process_name": [
    67            "curl"
    68          ],
    69          "process_path": [
    70            "/usr/bin/curl"
    71          ],
    72          "package_name": [
    73            "com.termux"
    74          ],
    75          "user": [
    76            "sekai"
    77          ],
    78          "user_id": [
    79            1000
    80          ],
    81          "clash_mode": "direct",
    82          "invert": false,
    83          "outbound": "direct"
    84        },
    85        {
    86          "type": "logical",
    87          "mode": "and",
    88          "rules": [],
    89          "invert": false,
    90          "outbound": "direct"
    91        }
    92      ]
    93    }
    94  }
    95  
    96  ```
    97  
    98  !!! note ""
    99  
   100      当内容只有一项时,可以忽略 JSON 数组 [] 标签。
   101  
   102  ### Default Fields
   103  
   104  !!! note ""
   105  
   106      默认规则使用以下匹配逻辑:  
   107      (`domain` || `domain_suffix` || `domain_keyword` || `domain_regex` || `geosite` || `geoip` || `ip_cidr`) &&  
   108      (`port` || `port_range`) &&  
   109      (`source_geoip` || `source_ip_cidr`) &&  
   110      (`source_port` || `source_port_range`) &&  
   111      `other fields`
   112  
   113  #### inbound
   114  
   115  [入站](/zh/configuration/inbound) 标签。
   116  
   117  #### ip_version
   118  
   119  4 或 6。
   120  
   121  默认不限制。
   122  
   123  #### auth_user
   124  
   125  认证用户名,参阅入站设置。
   126  
   127  #### protocol
   128  
   129  探测到的协议, 参阅 [协议探测](/zh/configuration/route/sniff/)。
   130  
   131  #### network
   132  
   133  `tcp` 或 `udp`。
   134  
   135  #### domain
   136  
   137  匹配完整域名。
   138  
   139  #### domain_suffix
   140  
   141  匹配域名后缀。
   142  
   143  #### domain_keyword
   144  
   145  匹配域名关键字。
   146  
   147  #### domain_regex
   148  
   149  匹配域名正则表达式。
   150  
   151  #### geosite
   152  
   153  匹配 GeoSite。
   154  
   155  #### source_geoip
   156  
   157  匹配源 GeoIP。
   158  
   159  #### geoip
   160  
   161  匹配 GeoIP。
   162  
   163  #### source_ip_cidr
   164  
   165  匹配源 IP CIDR。
   166  
   167  #### ip_cidr
   168  
   169  匹配 IP CIDR。
   170  
   171  #### source_port
   172  
   173  匹配源端口。
   174  
   175  #### source_port_range
   176  
   177  匹配源端口范围。
   178  
   179  #### port
   180  
   181  匹配端口。
   182  
   183  #### port_range
   184  
   185  匹配端口范围。
   186  
   187  #### process_name
   188  
   189  !!! error ""
   190  
   191      仅支持 Linux、Windows 和 macOS。
   192  
   193  匹配进程名称。
   194  
   195  #### process_path
   196  
   197  !!! error ""
   198  
   199      仅支持 Linux、Windows 和 macOS.
   200  
   201  匹配进程路径。
   202  
   203  #### package_name
   204  
   205  匹配 Android 应用包名。
   206  
   207  #### user
   208  
   209  !!! error ""
   210  
   211      仅支持 Linux.
   212  
   213  匹配用户名。
   214  
   215  #### user_id
   216  
   217  !!! error ""
   218  
   219      仅支持 Linux.
   220  
   221  匹配用户 ID。
   222  
   223  #### clash_mode
   224  
   225  匹配 Clash 模式。
   226  
   227  #### invert
   228  
   229  反选匹配结果。
   230  
   231  #### outbound
   232  
   233  ==必填==
   234  
   235  目标出站的标签。
   236  
   237  ### 逻辑字段
   238  
   239  #### type
   240  
   241  `logical`
   242  
   243  #### mode
   244  
   245  `and` 或 `or`
   246  
   247  #### rules
   248  
   249  包括的默认规则。
   250  
   251  #### invert
   252  
   253  反选匹配结果。
   254  
   255  #### outbound
   256  
   257  ==必填==
   258  
   259  目标出站的标签。