Compare commits

...

4 Commits

Author SHA1 Message Date
世界
72fbd3248b
Bump version 2025-05-04 18:47:34 +08:00
世界
8b489354e4
Undeprecate the block outbound 2025-05-04 18:45:53 +08:00
世界
7dea6eb7a6
Fix missing read waiter for cancelers 2025-05-04 18:14:21 +08:00
世界
af1bfe4e3e
Make rule_set.format optional 2025-05-04 18:14:21 +08:00
11 changed files with 83 additions and 23 deletions

@ -1 +1 @@
Subproject commit 6a15780ce1659a234816f7248cbc09e8ea54a1be Subproject commit 9dd336679d14a1d16c6d72b1a67c4abc4ccae4c0

View File

@ -5,6 +5,7 @@ import (
"context" "context"
"io" "io"
"os" "os"
"path/filepath"
"github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/srs" "github.com/sagernet/sing-box/common/srs"
@ -56,6 +57,14 @@ func ruleSetMatch(sourcePath string, domain string) error {
if err != nil { if err != nil {
return E.Cause(err, "read rule-set") return E.Cause(err, "read rule-set")
} }
if flagRuleSetMatchFormat == "" {
switch filepath.Ext(sourcePath) {
case ".json":
flagRuleSetMatchFormat = C.RuleSetFormatSource
case ".srs":
flagRuleSetMatchFormat = C.RuleSetFormatBinary
}
}
var ruleSet option.PlainRuleSetCompat var ruleSet option.PlainRuleSetCompat
switch flagRuleSetMatchFormat { switch flagRuleSetMatchFormat {
case C.RuleSetFormatSource: case C.RuleSetFormatSource:

View File

@ -2,11 +2,25 @@
icon: material/alert-decagram icon: material/alert-decagram
--- ---
### 1.11.10
* Undeprecate the `block` outbound **1**
* Fixes and improvements
**1**:
Since we dont have a replacement for using the `block` outbound in selectors yet,
we decided to temporarily undeprecate the `block` outbound until a replacement is available in the future.
_We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we
violated the rules (TestFlight users are not affected)._
### 1.11.9 ### 1.11.9
* Fixes and improvements * Fixes and improvements
_We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we violated the rules (TestFlight users are not affected)._ _We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we
violated the rules (TestFlight users are not affected)._
### 1.11.8 ### 1.11.8
@ -18,25 +32,29 @@ _We are temporarily unable to update sing-box apps on the App Store because the
Now `auto_redirect` fixes compatibility issues between TUN and Docker bridge networks, Now `auto_redirect` fixes compatibility issues between TUN and Docker bridge networks,
see [Tun](/configuration/inbound/tun/#auto_redirect). see [Tun](/configuration/inbound/tun/#auto_redirect).
_We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we violated the rules (TestFlight users are not affected)._ _We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we
violated the rules (TestFlight users are not affected)._
### 1.11.7 ### 1.11.7
* Fixes and improvements * Fixes and improvements
_We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we violated the rules (TestFlight users are not affected)._ _We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we
violated the rules (TestFlight users are not affected)._
### 1.11.6 ### 1.11.6
* Fixes and improvements * Fixes and improvements
_We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we violated the rules (TestFlight users are not affected)._ _We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we
violated the rules (TestFlight users are not affected)._
### 1.11.5 ### 1.11.5
* Fixes and improvements * Fixes and improvements
_We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we violated the rules (TestFlight users are not affected)._ _We are temporarily unable to update sing-box apps on the App Store because the reviewer mistakenly found that we
violated the rules (TestFlight users are not affected)._
### 1.11.4 ### 1.11.4
@ -46,7 +64,8 @@ _We are temporarily unable to update sing-box apps on the App Store because the
* Fixes and improvements * Fixes and improvements
_This version overwrites 1.11.2, as incorrect binaries were released due to a bug in the continuous integration process._ _This version overwrites 1.11.2, as incorrect binaries were released due to a bug in the continuous integration
process._
### 1.11.1 ### 1.11.1

View File

@ -2,10 +2,6 @@
icon: material/delete-clock icon: material/delete-clock
--- ---
!!! failure "Deprecated in sing-box 1.11.0"
Legacy special outbounds are deprecated and will be removed in sing-box 1.13.0, check [Migration](/migration/#migrate-legacy-special-outbounds-to-rule-actions).
### Structure ### Structure
```json ```json

View File

@ -2,10 +2,6 @@
icon: material/delete-clock icon: material/delete-clock
--- ---
!!! failure "已在 sing-box 1.11.0 废弃"
旧的特殊出站已被弃用,且将在 sing-box 1.13.0 中被移除,参阅 [迁移指南](/migration/#migrate-legacy-special-outbounds-to-rule-actions).
`block` 出站关闭所有传入请求。 `block` 出站关闭所有传入请求。
### 结构 ### 结构

View File

@ -84,6 +84,8 @@ List of [Headless Rule](./headless-rule/).
Format of rule-set file, `source` or `binary`. Format of rule-set file, `source` or `binary`.
Optional when `path` or `url` uses `json` or `srs` as extension.
### Local Fields ### Local Fields
#### path #### path

View File

@ -84,6 +84,8 @@ icon: material/new-box
规则集格式, `source``binary` 规则集格式, `source``binary`
`path``url` 使用 `json``srs` 作为扩展名时可选。
### 本地字段 ### 本地字段
#### path #### path

2
go.mod
View File

@ -26,7 +26,7 @@ require (
github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff
github.com/sagernet/quic-go v0.49.0-beta.1 github.com/sagernet/quic-go v0.49.0-beta.1
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691
github.com/sagernet/sing v0.6.8-0.20250429070844-b63643251ed5 github.com/sagernet/sing v0.6.8
github.com/sagernet/sing-dns v0.4.2 github.com/sagernet/sing-dns v0.4.2
github.com/sagernet/sing-mux v0.3.2 github.com/sagernet/sing-mux v0.3.2
github.com/sagernet/sing-quic v0.4.1-0.20250423030647-0eb05f373a76 github.com/sagernet/sing-quic v0.4.1-0.20250423030647-0eb05f373a76

4
go.sum
View File

@ -119,8 +119,8 @@ github.com/sagernet/quic-go v0.49.0-beta.1/go.mod h1:uesWD1Ihrldq1M3XtjuEvIUqi8W
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc= github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc=
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU= github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
github.com/sagernet/sing v0.6.7/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing v0.6.7/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing v0.6.8-0.20250429070844-b63643251ed5 h1:j5r2x3Lazb1giycHFxICc201LSyDn3ZH+ywa+8duNxo= github.com/sagernet/sing v0.6.8 h1:rpi0MozOxq2xD2/sAqXJDaoxLOvGU+foBs1a6HsYErg=
github.com/sagernet/sing v0.6.8-0.20250429070844-b63643251ed5/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing v0.6.8/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing-dns v0.4.2 h1:cWe2XPUBFLep2j9kJV4Epg3bctGhMvrrl/sWi9Wszfg= github.com/sagernet/sing-dns v0.4.2 h1:cWe2XPUBFLep2j9kJV4Epg3bctGhMvrrl/sWi9Wszfg=
github.com/sagernet/sing-dns v0.4.2/go.mod h1:dweQs54ng2YGzoJfz+F9dGuDNdP5pJ3PLeggnK5VWc8= github.com/sagernet/sing-dns v0.4.2/go.mod h1:dweQs54ng2YGzoJfz+F9dGuDNdP5pJ3PLeggnK5VWc8=
github.com/sagernet/sing-mux v0.3.2 h1:meZVFiiStvHThb/trcpAkCrmtJOuItG5Dzl1RRP5/NE= github.com/sagernet/sing-mux v0.3.2 h1:meZVFiiStvHThb/trcpAkCrmtJOuItG5Dzl1RRP5/NE=

View File

@ -39,7 +39,7 @@ func (h *Outbound) UnmarshalJSONContext(ctx context.Context, content []byte) err
return E.New("missing outbound options registry in context") return E.New("missing outbound options registry in context")
} }
switch h.Type { switch h.Type {
case C.TypeBlock, C.TypeDNS: case C.TypeDNS:
deprecated.Report(ctx, deprecated.OptionSpecialOutbounds) deprecated.Report(ctx, deprecated.OptionSpecialOutbounds)
} }
options, loaded := registry.CreateOptions(h.Type) options, loaded := registry.CreateOptions(h.Type)

View File

@ -1,6 +1,8 @@
package option package option
import ( import (
"net/url"
"path/filepath"
"reflect" "reflect"
C "github.com/sagernet/sing-box/constant" C "github.com/sagernet/sing-box/constant"
@ -27,6 +29,18 @@ type _RuleSet struct {
type RuleSet _RuleSet type RuleSet _RuleSet
func (r RuleSet) MarshalJSON() ([]byte, error) { func (r RuleSet) MarshalJSON() ([]byte, error) {
if r.Type != C.RuleSetTypeInline {
var defaultFormat string
switch r.Type {
case C.RuleSetTypeLocal:
defaultFormat = ruleSetDefaultFormat(r.LocalOptions.Path)
case C.RuleSetTypeRemote:
defaultFormat = ruleSetDefaultFormat(r.RemoteOptions.URL)
}
if r.Format == defaultFormat {
r.Format = ""
}
}
var v any var v any
switch r.Type { switch r.Type {
case "", C.RuleSetTypeInline: case "", C.RuleSetTypeInline:
@ -62,7 +76,19 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
default: default:
return E.New("unknown rule-set type: " + r.Type) return E.New("unknown rule-set type: " + r.Type)
} }
err = badjson.UnmarshallExcluded(bytes, (*_RuleSet)(r), v)
if err != nil {
return err
}
if r.Type != C.RuleSetTypeInline { if r.Type != C.RuleSetTypeInline {
if r.Format == "" {
switch r.Type {
case C.RuleSetTypeLocal:
r.Format = ruleSetDefaultFormat(r.LocalOptions.Path)
case C.RuleSetTypeRemote:
r.Format = ruleSetDefaultFormat(r.RemoteOptions.URL)
}
}
switch r.Format { switch r.Format {
case "": case "":
return E.New("missing format") return E.New("missing format")
@ -73,13 +99,23 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
} else { } else {
r.Format = "" r.Format = ""
} }
err = badjson.UnmarshallExcluded(bytes, (*_RuleSet)(r), v)
if err != nil {
return err
}
return nil return nil
} }
func ruleSetDefaultFormat(path string) string {
if pathURL, err := url.Parse(path); err == nil {
path = pathURL.Path
}
switch filepath.Ext(path) {
case ".json":
return C.RuleSetFormatSource
case ".srs":
return C.RuleSetFormatBinary
default:
return ""
}
}
type LocalRuleSet struct { type LocalRuleSet struct {
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
} }