Compare commits

..

107 Commits

Author SHA1 Message Date
世界
b03d912eb5
documentation: Bump version 2025-06-04 23:37:40 +08:00
世界
bf0611fa0b
Fix missing home for derp service 2025-06-04 23:37:14 +08:00
Zero Clover
92c6119109
documentation: Fix services 2025-06-04 23:37:14 +08:00
世界
f02de6ec00
Fix dns.client_subnet ignored 2025-06-04 23:37:14 +08:00
世界
1499dac0e1
documentation: Minor fixes 2025-06-04 23:37:13 +08:00
世界
cccd9622cc
Fix tailscale forward 2025-06-04 23:37:13 +08:00
世界
eb9e6beade
Minor fixes 2025-06-04 23:37:13 +08:00
世界
183c09a53b
Add SSM API service 2025-06-04 23:37:13 +08:00
世界
c09b96aedb
Add resolved service and DNS server 2025-06-04 23:37:12 +08:00
世界
4a162455c7
Add DERP service 2025-06-04 23:37:12 +08:00
世界
c4889e76ff
Add service component type 2025-06-04 23:37:12 +08:00
世界
03fba739e4
Fix tproxy tcp control 2025-06-04 23:37:12 +08:00
愚者
338bc709b4
release: Fix build tags for android
Signed-off-by: 愚者 <11926619+FansChou@users.noreply.github.com>
2025-06-04 23:37:12 +08:00
世界
936220aa64
prevent creation of bind and mark controls on unsupported platforms 2025-06-04 23:37:11 +08:00
PuerNya
9336bf802f
documentation: Fix description of reject DNS action behavior 2025-06-04 23:37:11 +08:00
Restia-Ashbell
4ecea1ae2b
Fix TLS record fragment 2025-06-04 23:37:11 +08:00
世界
20e462b577
Add missing accept_routes option for Tailscale 2025-06-04 23:37:11 +08:00
世界
46e97a5c7c
Add TLS record fragment support 2025-06-04 23:37:11 +08:00
世界
91a229b26e
release: Update Go to 1.24.3 2025-06-04 23:37:10 +08:00
世界
68cdf2246f
Fix set edns0 client subnet 2025-06-04 23:37:10 +08:00
世界
168548c8cc
Update minor dependencies 2025-06-04 23:37:10 +08:00
世界
14619fb5bd
Update certmagic and providers 2025-06-04 23:37:10 +08:00
世界
7760aa3e6c
Update protobuf and grpc 2025-06-04 23:37:09 +08:00
世界
af73e784f1
Add control options for listeners 2025-06-04 23:37:09 +08:00
世界
c44e127064
Update quic-go to v0.52.0 2025-06-04 23:37:08 +08:00
世界
7345152a8a
Update utls to v1.7.2 2025-06-04 23:37:08 +08:00
世界
979d8054a8
Handle EDNS version downgrade 2025-06-04 23:37:08 +08:00
世界
86841c36b5
documentation: Fix anytls padding scheme description 2025-06-04 23:37:07 +08:00
安容
d637de0043
Report invalid DNS address early 2025-06-04 23:37:07 +08:00
世界
1a9138ae4a
Fix wireguard listen_port 2025-06-04 23:37:07 +08:00
世界
67178bbd82
clash-api: Add more meta api 2025-06-04 23:37:06 +08:00
世界
c4b97029d2
Fix DNS lookup 2025-06-04 23:37:06 +08:00
世界
f7edfc5867
Fix fetch ECH configs 2025-06-04 23:37:06 +08:00
reletor
a6ca8e64ea
documentation: Minor fixes 2025-06-04 23:37:05 +08:00
caelansar
34b45bcd6b
Fix callback deletion in UDP transport 2025-06-04 23:37:05 +08:00
世界
1aa3791ced
documentation: Try to make the play review happy 2025-06-04 23:37:05 +08:00
世界
3313578a09
Fix missing handling of legacy domain_strategy options 2025-06-04 23:37:04 +08:00
世界
a5b9cd9696
Improve local DNS server 2025-06-04 23:37:04 +08:00
anytls
c1167df04d
Update anytls
Co-authored-by: anytls <anytls>
2025-06-04 23:37:04 +08:00
世界
c60adfd4b8
Fix DNS dialer 2025-06-04 23:37:03 +08:00
世界
f9d4b00e78
release: Skip override version for iOS 2025-06-04 23:37:03 +08:00
iikira
d262c8bff9
Fix UDP DNS server crash
Signed-off-by: iikira <i2@mail.iikira.com>
2025-06-04 23:37:03 +08:00
ReleTor
0b7ee68187
Fix fetch ECH configs 2025-06-04 23:37:02 +08:00
世界
84a3a364d1
Allow direct outbounds without domain_resolver 2025-06-04 23:37:02 +08:00
世界
186ecfcc61
Fix Tailscale dialer 2025-06-04 23:37:02 +08:00
dyhkwong
f92c3e9b54
Fix DNS over QUIC stream close 2025-06-04 23:37:02 +08:00
anytls
45f240f562
Update anytls
Co-authored-by: anytls <anytls>
2025-06-04 23:37:01 +08:00
Rambling2076
7b2dad1073
Fix missing with_tailscale in Dockerfile
Signed-off-by: Rambling2076 <Rambling2076@proton.me>
2025-06-04 23:37:01 +08:00
世界
955edac785
Fail when default DNS server not found 2025-06-04 23:37:01 +08:00
世界
21dc56b47e
Update gVisor to 20250319.0 2025-06-04 23:37:01 +08:00
世界
1d7a20a879
Explicitly reject detour to empty direct outbounds 2025-06-04 23:37:00 +08:00
世界
710b26c95d
Add netns support 2025-06-04 23:37:00 +08:00
世界
99154e8221
Add wildcard name support for predefined records 2025-06-04 23:36:59 +08:00
世界
0f0bdddc09
Remove map usage in options 2025-06-04 23:36:59 +08:00
世界
b2003ff63c
Fix unhandled DNS loop 2025-06-04 23:36:59 +08:00
世界
666fcf3342
Add wildcard-sni support for shadow-tls inbound 2025-06-04 23:36:59 +08:00
k9982874
b3257446a9
Add ntp protocol sniffing 2025-06-04 23:36:58 +08:00
世界
6f0917af2c
option: Fix marshal legacy DNS options 2025-06-04 23:36:58 +08:00
世界
c997cd5995
Make domain_resolver optional when only one DNS server is configured 2025-06-04 23:36:58 +08:00
世界
51e1ea0ff2
Fix DNS lookup context pollution 2025-06-04 23:36:57 +08:00
世界
d2aa704bd6
Fix http3 DNS server connecting to wrong address 2025-06-04 23:36:57 +08:00
Restia-Ashbell
d24c2ff9ef
documentation: Fix typo 2025-06-04 23:36:57 +08:00
anytls
30bdf826cb
Update sing-anytls
Co-authored-by: anytls <anytls>
2025-06-04 23:36:57 +08:00
k9982874
13f283554f
Fix hosts DNS server 2025-06-04 23:36:56 +08:00
世界
22b96aa95e
Fix UDP DNS server crash 2025-06-04 23:36:56 +08:00
世界
9cd361400c
documentation: Fix missing ip_accept_any DNS rule option 2025-06-04 23:36:55 +08:00
世界
9b34001232
Fix anytls dialer usage 2025-06-04 23:36:55 +08:00
世界
38f83819df
Move predefined DNS server to rule action 2025-06-04 23:36:55 +08:00
世界
a79799bb08
Fix domain resolver on direct outbound 2025-06-04 23:36:54 +08:00
Zephyruso
5f037b01f4
Fix missing AnyTLS display name 2025-06-04 23:36:54 +08:00
anytls
09ca2d0d91
Update sing-anytls
Co-authored-by: anytls <anytls>
2025-06-04 23:36:54 +08:00
Estel
61cbe8ed5d
documentation: Fix typo
Signed-off-by: Estel <callmebedrockdigger@gmail.com>
2025-06-04 23:36:54 +08:00
TargetLocked
9088fb312f
Fix parsing legacy DNS options 2025-06-04 23:36:53 +08:00
世界
0c29d16733
Fix DNS fallback 2025-06-04 23:36:53 +08:00
世界
75e15c7ac6
documentation: Fix missing hosts DNS server 2025-06-04 23:36:52 +08:00
anytls
e63154f746
Add MinIdleSession option to AnyTLS outbound
Co-authored-by: anytls <anytls>
2025-06-04 23:36:52 +08:00
ReleTor
b28721f08b
documentation: Minor fixes 2025-06-04 23:36:52 +08:00
libtry486
2eaa348762
documentation: Fix typo
fix typo

Signed-off-by: libtry486 <89328481+libtry486@users.noreply.github.com>
2025-06-04 23:36:52 +08:00
Alireza Ahmadi
76d94b0674
Fix Outbound deadlock 2025-06-04 23:36:52 +08:00
世界
3bbfff6e8b
documentation: Fix AnyTLS doc 2025-06-04 23:36:51 +08:00
anytls
6d7d1e9ada
Add AnyTLS protocol 2025-06-04 23:36:50 +08:00
世界
f709b1a265
Migrate to stdlib ECH support 2025-06-04 23:36:50 +08:00
世界
d35558a771
Add fallback local DNS server for iOS 2025-06-04 23:36:50 +08:00
世界
f1fc578414
Get darwin local DNS server from libresolv 2025-06-04 23:36:49 +08:00
世界
c498c5e48f
Improve resolve action 2025-06-04 23:36:49 +08:00
世界
e3aaa27d82
Add back port hopping to hysteria 1 2025-06-04 23:36:48 +08:00
xchacha20-poly1305
d6949a4ea4
Remove single quotes of raw Moziila certs 2025-06-04 23:36:48 +08:00
世界
19febe44cb
Add Tailscale endpoint 2025-06-04 23:36:47 +08:00
世界
f7adac3847
Build legacy binaries with latest Go 2025-06-04 23:36:47 +08:00
世界
1c63ddc69e
documentation: Remove outdated icons 2025-06-04 23:36:47 +08:00
世界
c37d2627ee
documentation: Certificate store 2025-06-04 23:36:46 +08:00
世界
e447da0f41
documentation: TLS fragment 2025-06-04 23:36:46 +08:00
世界
ed35d7a44f
documentation: Outbound domain resolver 2025-06-04 23:36:45 +08:00
世界
55254639d9
documentation: Refactor DNS 2025-06-04 23:36:45 +08:00
世界
f80e4ff91a
Add certificate store 2025-06-04 23:36:45 +08:00
世界
207a40fbb5
Add TLS fragment support 2025-06-04 23:36:45 +08:00
世界
2645466e48
refactor: Outbound domain resolver 2025-06-04 23:36:44 +08:00
世界
8ab0427199
refactor: DNS 2025-06-04 23:36:44 +08:00
世界
255068fd40
Bump version 2025-06-04 23:32:10 +08:00
世界
098a00b025
Fix v2ray websocket transport 2025-06-04 23:23:36 +08:00
世界
dba0b5276b
Bump version 2025-06-04 20:06:38 +08:00
Sentsuki
78ae935468
documentation: Fix typo
Signed-off-by: Sentsuki <52487960+Sentsuki@users.noreply.github.com>
2025-06-04 20:06:38 +08:00
Mahdi
3ea5f76470
Fix nil logger at v2rayhttp server 2025-06-04 20:06:20 +08:00
世界
b4d294c05e
Fix TUIC read buffer 2025-06-04 20:03:51 +08:00
世界
83cf5f5c6a
Fix ws closed error message 2025-05-27 14:30:07 +08:00
世界
e7b3a8eebe
Fix vmess read request 2025-05-27 14:11:05 +08:00
世界
ee3a42a67e
Fix none method read buffer 2025-05-27 14:03:48 +08:00
23 changed files with 188 additions and 53 deletions

@ -1 +1 @@
Subproject commit cec05bf6935eca219a722883212ae8880d2e863e
Subproject commit 320170a1077ea5c93872b3e055b96b8836615ef0

58
common/sniff/ntp.go Normal file
View File

@ -0,0 +1,58 @@
package sniff
import (
"context"
"encoding/binary"
"os"
"github.com/sagernet/sing-box/adapter"
C "github.com/sagernet/sing-box/constant"
)
func NTP(ctx context.Context, metadata *adapter.InboundContext, packet []byte) error {
// NTP packets must be at least 48 bytes long (standard NTP header size).
pLen := len(packet)
if pLen < 48 {
return os.ErrInvalid
}
// Check the LI (Leap Indicator) and Version Number (VN) in the first byte.
// We'll primarily focus on ensuring the version is valid for NTP.
// Many NTP versions are used, but let's check for generally accepted ones (3 & 4 for IPv4, plus potential extensions/customizations)
firstByte := packet[0]
li := (firstByte >> 6) & 0x03 // Extract LI
vn := (firstByte >> 3) & 0x07 // Extract VN
mode := firstByte & 0x07 // Extract Mode
// Leap Indicator should be a valid value (0-3).
if li > 3 {
return os.ErrInvalid
}
// Version Check (common NTP versions are 3 and 4)
if vn != 3 && vn != 4 {
return os.ErrInvalid
}
// Check the Mode field for a client request (Mode 3). This validates it *is* a request.
if mode != 3 {
return os.ErrInvalid
}
// Check Root Delay and Root Dispersion. While not strictly *required* for a request,
// we can check if they appear to be reasonable values (not excessively large).
rootDelay := binary.BigEndian.Uint32(packet[4:8])
rootDispersion := binary.BigEndian.Uint32(packet[8:12])
// Check for unreasonably large root delay and dispersion. NTP RFC specifies max values of approximately 16 seconds.
// Convert to milliseconds for easy comparison. Each unit is 1/2^16 seconds.
if float64(rootDelay)/65536.0 > 16.0 {
return os.ErrInvalid
}
if float64(rootDispersion)/65536.0 > 16.0 {
return os.ErrInvalid
}
metadata.Protocol = C.ProtocolNTP
return nil
}

33
common/sniff/ntp_test.go Normal file
View File

@ -0,0 +1,33 @@
package sniff_test
import (
"context"
"encoding/hex"
"os"
"testing"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/sniff"
C "github.com/sagernet/sing-box/constant"
"github.com/stretchr/testify/require"
)
func TestSniffNTP(t *testing.T) {
t.Parallel()
packet, err := hex.DecodeString("1b0006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
var metadata adapter.InboundContext
err = sniff.NTP(context.Background(), &metadata, packet)
require.NoError(t, err)
require.Equal(t, metadata.Protocol, C.ProtocolNTP)
}
func TestSniffNTPFailed(t *testing.T) {
t.Parallel()
packet, err := hex.DecodeString("400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
require.NoError(t, err)
var metadata adapter.InboundContext
err = sniff.NTP(context.Background(), &metadata, packet)
require.ErrorIs(t, err, os.ErrInvalid)
}

View File

@ -34,6 +34,7 @@ type Client struct {
disableCache bool
disableExpire bool
independentCache bool
clientSubnet netip.Prefix
rdrc adapter.RDRCStore
initRDRCFunc func() adapter.RDRCStore
logger logger.ContextLogger
@ -47,6 +48,7 @@ type ClientOptions struct {
DisableExpire bool
IndependentCache bool
CacheCapacity uint32
ClientSubnet netip.Prefix
RDRC func() adapter.RDRCStore
Logger logger.ContextLogger
}
@ -57,6 +59,7 @@ func NewClient(options ClientOptions) *Client {
disableCache: options.DisableCache,
disableExpire: options.DisableExpire,
independentCache: options.IndependentCache,
clientSubnet: options.ClientSubnet,
initRDRCFunc: options.RDRC,
logger: options.Logger,
}
@ -104,8 +107,12 @@ func (c *Client) Exchange(ctx context.Context, transport adapter.DNSTransport, m
return &responseMessage, nil
}
question := message.Question[0]
if options.ClientSubnet.IsValid() {
message = SetClientSubnet(message, options.ClientSubnet)
clientSubnet := options.ClientSubnet
if !clientSubnet.IsValid() {
clientSubnet = c.clientSubnet
}
if clientSubnet.IsValid() {
message = SetClientSubnet(message, clientSubnet)
}
isSimpleRequest := len(message.Question) == 1 &&
len(message.Ns) == 0 &&

View File

@ -55,6 +55,7 @@ func NewRouter(ctx context.Context, logFactory log.Factory, options option.DNSOp
DisableExpire: options.DNSClientOptions.DisableExpire,
IndependentCache: options.DNSClientOptions.IndependentCache,
CacheCapacity: options.DNSClientOptions.CacheCapacity,
ClientSubnet: options.DNSClientOptions.ClientSubnet.Build(netip.Prefix{}),
RDRC: func() adapter.RDRCStore {
cacheFile := service.FromContext[adapter.CacheFile](ctx)
if cacheFile == nil {

View File

@ -2,10 +2,24 @@
icon: material/alert-decagram
---
#### 1.12.0-beta.19
#### 1.12.0-beta.21
* Fix missing `home` option for DERP service **1**
* Fixes and improvements
**1**:
You can now choose what the DERP home page shows, just like with derper's `-home` flag.
See [DERP](/configuration/service/derp/#home).
### 1.11.13
* 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)._
#### 1.12.0-beta.17
* Update quic-go to v0.52.0

View File

@ -1,7 +1,11 @@
---
icon: material/new-box
icon: material/alert-decagram
---
!!! quote "Changes in sing-box 1.12.0"
:material-decagram: [servers](#servers)
!!! quote "Changes in sing-box 1.11.0"
:material-plus: [cache_capacity](#cache_capacity)

View File

@ -1,7 +1,11 @@
---
icon: material/new-box
icon: material/alert-decagram
---
!!! quote "sing-box 1.12.0 中的更改"
:material-decagram: [servers](#servers)
!!! quote "sing-box 1.11.0 中的更改"
:material-plus: [cache_capacity](#cache_capacity)

View File

@ -398,11 +398,11 @@ UDP NAT 过期时间。
TCP/IP 栈。
| 栈 | 描述 |
|--------|------------------------------------------------------------------|
| system | 基于系统网络栈执行 L3 到 L4 转换 |
| gVisor | 基于 [gVisor](https://github.com/google/gvisor) 虚拟网络栈执行 L3 到 L4 转换 |
| mixed | 混合 `system` TCP 栈与 `gvisor` UDP 栈 |
| 栈 | 描述 |
|----------|-------------------------------------------------------------------------------------------------------|
| `system` | 基于系统网络栈执行 L3 到 L4 转换 |
| `gvisor` | 基于 [gVisor](https://github.com/google/gvisor) 虚拟网络栈执行 L3 到 L4 转换 |
| `mixed` | 混合 `system` TCP 栈与 `gvisor` UDP 栈 |
默认使用 `mixed` 栈如果 gVisor 构建标记已启用,否则默认使用 `system` 栈。

View File

@ -22,6 +22,7 @@ If enabled in the inbound, the protocol and domain name (if present) of by the c
| UDP | `dtls` | / | / |
| TCP | `ssh` | / | SSH Client Name |
| TCP | `rdp` | / | / |
| UDP | `ntp` | / | / |
| QUIC Client | Type |
|:------------------------:|:----------:|

View File

@ -22,6 +22,7 @@
| UDP | `dtls` | / | / |
| TCP | `ssh` | / | SSH 客户端名称 |
| TCP | `rdp` | / | / |
| UDP | `ntp` | / | / |
| QUIC 客户端 | 类型 |
|:------------------------:|:----------:|

View File

@ -20,6 +20,7 @@ DERP service is a Tailscale DERP server, similar to [derper](https://pkg.go.dev/
"config_path": "",
"verify_client_endpoint": [],
"verify_client_url": [],
"home": "",
"mesh_with": [],
"mesh_psk": "",
"mesh_psk_file": "",
@ -69,6 +70,10 @@ Setting Array value to a string `__URL__` is equivalent to configuring:
{ "url": __URL__ }
```
#### home
What to serve at the root path. It may be left empty (the default, for a default homepage), `blank` for a blank page, or a URL to redirect to
#### mesh_with
Mesh with other DERP servers.

View File

@ -10,7 +10,7 @@ icon: material/new-box
```json
{
"endpoints": [
"services": [
{
"type": "",
"tag": ""
@ -25,6 +25,7 @@ icon: material/new-box
|------------|------------------------|
| `derp` | [DERP](./derp) |
| `resolved` | [Resolved](./resolved) |
| `ssm-api` | [SSM API](./ssm-api) |
#### tag

6
go.mod
View File

@ -30,12 +30,12 @@ require (
github.com/sagernet/quic-go v0.52.0-beta.1
github.com/sagernet/sing v0.6.11-0.20250521033217-30d675ea099b
github.com/sagernet/sing-mux v0.3.2
github.com/sagernet/sing-quic v0.5.0-beta.1
github.com/sagernet/sing-shadowsocks v0.2.7
github.com/sagernet/sing-quic v0.5.0-beta.2
github.com/sagernet/sing-shadowsocks v0.2.8
github.com/sagernet/sing-shadowsocks2 v0.2.1
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11
github.com/sagernet/sing-tun v0.6.6-0.20250428031943-0686f8c4f210
github.com/sagernet/sing-vmess v0.2.2-0.20250503051933-9b4cf17393f8
github.com/sagernet/sing-vmess v0.2.4-0.20250527060135-661c827800bc
github.com/sagernet/smux v1.5.34-mod.2
github.com/sagernet/tailscale v1.80.3-mod.5
github.com/sagernet/wireguard-go v0.0.1-beta.7

12
go.sum
View File

@ -172,18 +172,18 @@ github.com/sagernet/sing v0.6.11-0.20250521033217-30d675ea099b h1:ZjTCYPb5f7aHdf
github.com/sagernet/sing v0.6.11-0.20250521033217-30d675ea099b/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing-mux v0.3.2 h1:meZVFiiStvHThb/trcpAkCrmtJOuItG5Dzl1RRP5/NE=
github.com/sagernet/sing-mux v0.3.2/go.mod h1:pht8iFY4c9Xltj7rhVd208npkNaeCxzyXCgulDPLUDA=
github.com/sagernet/sing-quic v0.5.0-beta.1 h1:nC0i/s8LhlZB8ev6laZCXF/uiwAE4kRdT4PcDdE4rI4=
github.com/sagernet/sing-quic v0.5.0-beta.1/go.mod h1:SAv/qdeDN+75msGG5U5ZIwG+3Ua50jVIKNrRSY8pkx0=
github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8=
github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE=
github.com/sagernet/sing-quic v0.5.0-beta.2 h1:j7KAbBuGmsKwSxVAQL5soJ+wDqxim4/llK2kxB0hSKk=
github.com/sagernet/sing-quic v0.5.0-beta.2/go.mod h1:SAv/qdeDN+75msGG5U5ZIwG+3Ua50jVIKNrRSY8pkx0=
github.com/sagernet/sing-shadowsocks v0.2.8 h1:PURj5PRoAkqeHh2ZW205RWzN9E9RtKCVCzByXruQWfE=
github.com/sagernet/sing-shadowsocks v0.2.8/go.mod h1:lo7TWEMDcN5/h5B8S0ew+r78ZODn6SwVaFhvB6H+PTI=
github.com/sagernet/sing-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnqqs2gQ2/Qioo=
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 h1:tK+75l64tm9WvEFrYRE1t0YxoFdWQqw/h7Uhzj0vJ+w=
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
github.com/sagernet/sing-tun v0.6.6-0.20250428031943-0686f8c4f210 h1:6H4BZaTqKI3YcDMyTV3E576LuJM4S4wY99xoq2T1ECw=
github.com/sagernet/sing-tun v0.6.6-0.20250428031943-0686f8c4f210/go.mod h1:fisFCbC4Vfb6HqQNcwPJi2CDK2bf0Xapyz3j3t4cnHE=
github.com/sagernet/sing-vmess v0.2.2-0.20250503051933-9b4cf17393f8 h1:zW+zAOCxUIqBCgnZiPovt1uQ3S+zBS+w0NGp+1zITGA=
github.com/sagernet/sing-vmess v0.2.2-0.20250503051933-9b4cf17393f8/go.mod h1:IL8Rr+EGwuqijszZkNrEFTQDKhilEpkqFqOlvdpS6/w=
github.com/sagernet/sing-vmess v0.2.4-0.20250527060135-661c827800bc h1:kd3olNfnf/1EAAHDQm0flN9eihyjpeQDKdGONlLtXfc=
github.com/sagernet/sing-vmess v0.2.4-0.20250527060135-661c827800bc/go.mod h1:IL8Rr+EGwuqijszZkNrEFTQDKhilEpkqFqOlvdpS6/w=
github.com/sagernet/smux v1.5.34-mod.2 h1:gkmBjIjlJ2zQKpLigOkFur5kBKdV6bNRoFu2WkltRQ4=
github.com/sagernet/smux v1.5.34-mod.2/go.mod h1:0KW0+R+ycvA2INW4gbsd7BNyg+HEfLIAxa5N02/28Zc=
github.com/sagernet/tailscale v1.80.3-mod.5 h1:7V7z+p2C//TGtff20pPnDCt3qP6uFyY62peJoKF9z/A=

View File

@ -36,6 +36,7 @@ type DERPServiceOptions struct {
ConfigPath string `json:"config_path,omitempty"`
VerifyClientEndpoint badoption.Listable[string] `json:"verify_client_endpoint,omitempty"`
VerifyClientURL badoption.Listable[*DERPVerifyClientURLOptions] `json:"verify_client_url,omitempty"`
Home string `json:"home,omitempty"`
MeshWith badoption.Listable[*DERPMeshOptions] `json:"mesh_with,omitempty"`
MeshPSK string `json:"mesh_psk,omitempty"`
MeshPSKFile string `json:"mesh_psk_file,omitempty"`

View File

@ -564,6 +564,7 @@ func (r *Router) actionSniff(
sniff.UTP,
sniff.UDPTracker,
sniff.DTLSRecord,
sniff.NTP,
}
}
for {

View File

@ -379,6 +379,8 @@ func (r *RuleActionSniff) build() error {
r.StreamSniffers = append(r.StreamSniffers, sniff.SSH)
case C.ProtocolRDP:
r.StreamSniffers = append(r.StreamSniffers, sniff.RDP)
case C.ProtocolNTP:
r.PacketSniffers = append(r.PacketSniffers, sniff.NTP)
default:
return E.New("unknown sniffer: ", name)
}

View File

@ -124,6 +124,7 @@ func NewService(ctx context.Context, logger log.ContextLogger, tag string, optio
configPath: configPath,
verifyClientEndpoint: options.VerifyClientEndpoint,
verifyClientURL: options.VerifyClientURL,
home: options.Home,
meshKey: options.MeshPSK,
meshKeyPath: options.MeshPSKFile,
meshWith: options.MeshWith,

View File

@ -47,6 +47,7 @@ func NewServer(ctx context.Context, logger logger.ContextLogger, options option.
server := &Server{
ctx: ctx,
tlsConfig: tlsConfig,
logger: logger,
handler: handler,
h2Server: &http2.Server{
IdleTimeout: time.Duration(options.IdleTimeout),

View File

@ -3,6 +3,7 @@ package v2raywebsocket
import (
"context"
"encoding/base64"
"errors"
"io"
"net"
"os"
@ -67,9 +68,10 @@ func (c *WebsocketConn) Read(b []byte) (n int, err error) {
return
}
if !E.IsMulti(err, io.EOF, wsutil.ErrNoFrameAdvance) {
err = wrapWsError(err)
return
}
header, err = c.reader.NextFrame()
header, err = wrapWsError0(c.reader.NextFrame())
if err != nil {
return
}
@ -78,14 +80,14 @@ func (c *WebsocketConn) Read(b []byte) (n int, err error) {
err = wsutil.ErrFrameTooLarge
return
}
err = c.controlHandler(header, c.reader)
err = wrapWsError(c.controlHandler(header, c.reader))
if err != nil {
return
}
continue
}
if header.OpCode&ws.OpBinary == 0 {
err = c.reader.Discard()
err = wrapWsError(c.reader.Discard())
if err != nil {
return
}
@ -95,7 +97,7 @@ func (c *WebsocketConn) Read(b []byte) (n int, err error) {
}
func (c *WebsocketConn) Write(p []byte) (n int, err error) {
err = wsutil.WriteMessage(c.Conn, c.state, ws.OpBinary, p)
err = wrapWsError(wsutil.WriteMessage(c.Conn, c.state, ws.OpBinary, p))
if err != nil {
return
}
@ -146,7 +148,7 @@ func (c *EarlyWebsocketConn) Read(b []byte) (n int, err error) {
return 0, c.err
}
}
return c.conn.Read(b)
return wrapWsError0(c.conn.Read(b))
}
func (c *EarlyWebsocketConn) writeRequest(content []byte) error {
@ -191,7 +193,7 @@ func (c *EarlyWebsocketConn) writeRequest(content []byte) error {
func (c *EarlyWebsocketConn) Write(b []byte) (n int, err error) {
if c.conn != nil {
return c.conn.Write(b)
return wrapWsError0(c.conn.Write(b))
}
c.access.Lock()
defer c.access.Unlock()
@ -199,7 +201,7 @@ func (c *EarlyWebsocketConn) Write(b []byte) (n int, err error) {
return 0, c.err
}
if c.conn != nil {
return c.conn.Write(b)
return wrapWsError0(c.conn.Write(b))
}
err = c.writeRequest(b)
c.err = err
@ -212,12 +214,12 @@ func (c *EarlyWebsocketConn) Write(b []byte) (n int, err error) {
func (c *EarlyWebsocketConn) WriteBuffer(buffer *buf.Buffer) error {
if c.conn != nil {
return c.conn.WriteBuffer(buffer)
return wrapWsError(c.conn.WriteBuffer(buffer))
}
c.access.Lock()
defer c.access.Unlock()
if c.conn != nil {
return c.conn.WriteBuffer(buffer)
return wrapWsError(c.conn.WriteBuffer(buffer))
}
if c.err != nil {
return c.err
@ -272,3 +274,23 @@ func (c *EarlyWebsocketConn) Upstream() any {
func (c *EarlyWebsocketConn) LazyHeadroom() bool {
return c.conn == nil
}
func wrapWsError(err error) error {
if err == nil {
return nil
}
var closedErr wsutil.ClosedError
if errors.As(err, &closedErr) {
if closedErr.Code == ws.StatusNormalClosure {
err = io.EOF
}
}
return err
}
func wrapWsError0[T any](value T, err error) (T, error) {
if err == nil {
return value, nil
}
return value, wrapWsError(err)
}

View File

@ -1,22 +0,0 @@
package v2raywebsocket
import (
"net"
"time"
)
type deadConn struct {
net.Conn
}
func (c *deadConn) SetDeadline(t time.Time) error {
return nil
}
func (c *deadConn) SetReadDeadline(t time.Time) error {
return nil
}
func (c *deadConn) SetWriteDeadline(t time.Time) error {
return nil
}

View File

@ -66,7 +66,7 @@ func (w *Writer) WriteBuffer(buffer *buf.Buffer) error {
ws.Cipher(data, *(*[4]byte)(header[1+payloadBitLength:]), 0)
}
return w.writer.WriteBuffer(buffer)
return wrapWsError(w.writer.WriteBuffer(buffer))
}
func (w *Writer) FrontHeadroom() int {