remove process_path_prefix

This commit is contained in:
世界 2024-09-15 11:38:03 +08:00
parent 7d5d0918fb
commit e7a318a109
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
14 changed files with 25 additions and 151 deletions

View File

@ -40,8 +40,7 @@ SFA provides an unprivileged TUN implementation through Android VpnService.
|-----------------------|------------------|-----------------------------------| |-----------------------|------------------|-----------------------------------|
| `process_name` | :material-close: | No permission | | `process_name` | :material-close: | No permission |
| `process_path` | :material-close: | No permission | | `process_path` | :material-close: | No permission |
| `process_path_prefix` | :material-close: | No permission | | `process_path_regex` | :material-close: | No permission |
| `process_path_regex` | :material-close: | No permission |
| `package_name` | :material-check: | / | | `package_name` | :material-check: | / |
| `user` | :material-close: | Use `package_name` instead | | `user` | :material-close: | Use `package_name` instead |
| `user_id` | :material-close: | Use `package_name` instead | | `user_id` | :material-close: | Use `package_name` instead |

View File

@ -42,7 +42,6 @@ SFI/SFM/SFT provides an unprivileged TUN implementation through NetworkExtension
|-----------------------|------------------|-----------------------| |-----------------------|------------------|-----------------------|
| `process_name` | :material-close: | No permission | | `process_name` | :material-close: | No permission |
| `process_path` | :material-close: | No permission | | `process_path` | :material-close: | No permission |
| `process_path_prefix` | :material-close: | No permission |
| `process_path_regex` | :material-close: | No permission | | `process_path_regex` | :material-close: | No permission |
| `package_name` | :material-close: | / | | `package_name` | :material-close: | / |
| `user` | :material-close: | No permission | | `user` | :material-close: | No permission |

View File

@ -6,7 +6,8 @@ icon: material/new-box
:material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source) :material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source)
:material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source) :material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source)
:material-plus: [rule_set_ip_cidr_accept_empty](#rule_set_ip_cidr_accept_empty) :material-plus: [rule_set_ip_cidr_accept_empty](#rule_set_ip_cidr_accept_empty)
:material-plus: [process_path_regex](#process_path_regex)
!!! quote "Changes in sing-box 1.9.0" !!! quote "Changes in sing-box 1.9.0"
@ -103,9 +104,6 @@ icon: material/new-box
"process_path": [ "process_path": [
"/usr/bin/curl" "/usr/bin/curl"
], ],
"process_path_prefix": [
"/usr/bin/"
],
"process_path_regex": [ "process_path_regex": [
"^/usr/bin/.+" "^/usr/bin/.+"
], ],
@ -274,16 +272,6 @@ Match process name.
Match process path. Match process path.
#### process_path_prefix
!!! question "Since sing-box 1.10.0"
!!! quote ""
Only supported on Linux, Windows, and macOS.
Match process path using prefix.
#### process_path_regex #### process_path_regex
!!! question "Since sing-box 1.10.0" !!! question "Since sing-box 1.10.0"

View File

@ -6,7 +6,8 @@ icon: material/new-box
:material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source) :material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source)
:material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source) :material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source)
:material-plus: [rule_set_ip_cidr_accept_empty](#rule_set_ip_cidr_accept_empty) :material-plus: [rule_set_ip_cidr_accept_empty](#rule_set_ip_cidr_accept_empty)
:material-plus: [process_path_regex](#process_path_regex)
!!! quote "sing-box 1.9.0 中的更改" !!! quote "sing-box 1.9.0 中的更改"
@ -103,9 +104,6 @@ icon: material/new-box
"process_path": [ "process_path": [
"/usr/bin/curl" "/usr/bin/curl"
], ],
"process_path_prefix": [
"/usr/bin/"
],
"process_path_regex": [ "process_path_regex": [
"^/usr/bin/.+" "^/usr/bin/.+"
], ],
@ -272,16 +270,6 @@ DNS 查询类型。值可以为整数或者类型名称字符串。
匹配进程路径。 匹配进程路径。
#### process_path_prefix
!!! question "自 sing-box 1.10.0 起"
!!! quote ""
仅支持 Linux、Windows 和 macOS.
匹配进程路径前缀。
#### process_path_regex #### process_path_regex
!!! question "自 sing-box 1.10.0 起" !!! question "自 sing-box 1.10.0 起"

View File

@ -7,7 +7,6 @@ icon: material/alert-decagram
:material-plus: [client](#client) :material-plus: [client](#client)
:material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source) :material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source)
:material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source) :material-plus: [rule_set_ip_cidr_match_source](#rule_set_ip_cidr_match_source)
:material-plus: [process_path_prefix](#process_path_prefix)
:material-plus: [process_path_regex](#process_path_regex) :material-plus: [process_path_regex](#process_path_regex)
!!! quote "Changes in sing-box 1.8.0" !!! quote "Changes in sing-box 1.8.0"
@ -103,9 +102,6 @@ icon: material/alert-decagram
"process_path": [ "process_path": [
"/usr/bin/curl" "/usr/bin/curl"
], ],
"process_path_prefix": [
"/usr/bin/"
],
"process_path_regex": [ "process_path_regex": [
"^/usr/bin/.+" "^/usr/bin/.+"
], ],
@ -285,16 +281,6 @@ Match process name.
Match process path. Match process path.
#### process_path_prefix
!!! question "Since sing-box 1.10.0"
!!! quote ""
Only supported on Linux, Windows, and macOS.
Match process path using prefix.
#### process_path_regex #### process_path_regex
!!! question "Since sing-box 1.10.0" !!! question "Since sing-box 1.10.0"

View File

@ -6,9 +6,9 @@ icon: material/alert-decagram
:material-plus: [client](#client) :material-plus: [client](#client)
:material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source) :material-delete-clock: [rule_set_ipcidr_match_source](#rule_set_ipcidr_match_source)
:material-plus: [process_path_prefix](#process_path_prefix)
:material-plus: [process_path_regex](#process_path_regex) :material-plus: [process_path_regex](#process_path_regex)
!!! quote "sing-box 1.8.0 中的更改" !!! quote "sing-box 1.8.0 中的更改"
:material-plus: [rule_set](#rule_set) :material-plus: [rule_set](#rule_set)
@ -100,9 +100,6 @@ icon: material/alert-decagram
"process_path": [ "process_path": [
"/usr/bin/curl" "/usr/bin/curl"
], ],
"process_path_prefix": [
"/usr/bin/"
],
"process_path_regex": [ "process_path_regex": [
"^/usr/bin/.+" "^/usr/bin/.+"
], ],
@ -282,16 +279,6 @@ icon: material/alert-decagram
匹配进程路径。 匹配进程路径。
#### process_path_prefix
!!! question "自 sing-box 1.10.0 起"
!!! quote ""
仅支持 Linux、Windows 和 macOS.
匹配进程路径前缀。
#### process_path_regex #### process_path_regex
!!! question "自 sing-box 1.10.0 起" !!! question "自 sing-box 1.10.0 起"

View File

@ -57,9 +57,6 @@
"process_path": [ "process_path": [
"/usr/bin/curl" "/usr/bin/curl"
], ],
"process_path_prefix": [
"/usr/bin/"
],
"process_path_regex": [ "process_path_regex": [
"^/usr/bin/.+" "^/usr/bin/.+"
], ],
@ -166,16 +163,6 @@ Match process name.
Match process path. Match process path.
#### process_path_prefix
!!! question "Since sing-box 1.10.0"
!!! quote ""
Only supported on Linux, Windows, and macOS.
Match process path using prefix.
#### process_path_regex #### process_path_regex
!!! question "Since sing-box 1.10.0" !!! question "Since sing-box 1.10.0"

View File

@ -88,7 +88,6 @@ type _DefaultRule struct {
PortRange Listable[string] `json:"port_range,omitempty"` PortRange Listable[string] `json:"port_range,omitempty"`
ProcessName Listable[string] `json:"process_name,omitempty"` ProcessName Listable[string] `json:"process_name,omitempty"`
ProcessPath Listable[string] `json:"process_path,omitempty"` ProcessPath Listable[string] `json:"process_path,omitempty"`
ProcessPathPrefix Listable[string] `json:"process_path_prefix,omitempty"`
ProcessPathRegex Listable[string] `json:"process_path_regex,omitempty"` ProcessPathRegex Listable[string] `json:"process_path_regex,omitempty"`
PackageName Listable[string] `json:"package_name,omitempty"` PackageName Listable[string] `json:"package_name,omitempty"`
User Listable[string] `json:"user,omitempty"` User Listable[string] `json:"user,omitempty"`

View File

@ -88,7 +88,6 @@ type _DefaultDNSRule struct {
PortRange Listable[string] `json:"port_range,omitempty"` PortRange Listable[string] `json:"port_range,omitempty"`
ProcessName Listable[string] `json:"process_name,omitempty"` ProcessName Listable[string] `json:"process_name,omitempty"`
ProcessPath Listable[string] `json:"process_path,omitempty"` ProcessPath Listable[string] `json:"process_path,omitempty"`
ProcessPathPrefix Listable[string] `json:"process_path_prefix,omitempty"`
ProcessPathRegex Listable[string] `json:"process_path_regex,omitempty"` ProcessPathRegex Listable[string] `json:"process_path_regex,omitempty"`
PackageName Listable[string] `json:"package_name,omitempty"` PackageName Listable[string] `json:"package_name,omitempty"`
User Listable[string] `json:"user,omitempty"` User Listable[string] `json:"user,omitempty"`

View File

@ -144,26 +144,25 @@ func (r HeadlessRule) IsValid() bool {
} }
type DefaultHeadlessRule struct { type DefaultHeadlessRule struct {
QueryType Listable[DNSQueryType] `json:"query_type,omitempty"` QueryType Listable[DNSQueryType] `json:"query_type,omitempty"`
Network Listable[string] `json:"network,omitempty"` Network Listable[string] `json:"network,omitempty"`
Domain Listable[string] `json:"domain,omitempty"` Domain Listable[string] `json:"domain,omitempty"`
DomainSuffix Listable[string] `json:"domain_suffix,omitempty"` DomainSuffix Listable[string] `json:"domain_suffix,omitempty"`
DomainKeyword Listable[string] `json:"domain_keyword,omitempty"` DomainKeyword Listable[string] `json:"domain_keyword,omitempty"`
DomainRegex Listable[string] `json:"domain_regex,omitempty"` DomainRegex Listable[string] `json:"domain_regex,omitempty"`
SourceIPCIDR Listable[string] `json:"source_ip_cidr,omitempty"` SourceIPCIDR Listable[string] `json:"source_ip_cidr,omitempty"`
IPCIDR Listable[string] `json:"ip_cidr,omitempty"` IPCIDR Listable[string] `json:"ip_cidr,omitempty"`
SourcePort Listable[uint16] `json:"source_port,omitempty"` SourcePort Listable[uint16] `json:"source_port,omitempty"`
SourcePortRange Listable[string] `json:"source_port_range,omitempty"` SourcePortRange Listable[string] `json:"source_port_range,omitempty"`
Port Listable[uint16] `json:"port,omitempty"` Port Listable[uint16] `json:"port,omitempty"`
PortRange Listable[string] `json:"port_range,omitempty"` PortRange Listable[string] `json:"port_range,omitempty"`
ProcessName Listable[string] `json:"process_name,omitempty"` ProcessName Listable[string] `json:"process_name,omitempty"`
ProcessPath Listable[string] `json:"process_path,omitempty"` ProcessPath Listable[string] `json:"process_path,omitempty"`
ProcessPathPrefix Listable[string] `json:"process_path_prefix,omitempty"` ProcessPathRegex Listable[string] `json:"process_path_regex,omitempty"`
ProcessPathRegex Listable[string] `json:"process_path_regex,omitempty"` PackageName Listable[string] `json:"package_name,omitempty"`
PackageName Listable[string] `json:"package_name,omitempty"` WIFISSID Listable[string] `json:"wifi_ssid,omitempty"`
WIFISSID Listable[string] `json:"wifi_ssid,omitempty"` WIFIBSSID Listable[string] `json:"wifi_bssid,omitempty"`
WIFIBSSID Listable[string] `json:"wifi_bssid,omitempty"` Invert bool `json:"invert,omitempty"`
Invert bool `json:"invert,omitempty"`
DomainMatcher *domain.Matcher `json:"-"` DomainMatcher *domain.Matcher `json:"-"`
SourceIPSet *netipx.IPSet `json:"-"` SourceIPSet *netipx.IPSet `json:"-"`

View File

@ -179,11 +179,6 @@ func NewDefaultRule(router adapter.Router, logger log.ContextLogger, options opt
rule.items = append(rule.items, item) rule.items = append(rule.items, item)
rule.allItems = append(rule.allItems, item) rule.allItems = append(rule.allItems, item)
} }
if len(options.ProcessPathPrefix) > 0 {
item := NewProcessPathPrefixItem(options.ProcessPathPrefix)
rule.items = append(rule.items, item)
rule.allItems = append(rule.allItems, item)
}
if len(options.ProcessPathRegex) > 0 { if len(options.ProcessPathRegex) > 0 {
item, err := NewProcessPathRegexItem(options.ProcessPathRegex) item, err := NewProcessPathRegexItem(options.ProcessPathRegex)
if err != nil { if err != nil {

View File

@ -183,11 +183,6 @@ func NewDefaultDNSRule(router adapter.Router, logger log.ContextLogger, options
rule.items = append(rule.items, item) rule.items = append(rule.items, item)
rule.allItems = append(rule.allItems, item) rule.allItems = append(rule.allItems, item)
} }
if len(options.ProcessPathPrefix) > 0 {
item := NewProcessPathPrefixItem(options.ProcessPathPrefix)
rule.items = append(rule.items, item)
rule.allItems = append(rule.allItems, item)
}
if len(options.ProcessPathRegex) > 0 { if len(options.ProcessPathRegex) > 0 {
item, err := NewProcessPathRegexItem(options.ProcessPathRegex) item, err := NewProcessPathRegexItem(options.ProcessPathRegex)
if err != nil { if err != nil {

View File

@ -123,11 +123,6 @@ func NewDefaultHeadlessRule(router adapter.Router, options option.DefaultHeadles
rule.items = append(rule.items, item) rule.items = append(rule.items, item)
rule.allItems = append(rule.allItems, item) rule.allItems = append(rule.allItems, item)
} }
if len(options.ProcessPathPrefix) > 0 {
item := NewProcessPathPrefixItem(options.ProcessPathPrefix)
rule.items = append(rule.items, item)
rule.allItems = append(rule.allItems, item)
}
if len(options.ProcessPathRegex) > 0 { if len(options.ProcessPathRegex) > 0 {
item, err := NewProcessPathRegexItem(options.ProcessPathRegex) item, err := NewProcessPathRegexItem(options.ProcessPathRegex)
if err != nil { if err != nil {

View File

@ -1,42 +0,0 @@
package route
import (
"strings"
"github.com/sagernet/sing-box/adapter"
)
var _ RuleItem = (*ProcessPathPrefixItem)(nil)
type ProcessPathPrefixItem struct {
processes []string
}
func NewProcessPathPrefixItem(directories []string) *ProcessPathPrefixItem {
return &ProcessPathPrefixItem{
processes: directories,
}
}
func (r *ProcessPathPrefixItem) Match(metadata *adapter.InboundContext) bool {
if metadata.ProcessInfo == nil || metadata.ProcessInfo.ProcessPath == "" {
return false
}
for _, processe := range r.processes {
if strings.HasPrefix(metadata.ProcessInfo.ProcessPath, processe) {
return true
}
}
return false
}
func (r *ProcessPathPrefixItem) String() string {
var description string
pLen := len(r.processes)
if pLen == 1 {
description = "process_path_prefix=" + r.processes[0]
} else {
description = "process_path_prefix=[" + strings.Join(r.processes, " ") + "]"
}
return description
}