Skip to content

Commit

Permalink
update from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jashok2 committed Mar 15, 2024
2 parents 2084a76 + 1482baa commit 129f8ef
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 32 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Release to Linux repository

on:
release:
types:
- released
- prereleased
workflow_dispatch:

jobs:
build:
Expand All @@ -23,7 +20,7 @@ jobs:
with:
distribution: goreleaser-pro
version: latest
args: release --clean --skip publish
args: goreleaser release -f .goreleaser.fury.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
1 change: 0 additions & 1 deletion .goreleaser.fury.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ builds:
- with_reality_server
- with_acme
- with_clash_api
- with_shadowsocksr
env:
- CGO_ENABLED=0
targets:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MAIN_PARAMS = $(PARAMS) -tags $(TAGS)
MAIN = ./cmd/sing-box
PREFIX ?= $(shell go env GOPATH)

.PHONY: test release docs
.PHONY: test release docs build

build:
go build $(MAIN_PARAMS) $(MAIN)
Expand Down
2 changes: 1 addition & 1 deletion clients/android
Submodule android updated 72 files
+1 −17 app/build.gradle
+2 −0 app/src/main/java/io/nekohasekai/sfa/Application.kt
+1 −1 app/src/main/java/io/nekohasekai/sfa/bg/AppChangeReceiver.kt
+4 −0 app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt
+12 −0 app/src/main/java/io/nekohasekai/sfa/ktx/Clips.kt
+2 −2 app/src/main/java/io/nekohasekai/sfa/ktx/Intents.kt
+54 −23 app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt
+49 −10 app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt
+0 −22 app/src/main/java/io/nekohasekai/sfa/ui/dashboard/OverviewFragment.kt
+1 −8 app/src/main/java/io/nekohasekai/sfa/ui/debug/DebugActivity.kt
+1 −6 app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt
+43 −5 app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt
+9 −0 app/src/main/java/io/nekohasekai/sfa/ui/main/SettingsFragment0.kt
+3 −30 app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileActivity.kt
+4 −14 app/src/main/java/io/nekohasekai/sfa/ui/profile/EditProfileContentActivity.kt
+1 −11 app/src/main/java/io/nekohasekai/sfa/ui/profile/NewProfileActivity.kt
+532 −353 app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt
+3 −7 app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/ProfileOverrideActivity.kt
+27 −0 app/src/main/java/io/nekohasekai/sfa/ui/settings/AbstractSettingsFragment.kt
+6 −0 app/src/main/java/io/nekohasekai/sfa/ui/settings/CoreFragment.kt
+45 −0 app/src/main/java/io/nekohasekai/sfa/ui/settings/Preference.kt
+48 −11 app/src/main/java/io/nekohasekai/sfa/ui/shared/AbstractActivity.kt
+1 −1 app/src/main/java/io/nekohasekai/sfa/utils/CommandClient.kt
+31 −0 app/src/main/java/io/nekohasekai/sfa/utils/MIUIUtils.kt
+9 −4 app/src/main/res/drawable/ic_delete_24.xml
+9 −4 app/src/main/res/drawable/ic_electric_bolt_24.xml
+9 −4 app/src/main/res/drawable/ic_expand_less_24.xml
+9 −4 app/src/main/res/drawable/ic_expand_more_24.xml
+9 −4 app/src/main/res/drawable/ic_find_in_page_24.xml
+9 −4 app/src/main/res/drawable/ic_ios_share_24.xml
+10 −4 app/src/main/res/drawable/ic_message_24.xml
+9 −4 app/src/main/res/drawable/ic_more_vert_24.xml
+9 −4 app/src/main/res/drawable/ic_settings_24.xml
+120 −110 app/src/main/res/layout/activity_add_profile.xml
+68 −59 app/src/main/res/layout/activity_config_override.xml
+13 −4 app/src/main/res/layout/activity_debug.xml
+98 −90 app/src/main/res/layout/activity_edit_profile.xml
+25 −8 app/src/main/res/layout/activity_edit_profile_content.xml
+45 −4 app/src/main/res/layout/activity_main.xml
+36 −36 app/src/main/res/layout/activity_per_app_proxy.xml
+31 −13 app/src/main/res/layout/activity_vpn_scan.xml
+18 −0 app/src/main/res/layout/dialog_progressbar.xml
+1 −5 app/src/main/res/layout/fragment_configuration.xml
+11 −34 app/src/main/res/layout/fragment_dashboard.xml
+1 −3 app/src/main/res/layout/fragment_dashboard_groups.xml
+13 −32 app/src/main/res/layout/fragment_dashboard_overview.xml
+1 −3 app/src/main/res/layout/fragment_log.xml
+11 −12 app/src/main/res/layout/fragment_qrcode_dialog.xml
+7 −6 app/src/main/res/layout/fragment_settings.xml
+6 −0 app/src/main/res/layout/fragment_settings_core.xml
+38 −18 app/src/main/res/layout/view_app_list_item.xml
+64 −0 app/src/main/res/layout/view_app_list_item0.xml
+15 −0 app/src/main/res/layout/view_appbar.xml
+68 −51 app/src/main/res/layout/view_dashboard_group.xml
+5 −1 app/src/main/res/layout/view_dashboard_group_item.xml
+9 −0 app/src/main/res/layout/view_prefenence_screen.xml
+25 −0 app/src/main/res/menu/app_menu.xml
+2 −2 app/src/main/res/menu/per_app_menu.xml
+99 −0 app/src/main/res/menu/per_app_menu0.xml
+5 −4 app/src/main/res/navigation/mobile_navigation.xml
+0 −4 app/src/main/res/values-night/colors.xml
+3 −2 app/src/main/res/values-night/themes.xml
+0 −2 app/src/main/res/values/colors.xml
+40 −6 app/src/main/res/values/strings.xml
+2 −1 app/src/main/res/values/themes.xml
+9 −3 app/src/main/res/xml/backup_rules.xml
+3 −1 app/src/main/res/xml/cache_paths.xml
+18 −6 app/src/main/res/xml/data_extraction_rules.xml
+9 −0 app/src/main/res/xml/preferences_settings.xml
+1 −0 app/src/other/play/listings/en-US/graphics/icon/ic_launcher-playstore.png
+2 −3 build.gradle
+3 −3 version.properties
7 changes: 6 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
icon: material/alert-decagram
---

#### 1.9.0-beta.12
#### 1.9.0-beta.14

* Update gVisor to 20240212.0-65-g71212d503
* Fixes and improvements

#### 1.8.9

* Fixes and improvements

Expand Down
57 changes: 50 additions & 7 deletions docs/manual/proxy/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ flowchart TB
}
```

=== ":material-dns: DNS rules (1.9.0+)"
=== ":material-dns: DNS rules (Enhanced, but slower) (1.9.0+)"

=== ":material-shield-off: With DNS leaks"

=== ":material-shield-off: With DNS Leaks"

```json
{
"dns": {
Expand Down Expand Up @@ -376,7 +376,16 @@ flowchart TB
"server": "google"
},
{
"rule_set": "geoip-cn",
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": "geosite-geolocation-!cn"
},
{
"rule_set": "geoip-cn"
}
],
"server": "local"
}
]
Expand All @@ -389,6 +398,12 @@ flowchart TB
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs"
},
{
"type": "remote",
"tag": "geosite-geolocation-!cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs"
},
{
"type": "remote",
"tag": "geoip-cn",
Expand All @@ -398,14 +413,18 @@ flowchart TB
]
},
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Leak"
"default_mode": "Enhanced"
}
}
}
```

=== ":material-security: Without DNS Leaks (1.9.0-alpha.2+)"
=== ":material-security: Without DNS leaks, but slower (1.9.0-alpha.2+)"

```json
{
Expand Down Expand Up @@ -439,7 +458,16 @@ flowchart TB
"server": "local"
},
{
"rule_set": "geoip-cn",
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": "geosite-geolocation-!cn"
},
{
"rule_set": "geoip-cn"
}
],
"server": "google",
"client_subnet": "114.114.114.114" // Any China client IP address
}
Expand All @@ -453,13 +481,28 @@ flowchart TB
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs"
},
{
"type": "remote",
"tag": "geosite-geolocation-!cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs"
},
{
"type": "remote",
"tag": "geoip-cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs"
}
]
},
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Enhanced"
}
}
}
```
Expand Down
1 change: 1 addition & 0 deletions experimental/libbox/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const (
CommandLog int32 = iota
CommandStatus
CommandServiceReload
CommandServiceClose
CommandCloseConnections
CommandGroup
CommandSelectOutbound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,41 @@ func (s *CommandServer) handleServiceReload(conn net.Conn) error {
}
return nil
}

func (c *CommandClient) ServiceClose() error {
conn, err := c.directConnect()
if err != nil {
return err
}
defer conn.Close()
err = binary.Write(conn, binary.BigEndian, uint8(CommandServiceClose))
if err != nil {
return err
}
var hasError bool
err = binary.Read(conn, binary.BigEndian, &hasError)
if err != nil {
return nil
}
if hasError {
errorMessage, err := rw.ReadVString(conn)
if err != nil {
return nil
}
return E.New(errorMessage)
}
return nil
}

func (s *CommandServer) handleServiceClose(conn net.Conn) error {
rErr := s.service.Close()
s.handler.PostServiceClose()
err := binary.Write(conn, binary.BigEndian, rErr != nil)
if err != nil {
return err
}
if rErr != nil {
return rw.WriteVString(conn, rErr.Error())
}
return nil
}
16 changes: 11 additions & 5 deletions experimental/libbox/command_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type CommandServer struct {

type CommandServerHandler interface {
ServiceReload() error
PostServiceClose()
GetSystemProxyStatus() *SystemProxyStatus
SetSystemProxyEnabled(isEnabled bool) error
}
Expand All @@ -58,16 +59,19 @@ func (s *CommandServer) SetService(newService *BoxService) {
if newService != nil {
service.PtrFromContext[urltest.HistoryStorage](newService.ctx).SetHook(s.urlTestUpdate)
newService.instance.Router().ClashServer().(*clashapi.Server).SetModeUpdateHook(s.modeUpdate)
s.savedLines.Init()
select {
case s.logReset <- struct{}{}:
default:
}
}
s.service = newService
s.notifyURLTestUpdate()
}

func (s *CommandServer) ResetLog() {
s.savedLines.Init()
select {
case s.logReset <- struct{}{}:
default:
}
}

func (s *CommandServer) notifyURLTestUpdate() {
select {
case s.urlTestUpdate <- struct{}{}:
Expand Down Expand Up @@ -152,6 +156,8 @@ func (s *CommandServer) handleConnection(conn net.Conn) error {
return s.handleStatusConn(conn)
case CommandServiceReload:
return s.handleServiceReload(conn)
case CommandServiceClose:
return s.handleServiceClose(conn)
case CommandCloseConnections:
return s.handleCloseConnections(conn)
case CommandGroup:
Expand Down
13 changes: 13 additions & 0 deletions experimental/libbox/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ package libbox
import (
"context"
"net/netip"
"os"
"runtime"
runtimeDebug "runtime/debug"
"syscall"
"time"

"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/process"
"github.com/sagernet/sing-box/common/urltest"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/experimental/libbox/internal/procfs"
"github.com/sagernet/sing-box/experimental/libbox/platform"
"github.com/sagernet/sing-box/log"
Expand Down Expand Up @@ -72,6 +75,16 @@ func (s *BoxService) Start() error {
}

func (s *BoxService) Close() error {
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-done:
return
case <-time.After(C.DefaultStopFatalTimeout):
os.Exit(1)
}
}()
s.cancel()
s.urlTestHistoryStorage.Close()
return s.instance.Close()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
github.com/sagernet/sing-shadowsocks v0.2.6
github.com/sagernet/sing-shadowsocks2 v0.2.0
github.com/sagernet/sing-shadowtls v0.1.4
github.com/sagernet/sing-tun v0.2.4-beta.1
github.com/sagernet/sing-tun v0.2.5-beta.1
github.com/sagernet/sing-vmess v0.1.8
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7
github.com/sagernet/tfo-go v0.0.0-20231209031829-7b5343ac1dc6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ github.com/sagernet/sing-shadowsocks2 v0.2.0 h1:wpZNs6wKnR7mh1wV9OHwOyUr21VkS3wK
github.com/sagernet/sing-shadowsocks2 v0.2.0/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
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.2.4-beta.1 h1:npx/TwmVqsGZxw5aX08oRHpFBaIw3VSgR/CVfz1BA1A=
github.com/sagernet/sing-tun v0.2.4-beta.1/go.mod h1:lkefC8gty7FTuzz9ZoNASueutIhClEz7LHjFK3BLGco=
github.com/sagernet/sing-tun v0.2.5-beta.1 h1:a6KnZR1XbsEaowAR6bC32y86WPoZm3We57NGzZO3ryo=
github.com/sagernet/sing-tun v0.2.5-beta.1/go.mod h1:lkefC8gty7FTuzz9ZoNASueutIhClEz7LHjFK3BLGco=
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=
Expand Down
8 changes: 6 additions & 2 deletions route/router_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,24 @@ func (r *Router) Exchange(ctx context.Context, message *mDNS.Msg) (*mDNS.Msg, er
response, err = r.dnsClient.Exchange(dnsCtx, transport, message, strategy)
}
cancel()
var rejected bool
if err != nil {
if errors.Is(err, dns.ErrResponseRejectedCached) {
rejected = true
r.dnsLogger.DebugContext(ctx, E.Cause(err, "response rejected for ", formatQuestion(message.Question[0].String())), " (cached)")
} else if errors.Is(err, dns.ErrResponseRejected) {
rejected = true
r.dnsLogger.DebugContext(ctx, E.Cause(err, "response rejected for ", formatQuestion(message.Question[0].String())))
} else if len(message.Question) > 0 {
r.dnsLogger.ErrorContext(ctx, E.Cause(err, "exchange failed for ", formatQuestion(message.Question[0].String())))
} else {
r.dnsLogger.ErrorContext(ctx, E.Cause(err, "exchange failed for <empty query>"))
}
}
if !addressLimit || err == nil {
break
if addressLimit && rejected {
continue
}
break
}
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ require (
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
github.com/sagernet/sing-mux v0.2.0 // indirect
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
github.com/sagernet/sing-tun v0.2.4-beta.1 // indirect
github.com/sagernet/sing-tun v0.2.5-beta.1 // 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
Expand Down
1 change: 1 addition & 0 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ github.com/sagernet/sing-tun v0.1.24-0.20231212060935-6a1419aeae11/go.mod h1:DgX
github.com/sagernet/sing-tun v0.2.2-beta.1/go.mod h1:w1HTPPEL575m+Ob3GOIWaTs3ZrTdgLIwoldce/p3WPU=
github.com/sagernet/sing-tun v0.2.2-beta.3/go.mod h1:TaUYOzyBWK43Si6TadJ4gc7fj2iYZ7kxcp6CzzKey3E=
github.com/sagernet/sing-tun v0.2.4-beta.1/go.mod h1:lkefC8gty7FTuzz9ZoNASueutIhClEz7LHjFK3BLGco=
github.com/sagernet/sing-tun v0.2.5-beta.1/go.mod h1:lkefC8gty7FTuzz9ZoNASueutIhClEz7LHjFK3BLGco=
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=
Expand Down
8 changes: 4 additions & 4 deletions transport/wireguard/device_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type StackDevice struct {
stack *stack.Stack
mtu uint32
events chan wgTun.Event
outbound chan stack.PacketBufferPtr
outbound chan *stack.PacketBuffer
packetOutbound chan *buf.Buffer
done chan struct{}
dispatcher stack.NetworkDispatcher
Expand All @@ -52,7 +52,7 @@ func NewStackDevice(localAddresses []netip.Prefix, mtu uint32) (*StackDevice, er
stack: ipStack,
mtu: mtu,
events: make(chan wgTun.Event, 1),
outbound: make(chan stack.PacketBufferPtr, 256),
outbound: make(chan *stack.PacketBuffer, 256),
packetOutbound: make(chan *buf.Buffer, 256),
done: make(chan struct{}),
}
Expand Down Expand Up @@ -283,10 +283,10 @@ func (ep *wireEndpoint) ARPHardwareType() header.ARPHardwareType {
return header.ARPHardwareNone
}

func (ep *wireEndpoint) AddHeader(buffer stack.PacketBufferPtr) {
func (ep *wireEndpoint) AddHeader(buffer *stack.PacketBuffer) {
}

func (ep *wireEndpoint) ParseHeader(ptr stack.PacketBufferPtr) bool {
func (ep *wireEndpoint) ParseHeader(ptr *stack.PacketBuffer) bool {
return true
}

Expand Down

0 comments on commit 129f8ef

Please sign in to comment.