Skip to content

Commit 8431ad3

Browse files
committed
Merge branch 'dev' of https://github.com/SagerNet/sing into dev
# Conflicts: # common/cond.go
2 parents 6bd8781 + 1c3b777 commit 8431ad3

File tree

124 files changed

+5936
-765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+5936
-765
lines changed

.github/renovate.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"commitMessagePrefix": "[dependencies]",
4-
"branchName": "main",
54
"extends": [
65
"config:base",
76
":disableRateLimiting"
87
],
8+
"baseBranches": [
9+
"dev"
10+
],
911
"packageRules": [
1012
{
1113
"matchManagers": [
@@ -15,9 +17,9 @@
1517
},
1618
{
1719
"matchManagers": [
18-
"gomod"
20+
"dockerfile"
1921
],
20-
"groupName": "gomod"
22+
"groupName": "Dockerfile"
2123
}
2224
]
2325
}

.github/workflows/lint.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint
1+
name: lint
22

33
on:
44
push:
@@ -24,16 +24,16 @@ jobs:
2424
with:
2525
fetch-depth: 0
2626
- name: Setup Go
27-
uses: actions/setup-go@v4
27+
uses: actions/setup-go@v5
2828
with:
29-
go-version: ^1.22
29+
go-version: ^1.23
3030
- name: Cache go module
31-
uses: actions/cache@v3
31+
uses: actions/cache@v4
3232
with:
3333
path: |
3434
~/go/pkg/mod
3535
key: go-${{ hashFiles('**/go.sum') }}
3636
- name: golangci-lint
37-
uses: golangci/golangci-lint-action@v3
37+
uses: golangci/golangci-lint-action@v6
3838
with:
3939
version: latest

.github/workflows/debug.yml renamed to .github/workflows/test.yml

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Debug build
1+
name: test
22

33
on:
44
push:
@@ -16,80 +16,96 @@ on:
1616

1717
jobs:
1818
build:
19-
name: Linux Debug build
19+
name: Linux
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 0
2626
- name: Setup Go
27-
uses: actions/setup-go@v4
27+
uses: actions/setup-go@v5
2828
with:
29-
go-version: ^1.22
29+
go-version: ^1.23
3030
- name: Build
3131
run: |
3232
make test
3333
build_go120:
34-
name: Linux Debug build (Go 1.20)
34+
name: Linux (Go 1.20)
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Checkout
3838
uses: actions/checkout@v4
3939
with:
4040
fetch-depth: 0
4141
- name: Setup Go
42-
uses: actions/setup-go@v4
42+
uses: actions/setup-go@v5
4343
with:
4444
go-version: ~1.20
4545
continue-on-error: true
4646
- name: Build
4747
run: |
4848
make test
4949
build_go121:
50-
name: Linux Debug build (Go 1.21)
50+
name: Linux (Go 1.21)
5151
runs-on: ubuntu-latest
5252
steps:
5353
- name: Checkout
5454
uses: actions/checkout@v4
5555
with:
5656
fetch-depth: 0
5757
- name: Setup Go
58-
uses: actions/setup-go@v4
58+
uses: actions/setup-go@v5
5959
with:
6060
go-version: ~1.21
6161
continue-on-error: true
6262
- name: Build
6363
run: |
6464
make test
65-
build__windows:
66-
name: Windows Debug build
65+
build_go122:
66+
name: Linux (Go 1.22)
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
- name: Setup Go
74+
uses: actions/setup-go@v5
75+
with:
76+
go-version: ~1.22
77+
continue-on-error: true
78+
- name: Build
79+
run: |
80+
make test
81+
build_windows:
82+
name: Windows
6783
runs-on: windows-latest
6884
steps:
6985
- name: Checkout
7086
uses: actions/checkout@v4
7187
with:
7288
fetch-depth: 0
7389
- name: Setup Go
74-
uses: actions/setup-go@v4
90+
uses: actions/setup-go@v5
7591
with:
76-
go-version: ^1.22
92+
go-version: ^1.23
7793
continue-on-error: true
7894
- name: Build
7995
run: |
8096
make test
8197
build_darwin:
82-
name: macOS Debug build
98+
name: macOS
8399
runs-on: macos-latest
84100
steps:
85101
- name: Checkout
86102
uses: actions/checkout@v4
87103
with:
88104
fetch-depth: 0
89105
- name: Setup Go
90-
uses: actions/setup-go@v4
106+
uses: actions/setup-go@v5
91107
with:
92-
go-version: ^1.22
108+
go-version: ^1.23
93109
continue-on-error: true
94110
- name: Build
95111
run: |

.golangci.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ linters:
55
- govet
66
- gci
77
- staticcheck
8+
- paralleltest
9+
- ineffassign
810

911
linters-settings:
1012
gci:
@@ -14,4 +16,9 @@ linters-settings:
1416
- prefix(github.com/sagernet/)
1517
- default
1618
staticcheck:
17-
go: '1.20'
19+
checks:
20+
- all
21+
- -SA1003
22+
23+
run:
24+
go: "1.23"

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ fmt_install:
88
go install -v github.com/daixiang0/gci@latest
99

1010
lint:
11-
GOOS=linux golangci-lint run ./...
12-
GOOS=android golangci-lint run ./...
13-
GOOS=windows golangci-lint run ./...
14-
GOOS=darwin golangci-lint run ./...
15-
GOOS=freebsd golangci-lint run ./...
11+
GOOS=linux golangci-lint run
12+
GOOS=android golangci-lint run
13+
GOOS=windows golangci-lint run
14+
GOOS=darwin golangci-lint run
15+
GOOS=freebsd golangci-lint run
1616

1717
lint_install:
1818
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
1919

2020
test:
21-
go test $(shell go list ./... | grep -v /internal/)
21+
go test ./...

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# sing
22

3+
![test](https://github.com/sagernet/sing/actions/workflows/test.yml/badge.svg)
4+
![lint](https://github.com/sagernet/sing/actions/workflows/lint.yml/badge.svg)
5+
36
Do you hear the people sing?

common/baderror/baderror.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package baderror
22

33
import (
44
"context"
5+
"errors"
56
"io"
67
"net"
78
"strings"
8-
9-
E "github.com/sagernet/sing/common/exceptions"
109
)
1110

1211
func Contains(err error, msgList ...string) bool {
@@ -22,8 +21,7 @@ func WrapH2(err error) error {
2221
if err == nil {
2322
return nil
2423
}
25-
err = E.Unwrap(err)
26-
if err == io.ErrUnexpectedEOF {
24+
if errors.Is(err, io.ErrUnexpectedEOF) {
2725
return io.EOF
2826
}
2927
if Contains(err, "client disconnected", "body closed by handler", "response body closed", "; CANCEL") {

common/bufio/addr_conn.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ import (
99

1010
type AddrConn struct {
1111
net.Conn
12-
M.Metadata
12+
Source M.Socksaddr
13+
Destination M.Socksaddr
1314
}
1415

1516
func (c *AddrConn) LocalAddr() net.Addr {
16-
if c.Metadata.Destination.IsValid() {
17-
return c.Metadata.Destination.TCPAddr()
17+
if c.Destination.IsValid() {
18+
return c.Destination.TCPAddr()
1819
}
1920
return c.Conn.LocalAddr()
2021
}
2122

2223
func (c *AddrConn) RemoteAddr() net.Addr {
23-
if c.Metadata.Source.IsValid() {
24-
return c.Metadata.Source.TCPAddr()
24+
if c.Source.IsValid() {
25+
return c.Source.TCPAddr()
2526
}
2627
return c.Conn.RemoteAddr()
2728
}

common/bufio/cache.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package bufio
33
import (
44
"io"
55
"net"
6-
"time"
76

87
"github.com/sagernet/sing/common/buf"
98
M "github.com/sagernet/sing/common/metadata"
@@ -60,13 +59,6 @@ func (c *CachedConn) WriteTo(w io.Writer) (n int64, err error) {
6059
return
6160
}
6261

63-
func (c *CachedConn) SetReadDeadline(t time.Time) error {
64-
if c.buffer != nil && !c.buffer.IsEmpty() {
65-
return nil
66-
}
67-
return c.Conn.SetReadDeadline(t)
68-
}
69-
7062
func (c *CachedConn) ReadFrom(r io.Reader) (n int64, err error) {
7163
return Copy(c.Conn, r)
7264
}
@@ -192,10 +184,12 @@ func (c *CachedPacketConn) ReadCachedPacket() *N.PacketBuffer {
192184
if buffer != nil {
193185
buffer.DecRef()
194186
}
195-
return &N.PacketBuffer{
187+
packet := N.NewPacketBuffer()
188+
*packet = N.PacketBuffer{
196189
Buffer: buffer,
197190
Destination: c.destination,
198191
}
192+
return packet
199193
}
200194

201195
func (c *CachedPacketConn) Upstream() any {

common/bufio/conn.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,7 @@ func (w *ExtendedUDPConn) ReadPacket(buffer *buf.Buffer) (M.Socksaddr, error) {
3535

3636
func (w *ExtendedUDPConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
3737
defer buffer.Release()
38-
if destination.IsFqdn() {
39-
udpAddr, err := net.ResolveUDPAddr("udp", destination.String())
40-
if err != nil {
41-
return err
42-
}
43-
return common.Error(w.UDPConn.WriteTo(buffer.Bytes(), udpAddr))
44-
}
45-
return common.Error(w.UDPConn.WriteToUDP(buffer.Bytes(), destination.UDPAddr()))
38+
return common.Error(w.UDPConn.WriteToUDPAddrPort(buffer.Bytes(), destination.AddrPort()))
4639
}
4740

4841
func (w *ExtendedUDPConn) Upstream() any {

0 commit comments

Comments
 (0)