Compare commits

..
Author SHA1 Message Date
世界 470173189d documentation: Bump version 2025-05-23 11:44:36 +08:00
世界 c24ae9cf34 Update quic-go to v0.52.0 2025-05-23 11:41:48 +08:00
世界 f27cf36174 Add SSM API service 2025-05-23 11:41:37 +08:00
世界 dfb9786bd0 Add resolved service and DNS server 2025-05-23 11:41:34 +08:00
世界 fe84746aff Add DERP service 2025-05-23 11:03:14 +08:00
世界 f236effb5f Add service component type 2025-05-23 11:03:14 +08:00
世界 60daaeb134 Fix tproxy tcp control 2025-05-23 11:03:14 +08:00
愚者and世界 7ba271267d release: Fix build tags for android
Signed-off-by: 愚者 <11926619+FansChou@users.noreply.github.com>
2025-05-23 11:03:13 +08:00
世界 aa73b166ca prevent creation of bind and mark controls on unsupported platforms 2025-05-23 11:03:13 +08:00
PuerNyaand世界 d136c489ad documentation: Fix description of reject DNS action behavior 2025-05-23 11:03:13 +08:00
Restia-Ashbelland世界 5c4dfabc2c Fix TLS record fragment 2025-05-23 11:03:12 +08:00
世界 836d8c0edc Add missing accept_routes option for Tailscale 2025-05-23 11:03:12 +08:00
世界 b45f7e62d4 Add TLS record fragment support 2025-05-23 11:03:12 +08:00
世界 5f1b210e49 release: Update Go to 1.24.3 2025-05-23 11:03:11 +08:00
世界 c0e64581be Fix set edns0 client subnet 2025-05-23 11:03:11 +08:00
世界 69d16594f8 Update minor dependencies 2025-05-23 11:03:11 +08:00
世界 ee4853b979 Update certmagic and providers 2025-05-23 11:03:11 +08:00
世界 5ec54800bb Update protobuf and grpc 2025-05-23 11:03:10 +08:00
世界 0c24f4cbe7 Add control options for listeners 2025-05-23 11:03:10 +08:00
世界 64c164a1ec Update quic-go to v0.51.0 2025-05-23 11:03:10 +08:00
世界 50736b36ff Update utls to v1.7.2 2025-05-23 11:03:04 +08:00
世界 95f536ae43 Handle EDNS version downgrade 2025-05-23 11:02:58 +08:00
世界 7b2fabc5f7 documentation: Fix anytls padding scheme description 2025-05-23 11:02:58 +08:00
安容and世界 0b236ba700 Report invalid DNS address early 2025-05-23 11:02:58 +08:00
世界 667772e1cd Fix wireguard listen_port 2025-05-23 11:02:58 +08:00
世界 3e6bb5865b clash-api: Add more meta api 2025-05-23 11:02:57 +08:00
世界 7f2e236a02 Fix DNS lookup 2025-05-23 11:02:57 +08:00
世界 0b02dd5ac2 Fix fetch ECH configs 2025-05-23 11:02:57 +08:00
reletorand世界 46efbcdacf documentation: Minor fixes 2025-05-23 11:02:56 +08:00
caelansarand世界 b9d48631e1 Fix callback deletion in UDP transport 2025-05-23 11:02:56 +08:00
世界 45d58c7fe3 documentation: Try to make the play review happy 2025-05-23 11:02:56 +08:00
世界 93f0a149bf Fix missing handling of legacy domain_strategy options 2025-05-23 11:02:55 +08:00
世界 e07b412faf Improve local DNS server 2025-05-23 11:02:55 +08:00
anytls世界anytls <anytls>
8d62f33232 Update anytls
Co-authored-by: anytls <anytls>
2025-05-23 11:02:55 +08:00
世界 184344cbb0 Fix DNS dialer 2025-05-23 11:02:54 +08:00
世界 8947ceea2a release: Skip override version for iOS 2025-05-23 11:02:54 +08:00
iikiraand世界 6be05a739a Fix UDP DNS server crash
Signed-off-by: iikira <i2@mail.iikira.com>
2025-05-23 11:02:54 +08:00
ReleTorand世界 e6cb0003e6 Fix fetch ECH configs 2025-05-23 11:02:53 +08:00
世界 96c6560507 Allow direct outbounds without domain_resolver 2025-05-23 11:02:53 +08:00
世界 f635bf6f76 Fix Tailscale dialer 2025-05-23 11:02:53 +08:00
dyhkwongand世界 29e89ce723 Fix DNS over QUIC stream close 2025-05-23 11:02:52 +08:00
anytls世界anytls <anytls>
ad8bc33032 Update anytls
Co-authored-by: anytls <anytls>
2025-05-23 11:02:52 +08:00
Rambling2076and世界 cc5803f5a8 Fix missing with_tailscale in Dockerfile
Signed-off-by: Rambling2076 <Rambling2076@proton.me>
2025-05-23 11:02:51 +08:00
世界 74955d9a2a Fail when default DNS server not found 2025-05-23 11:02:51 +08:00
世界 a780c49c5d Update gVisor to 20250319.0 2025-05-23 11:02:51 +08:00
世界 02727c2e5e Explicitly reject detour to empty direct outbounds 2025-05-23 11:02:50 +08:00
世界 174a73749e Add netns support 2025-05-23 11:02:50 +08:00
世界 8ccf8cf4a4 Add wildcard name support for predefined records 2025-05-23 11:02:50 +08:00
世界 4b852b45ed Remove map usage in options 2025-05-23 11:02:50 +08:00
世界 b052d5e1cb Fix unhandled DNS loop 2025-05-23 11:02:49 +08:00
世界 0ba818a8ef Add wildcard-sni support for shadow-tls inbound 2025-05-23 11:02:48 +08:00
k9982874and世界 e6bb0aedcc Add ntp protocol sniffing 2025-05-23 11:02:48 +08:00
世界 2e2ab6d83e option: Fix marshal legacy DNS options 2025-05-23 11:02:48 +08:00
世界 b25a5eba99 Make domain_resolver optional when only one DNS server is configured 2025-05-23 11:02:48 +08:00
世界 10b663d54a Fix DNS lookup context pollution 2025-05-23 11:02:47 +08:00
世界 9c5303deeb Fix http3 DNS server connecting to wrong address 2025-05-23 11:02:47 +08:00
Restia-Ashbelland世界 1fa0add096 documentation: Fix typo 2025-05-23 11:02:47 +08:00
anytls世界anytls <anytls>
b5acbd0f08 Update sing-anytls
Co-authored-by: anytls <anytls>
2025-05-23 11:02:46 +08:00
k9982874and世界 ac714721bd Fix hosts DNS server 2025-05-23 11:02:46 +08:00
世界 d872331e90 Fix UDP DNS server crash 2025-05-23 11:02:46 +08:00
世界 20c4781a49 documentation: Fix missing ip_accept_any DNS rule option 2025-05-23 11:02:46 +08:00
世界 87373efbb6 Fix anytls dialer usage 2025-05-23 11:02:45 +08:00
世界 2f34022ded Move predefined DNS server to rule action 2025-05-23 11:02:45 +08:00
世界 cb0df4620b Fix domain resolver on direct outbound 2025-05-23 11:02:45 +08:00
Zephyrusoand世界 5941c9ceb2 Fix missing AnyTLS display name 2025-05-23 11:02:44 +08:00
anytls世界anytls <anytls>
d261c74180 Update sing-anytls
Co-authored-by: anytls <anytls>
2025-05-23 11:02:44 +08:00
Esteland世界 7e9213d72c documentation: Fix typo
Signed-off-by: Estel <callmebedrockdigger@gmail.com>
2025-05-23 11:02:44 +08:00
TargetLockedand世界 8419930534 Fix parsing legacy DNS options 2025-05-23 11:02:43 +08:00
世界 7f2c4999ec Fix DNS fallback 2025-05-23 11:02:43 +08:00
世界 d5771e6029 documentation: Fix missing hosts DNS server 2025-05-23 11:02:43 +08:00
anytls世界anytls <anytls>
5d3f4bad0c Add MinIdleSession option to AnyTLS outbound
Co-authored-by: anytls <anytls>
2025-05-23 11:02:42 +08:00
ReleTorand世界 6e9dcc7b65 documentation: Minor fixes 2025-05-23 11:02:42 +08:00
libtry486and世界 3df2b68490 documentation: Fix typo
fix typo

Signed-off-by: libtry486 <89328481+libtry486@users.noreply.github.com>
2025-05-23 11:02:42 +08:00
Alireza Ahmadiand世界 933f179849 Fix Outbound deadlock 2025-05-23 11:02:41 +08:00
世界 3a91afdd84 documentation: Fix AnyTLS doc 2025-05-23 11:02:41 +08:00
anytlsand世界 09110d512b Add AnyTLS protocol 2025-05-23 11:02:40 +08:00
世界 841b70855f Migrate to stdlib ECH support 2025-05-23 11:02:39 +08:00
世界 5db3f06f6a Add fallback local DNS server for iOS 2025-05-23 11:02:39 +08:00
世界 916a1d436c Get darwin local DNS server from libresolv 2025-05-23 11:02:38 +08:00
世界 9719d958b8 Improve resolve action 2025-05-23 11:02:38 +08:00
世界 ae65faceec Add back port hopping to hysteria 1 2025-05-23 11:02:38 +08:00
xchacha20-poly1305and世界 e0b2802247 Remove single quotes of raw Moziila certs 2025-05-23 11:02:38 +08:00
世界 81c4a1efc8 Add Tailscale endpoint 2025-05-23 11:02:37 +08:00
世界 cc2654d24a Build legacy binaries with latest Go 2025-05-23 11:02:36 +08:00
世界 863671f73c documentation: Remove outdated icons 2025-05-23 11:02:36 +08:00
世界 30e0990e32 documentation: Certificate store 2025-05-23 11:02:36 +08:00
世界 286f007b5d documentation: TLS fragment 2025-05-23 11:02:35 +08:00
世界 c1dbb3f3c9 documentation: Outbound domain resolver 2025-05-23 11:02:35 +08:00
世界 5b885b44b1 documentation: Refactor DNS 2025-05-23 11:02:35 +08:00
世界 d1b146f91e Add certificate store 2025-05-23 11:02:35 +08:00
世界 fb2ff27861 Add TLS fragment support 2025-05-23 11:02:23 +08:00
世界 667dc79d2a refactor: Outbound domain resolver 2025-05-23 11:00:16 +08:00
世界 c998c7276d refactor: DNS 2025-05-23 11:00:03 +08:00
18 changed files with 132 additions and 49 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ jobs:
- name: Set build tags
run: |
set -xeuo pipefail
TAGS='with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale'
TAGS='with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api'
echo "BUILD_TAGS=${TAGS}" >> "${GITHUB_ENV}"
- name: Build
run: |
+3 -2
View File
@@ -1,10 +1,11 @@
NAME = sing-box
COMMIT = $(shell git rev-parse --short HEAD)
TAGS ?= with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale
TAGS ?= with_gvisor,with_dhcp,with_wireguard,with_clash_api,with_quic,with_utls,with_tailscale
TAGS_TEST ?= with_gvisor,with_quic,with_wireguard,with_grpc,with_utls
GOHOSTOS = $(shell go env GOHOSTOS)
GOHOSTARCH = $(shell go env GOHOSTARCH)
VERSION=$(shell CGO_ENABLED=0 GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go run github.com/sagernet/sing-box/cmd/internal/read_tag@latest)
VERSION=$(shell CGO_ENABLED=0 GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go run ./cmd/internal/read_tag)
PARAMS = -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=$(VERSION)' -s -w -buildid="
MAIN_PARAMS = $(PARAMS) -tags "$(TAGS)"
+2 -2
View File
@@ -105,7 +105,7 @@ func publishTestflight(ctx context.Context) error {
return err
}
tag := tagVersion.VersionString()
client := createClient(20 * time.Minute)
client := createClient(10 * time.Minute)
log.Info(tag, " list build IDs")
buildIDsResponse, _, err := client.TestFlight.ListBuildIDsForBetaGroup(ctx, groupID, nil)
@@ -145,7 +145,7 @@ func publishTestflight(ctx context.Context) error {
return err
}
build := builds.Data[0]
if common.Contains(buildIDs, build.ID) || time.Since(build.Attributes.UploadedDate.Time) > 30*time.Minute {
if common.Contains(buildIDs, build.ID) || time.Since(build.Attributes.UploadedDate.Time) > 5*time.Minute {
log.Info(string(platform), " ", tag, " waiting for process")
time.Sleep(15 * time.Second)
continue
+3 -1
View File
@@ -7,6 +7,7 @@ import (
"strconv"
"time"
"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/experimental/deprecated"
"github.com/sagernet/sing-box/include"
"github.com/sagernet/sing-box/log"
@@ -67,5 +68,6 @@ func preRun(cmd *cobra.Command, args []string) {
if len(configPaths) == 0 && len(configDirectories) == 0 {
configPaths = append(configPaths, "config.json")
}
globalCtx = include.Context(service.ContextWith(globalCtx, deprecated.NewStderrManager(log.StdLogger())))
globalCtx = service.ContextWith(globalCtx, deprecated.NewStderrManager(log.StdLogger()))
globalCtx = box.Context(globalCtx, include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry(), include.DNSTransportRegistry(), include.ServiceRegistry())
}
+58
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
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)
}
-4
View File
@@ -2,10 +2,6 @@
icon: material/alert-decagram
---
#### 1.12.0-beta.19
* Fixes and improvements
#### 1.12.0-beta.17
* Update quic-go to v0.52.0
+1
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 |
|:------------------------:|:----------:|
+1
View File
@@ -22,6 +22,7 @@
| UDP | `dtls` | / | / |
| TCP | `ssh` | / | SSH 客户端名称 |
| TCP | `rdp` | / | / |
| UDP | `ntp` | / | / |
| QUIC 客户端 | 类型 |
|:------------------------:|:----------:|
+1 -1
View File
@@ -32,7 +32,7 @@ require (
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-shadowsocks2 v0.2.1
github.com/sagernet/sing-shadowsocks2 v0.2.0
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
+6 -2
View File
@@ -165,6 +165,8 @@ github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZN
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
github.com/sagernet/quic-go v0.51.0-beta.5 h1:/mME3sJvQ8k/JKP0oC/9XoWrm0znO7hWXviB5yiipJY=
github.com/sagernet/quic-go v0.51.0-beta.5/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
github.com/sagernet/quic-go v0.52.0-beta.1 h1:hWkojLg64zjV+MJOvJU/kOeWndm3tiEfBLx5foisszs=
github.com/sagernet/quic-go v0.52.0-beta.1/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
github.com/sagernet/sing v0.6.9/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
@@ -172,12 +174,14 @@ 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.4.1-0.20250511050139-d459f561c9c3 h1:1J+s1yyZ8+YAYaClI+az8YuFgV9NGXUUCZnriKmos6w=
github.com/sagernet/sing-quic v0.4.1-0.20250511050139-d459f561c9c3/go.mod h1:Mv7CdSyLepmqoLT8rd88Qn3QMv5AbsgjEm3DvEhDVNE=
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-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnqqs2gQ2/Qioo=
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
github.com/sagernet/sing-shadowsocks2 v0.2.0 h1:wpZNs6wKnR7mh1wV9OHwOyUr21VkS3wKFHi+8XwgADg=
github.com/sagernet/sing-shadowsocks2 v0.2.0/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=
-5
View File
@@ -3,7 +3,6 @@ package include
import (
"context"
"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/adapter/endpoint"
"github.com/sagernet/sing-box/adapter/inbound"
@@ -40,10 +39,6 @@ import (
E "github.com/sagernet/sing/common/exceptions"
)
func Context(ctx context.Context) context.Context {
return box.Context(ctx, InboundRegistry(), OutboundRegistry(), EndpointRegistry(), DNSTransportRegistry(), ServiceRegistry())
}
func InboundRegistry() *inbound.Registry {
registry := inbound.NewRegistry()
-8
View File
@@ -221,14 +221,6 @@ func (t *Endpoint) Start(stage adapter.StartStage) error {
}
ipStack := t.server.ExportNetstack().ExportIPStack()
gErr := ipStack.SetSpoofing(tun.DefaultNIC, true)
if gErr != nil {
return gonet.TranslateNetstackError(gErr)
}
gErr = ipStack.SetPromiscuousMode(tun.DefaultNIC, true)
if gErr != nil {
return gonet.TranslateNetstackError(gErr)
}
ipStack.SetTransportProtocolHandler(tcp.ProtocolNumber, tun.NewTCPForwarder(t.ctx, ipStack, t).HandlePacket)
udpForwarder := tun.NewUDPForwarder(t.ctx, ipStack, t, t.udpTimeout)
ipStack.SetTransportProtocolHandler(udp.ProtocolNumber, udpForwarder.HandlePacket)
+18 -20
View File
@@ -172,6 +172,8 @@ func (r *Router) RoutePacketConnectionEx(ctx context.Context, conn N.PacketConn,
} else {
r.logger.ErrorContext(ctx, err)
}
} else if onClose != nil {
onClose(nil)
}
}
@@ -499,9 +501,7 @@ func (r *Router) actionSniff(
return
}
if inputConn != nil {
if len(action.StreamSniffers) == 0 && len(action.PacketSniffers) > 0 {
return
}
sniffBuffer := buf.NewPacket()
var streamSniffers []sniff.StreamSniffer
if len(action.StreamSniffers) > 0 {
streamSniffers = action.StreamSniffers
@@ -515,7 +515,6 @@ func (r *Router) actionSniff(
sniff.RDP,
}
}
sniffBuffer := buf.NewPacket()
err := sniff.PeekStream(
ctx,
metadata,
@@ -547,25 +546,10 @@ func (r *Router) actionSniff(
sniffBuffer.Release()
}
} else if inputPacketConn != nil {
if len(action.PacketSniffers) == 0 && len(action.StreamSniffers) > 0 {
return
} else if metadata.PacketSniffError != nil && !errors.Is(metadata.PacketSniffError, sniff.ErrNeedMoreData) {
if metadata.PacketSniffError != nil && !errors.Is(metadata.PacketSniffError, sniff.ErrNeedMoreData) {
r.logger.DebugContext(ctx, "packet sniff skipped due to previous error: ", metadata.PacketSniffError)
return
}
var packetSniffers []sniff.PacketSniffer
if len(action.PacketSniffers) > 0 {
packetSniffers = action.PacketSniffers
} else {
packetSniffers = []sniff.PacketSniffer{
sniff.DomainNameQuery,
sniff.QUICClientHello,
sniff.STUNMessage,
sniff.UTP,
sniff.UDPTracker,
sniff.DTLSRecord,
}
}
for {
var (
sniffBuffer = buf.NewPacket()
@@ -605,6 +589,20 @@ func (r *Router) actionSniff(
sniff.QUICClientHello,
)
} else {
var packetSniffers []sniff.PacketSniffer
if len(action.PacketSniffers) > 0 {
packetSniffers = action.PacketSniffers
} else {
packetSniffers = []sniff.PacketSniffer{
sniff.DomainNameQuery,
sniff.QUICClientHello,
sniff.STUNMessage,
sniff.UTP,
sniff.UDPTracker,
sniff.DTLSRecord,
sniff.NTP,
}
}
err = sniff.PeekPacket(
ctx, metadata,
sniffBuffer.Bytes(),
+2
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)
}
+1 -1
View File
@@ -58,7 +58,7 @@ func NewService(ctx context.Context, logger log.ContextLogger, tag string, optio
for i, entry := range options.Servers.Entries() {
inbound, loaded := inboundManager.Get(entry.Value)
if !loaded {
return nil, E.New("parse SSM server[", i, "]: inbound ", entry.Value, " not found")
return nil, E.New("parse SSM server[", i, "]: inbound ", entry.Value, "not found")
}
managedServer, isManaged := inbound.(adapter.ManagedSSMServer)
if !isManaged {
+1 -1
View File
@@ -55,7 +55,7 @@ func (m *UserManager) Add(username string, password string) error {
m.access.Lock()
defer m.access.Unlock()
if _, found := m.usersMap[username]; found {
return E.New("user ", username, " already exists")
return E.New("user", username, "already exists")
}
m.usersMap[username] = password
return m.postUpdate()
+1 -1
View File
@@ -32,7 +32,7 @@ func TestMain(m *testing.M) {
var globalCtx context.Context
func init() {
globalCtx = include.Context(context.Background())
globalCtx = box.Context(context.Background(), include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry(), include.DNSTransportRegistry(), include.ServiceRegistry())
}
func startInstance(t *testing.T, options option.Options) *box.Box {