Compare commits

..
Author SHA1 Message Date
世界 7ec275b54b documentation: Bump version 2023-12-12 14:17:27 +08:00
世界 89eb866a70 Refactor inbound/outbound options struct 2023-12-12 14:17:27 +08:00
世界 5a235dff20 Improve configuration merge 2023-12-12 14:17:27 +08:00
世界 3afc8d815c Update uTLS to 1.5.4 2023-12-12 14:17:27 +08:00
世界 2d45adf2bb Update tfo-go 2023-12-12 14:17:27 +08:00
世界 7eb0ded48d Update gomobile and add tag 2023-12-12 14:17:27 +08:00
世界 d6d4c9826c Update cloudflare-tls to go1.21.5 2023-12-12 14:17:27 +08:00
世界 ac2c01ad72 Improve read wait interface &
Refactor Authenticator interface to struct &
Update smux &
Update gVisor to 20231204.0 &
Update wireguard-go &
Add GSO support for TUN/WireGuard
2023-12-12 14:17:27 +08:00
世界 94d18e9649 Make type check strict 2023-12-12 14:17:27 +08:00
世界 036edee6d9 Remove comparable limit for Listable 2023-12-12 14:17:27 +08:00
世界 4f668b4d7b Avoid opening log output before start &
Replace tracing logs with task monitor
2023-12-12 14:17:27 +08:00
世界 c60465a01f Update documentation 2023-12-12 14:08:26 +08:00
世界 cf6d8318e2 Add idle_timeout for URLTest outbound 2023-12-12 14:08:26 +08:00
世界 b8fc1f7e58 Skip internal fake-ip queries 2023-12-12 14:08:25 +08:00
世界 7888a15fa5 Migrate contentjson and badjson to library &
Add omitempty in format
2023-12-12 14:08:25 +08:00
世界 894f39ec0f Update documentation 2023-12-12 14:08:25 +08:00
世界 5d3ffb62dc Independent source_ip_is_private and ip_is_private rules 2023-12-12 14:08:25 +08:00
世界 ce316c182d Add rule-set 2023-12-12 14:08:16 +08:00
世界 f594f186fb Update buffer usage 2023-12-12 14:08:16 +08:00
世界 6259717410 Allow nested logical rules 2023-12-12 14:08:14 +08:00
世界 50689ca969 Migrate to independent cache file 2023-12-12 14:08:12 +08:00
8 changed files with 33 additions and 123 deletions
+2 -1
View File
@@ -57,7 +57,8 @@ func readConfigAt(path string) (*OptionsEntry, error) {
if err != nil {
return nil, E.Cause(err, "read config at ", path)
}
options, err := json.UnmarshalExtended[option.Options](configContent)
var options option.Options
err = options.UnmarshalJSON(configContent)
if err != nil {
return nil, E.Cause(err, "decode config at ", path)
}
+4 -8
View File
@@ -2,19 +2,11 @@
icon: material/alert-decagram
---
#### 1.8.0-beta.3
* Fixes and improvements
#### 1.8.0-beta.2
* Fix GSO support
* Fixes and improvements
#### 1.7.5
* Fixes and improvements
#### 1.8.0-alpha.17
* Add GSO support for TUN and WireGuard system interface **1**
@@ -37,6 +29,10 @@ Updated `cloudflare-tls`, `gomobile`, `smux`, `tfo-go` and `wireguard-go` to lat
This may break something, good luck!
#### 1.7.5
* Fixes and improvements
#### 1.7.4
* Fixes and improvements
+5 -100
View File
@@ -3,24 +3,16 @@ package libbox
import (
"bytes"
"context"
"net/netip"
"os"
"encoding/json"
"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/process"
"github.com/sagernet/sing-box/experimental/libbox/platform"
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-tun"
"github.com/sagernet/sing/common/control"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/json"
"github.com/sagernet/sing/common/logger"
"github.com/sagernet/sing/common/x/list"
)
func parseConfig(configContent string) (option.Options, error) {
options, err := json.UnmarshalExtended[option.Options]([]byte(configContent))
var options option.Options
err := options.UnmarshalJSON([]byte(configContent))
if err != nil {
return option.Options{}, E.Cause(err, "decode config")
}
@@ -35,9 +27,8 @@ func CheckConfig(configContent string) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
instance, err := box.New(box.Options{
Context: ctx,
Options: options,
PlatformInterface: (*platformInterfaceStub)(nil),
Context: ctx,
Options: options,
})
if err == nil {
instance.Close()
@@ -45,92 +36,6 @@ func CheckConfig(configContent string) error {
return err
}
type platformInterfaceStub struct{}
func (s *platformInterfaceStub) Initialize(ctx context.Context, router adapter.Router) error {
return nil
}
func (s *platformInterfaceStub) UsePlatformAutoDetectInterfaceControl() bool {
return true
}
func (s *platformInterfaceStub) AutoDetectInterfaceControl() control.Func {
return nil
}
func (s *platformInterfaceStub) OpenTun(options *tun.Options, platformOptions option.TunPlatformOptions) (tun.Tun, error) {
return nil, os.ErrInvalid
}
func (s *platformInterfaceStub) UsePlatformDefaultInterfaceMonitor() bool {
return true
}
func (s *platformInterfaceStub) CreateDefaultInterfaceMonitor(logger logger.Logger) tun.DefaultInterfaceMonitor {
return (*interfaceMonitorStub)(nil)
}
func (s *platformInterfaceStub) UsePlatformInterfaceGetter() bool {
return true
}
func (s *platformInterfaceStub) Interfaces() ([]platform.NetworkInterface, error) {
return nil, os.ErrInvalid
}
func (s *platformInterfaceStub) UnderNetworkExtension() bool {
return false
}
func (s *platformInterfaceStub) ClearDNSCache() {
}
func (s *platformInterfaceStub) ReadWIFIState() adapter.WIFIState {
return adapter.WIFIState{}
}
func (s *platformInterfaceStub) FindProcessInfo(ctx context.Context, network string, source netip.AddrPort, destination netip.AddrPort) (*process.Info, error) {
return nil, os.ErrInvalid
}
type interfaceMonitorStub struct{}
func (s *interfaceMonitorStub) Start() error {
return os.ErrInvalid
}
func (s *interfaceMonitorStub) Close() error {
return os.ErrInvalid
}
func (s *interfaceMonitorStub) DefaultInterfaceName(destination netip.Addr) string {
return ""
}
func (s *interfaceMonitorStub) DefaultInterfaceIndex(destination netip.Addr) int {
return -1
}
func (s *interfaceMonitorStub) DefaultInterface(destination netip.Addr) (string, int) {
return "", -1
}
func (s *interfaceMonitorStub) OverrideAndroidVPN() bool {
return false
}
func (s *interfaceMonitorStub) AndroidVPNEnabled() bool {
return false
}
func (s *interfaceMonitorStub) RegisterCallback(callback tun.DefaultInterfaceUpdateCallback) *list.Element[tun.DefaultInterfaceUpdateCallback] {
return nil
}
func (s *interfaceMonitorStub) UnregisterCallback(element *list.Element[tun.DefaultInterfaceUpdateCallback]) {
}
func FormatConfig(configContent string) (string, error) {
options, err := parseConfig(configContent)
if err != nil {
+1 -1
View File
@@ -26,7 +26,7 @@ require (
github.com/sagernet/gvisor v0.0.0-20231209105102-8d27a30e436e
github.com/sagernet/quic-go v0.40.0
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691
github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226
github.com/sagernet/sing v0.2.20-0.20231211084415-35e7014b0898
github.com/sagernet/sing-dns v0.1.11
github.com/sagernet/sing-mux v0.1.6-0.20231208180947-9053c29513a2
github.com/sagernet/sing-quic v0.1.6-0.20231207143711-eb3cbf9ed054
+2 -2
View File
@@ -109,8 +109,8 @@ github.com/sagernet/quic-go v0.40.0/go.mod h1:VqtdhlbkeeG5Okhb3eDMb/9o0EoglReHun
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/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226 h1:rcII71ho6F/7Nyx7n2kESLcnvNMdcU4i8ZUGF2Fi7yA=
github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80=
github.com/sagernet/sing v0.2.20-0.20231211084415-35e7014b0898 h1:ZR0wpw4/0NCICOX10SIUW8jpPVV7+D98nGA6p4zWICo=
github.com/sagernet/sing v0.2.20-0.20231211084415-35e7014b0898/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80=
github.com/sagernet/sing-dns v0.1.11 h1:PPrMCVVrAeR3f5X23I+cmvacXJ+kzuyAsBiWyUKhGSE=
github.com/sagernet/sing-dns v0.1.11/go.mod h1:zJ/YjnYB61SYE+ubMcMqVdpaSvsyQ2iShQGO3vuLvvE=
github.com/sagernet/sing-mux v0.1.6-0.20231208180947-9053c29513a2 h1:rRlYQPbMKmzKX+43XC04gEQvxc45/AxfteRWfcl2/rw=
+13 -5
View File
@@ -2,7 +2,9 @@ package option
import (
"bytes"
"strings"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/json"
)
@@ -21,14 +23,20 @@ type _Options struct {
type Options _Options
func (o *Options) UnmarshalJSON(content []byte) error {
decoder := json.NewDecoder(bytes.NewReader(content))
decoder := json.NewDecoder(json.NewCommentFilter(bytes.NewReader(content)))
decoder.DisallowUnknownFields()
err := decoder.Decode((*_Options)(o))
if err != nil {
return err
if err == nil {
o.RawMessage = content
return nil
}
o.RawMessage = content
return nil
if syntaxError, isSyntaxError := err.(*json.SyntaxError); isSyntaxError {
prefix := string(content[:syntaxError.Offset])
row := strings.Count(prefix, "\n") + 1
column := len(prefix) - strings.LastIndex(prefix, "\n") - 1
return E.Extend(syntaxError, "row ", row, ", column ", column)
}
return err
}
type LogOptions struct {
+2 -2
View File
@@ -11,7 +11,7 @@ require (
github.com/docker/go-connections v0.4.0
github.com/gofrs/uuid/v5 v5.0.0
github.com/sagernet/quic-go v0.40.0
github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226
github.com/sagernet/sing v0.2.20-0.20231211084415-35e7014b0898
github.com/sagernet/sing-dns v0.1.11
github.com/sagernet/sing-quic v0.1.6-0.20231207143711-eb3cbf9ed054
github.com/sagernet/sing-shadowsocks v0.2.6
@@ -77,7 +77,7 @@ require (
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
github.com/sagernet/sing-mux v0.1.6-0.20231208180947-9053c29513a2 // indirect
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
github.com/sagernet/sing-tun v0.1.24-0.20231212060935-6a1419aeae11 // indirect
github.com/sagernet/sing-tun v0.1.24-0.20231211145236-1cd52bf7fa00 // indirect
github.com/sagernet/sing-vmess v0.1.8 // indirect
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
github.com/sagernet/tfo-go v0.0.0-20231209031829-7b5343ac1dc6 // indirect
+4 -4
View File
@@ -126,8 +126,8 @@ github.com/sagernet/quic-go v0.40.0/go.mod h1:VqtdhlbkeeG5Okhb3eDMb/9o0EoglReHun
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/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226 h1:rcII71ho6F/7Nyx7n2kESLcnvNMdcU4i8ZUGF2Fi7yA=
github.com/sagernet/sing v0.2.20-0.20231212123824-8836b6754226/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80=
github.com/sagernet/sing v0.2.20-0.20231211084415-35e7014b0898 h1:ZR0wpw4/0NCICOX10SIUW8jpPVV7+D98nGA6p4zWICo=
github.com/sagernet/sing v0.2.20-0.20231211084415-35e7014b0898/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80=
github.com/sagernet/sing-dns v0.1.11 h1:PPrMCVVrAeR3f5X23I+cmvacXJ+kzuyAsBiWyUKhGSE=
github.com/sagernet/sing-dns v0.1.11/go.mod h1:zJ/YjnYB61SYE+ubMcMqVdpaSvsyQ2iShQGO3vuLvvE=
github.com/sagernet/sing-mux v0.1.6-0.20231208180947-9053c29513a2 h1:rRlYQPbMKmzKX+43XC04gEQvxc45/AxfteRWfcl2/rw=
@@ -140,8 +140,8 @@ github.com/sagernet/sing-shadowsocks2 v0.1.6-0.20231207143709-50439739601a h1:uY
github.com/sagernet/sing-shadowsocks2 v0.1.6-0.20231207143709-50439739601a/go.mod h1:pjeylQ4ApvpEH7B4PUBrdyJf4xmQkg8BaIzT5fI2fR0=
github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnVpEx6Tw3k=
github.com/sagernet/sing-shadowtls v0.1.4/go.mod h1:F8NBgsY5YN2beQavdgdm1DPlhaKQlaL6lpDdcBglGK4=
github.com/sagernet/sing-tun v0.1.24-0.20231212060935-6a1419aeae11 h1:crTOVPJGOGWOW+Q2a0FQiiS/G2+W6uCLKtOofFMisQc=
github.com/sagernet/sing-tun v0.1.24-0.20231212060935-6a1419aeae11/go.mod h1:DgXPnBqtqWrZj37Mun/W61dW0Q56eLqTZYhcuNLaCtY=
github.com/sagernet/sing-tun v0.1.24-0.20231211145236-1cd52bf7fa00 h1:k9dybQoKrRNQCYzCA8uqY0oZjGSM57yxZJWjjAmkn6M=
github.com/sagernet/sing-tun v0.1.24-0.20231211145236-1cd52bf7fa00/go.mod h1:DgXPnBqtqWrZj37Mun/W61dW0Q56eLqTZYhcuNLaCtY=
github.com/sagernet/sing-vmess v0.1.8 h1:XVWad1RpTy9b5tPxdm5MCU8cGfrTGdR8qCq6HV2aCNc=
github.com/sagernet/sing-vmess v0.1.8/go.mod h1:vhx32UNzTDUkNwOyIjcZQohre1CaytquC5mPplId8uA=
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=