Fix sniffers clearing reverse mapped domain

This commit is contained in:
世界
2026-11-14 04:42:41 +00:00
parent b33a1a5c6b
commit dfc2204298
3 changed files with 10 additions and 3 deletions
+3 -1
View File
@@ -23,6 +23,8 @@ func HTTPHost(_ context.Context, metadata *adapter.InboundContext, reader io.Rea
}
}
metadata.Protocol = C.ProtocolHTTP
metadata.Domain = M.ParseSocksaddr(request.Host).Fqdn
if domain := M.ParseSocksaddr(request.Host).Fqdn; domain != "" {
metadata.Domain = domain
}
return nil
}
+4 -1
View File
@@ -16,6 +16,7 @@ import (
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing/common/buf"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
"golang.org/x/crypto/hkdf"
)
@@ -309,7 +310,9 @@ find:
metadata.SniffContext = fragments
return E.Cause1(ErrNeedMoreData, err)
}
metadata.Domain = fingerprint.ServerName
if domain := M.ParseSocksaddrHostPort(fingerprint.ServerName, 0).Fqdn; domain != "" {
metadata.Domain = domain
}
for metadata.Client == "" {
if len(frameTypeList) == 1 {
metadata.Client = C.ClientFirefox
+3 -1
View File
@@ -23,7 +23,9 @@ func TLSClientHello(ctx context.Context, metadata *adapter.InboundContext, reade
}).HandshakeContext(ctx)
if clientHello != nil {
metadata.Protocol = C.ProtocolTLS
metadata.Domain = M.ParseSocksaddrHostPort(clientHello.ServerName, 0).Fqdn
if domain := M.ParseSocksaddrHostPort(clientHello.ServerName, 0).Fqdn; domain != "" {
metadata.Domain = domain
}
return nil
}
if errors.Is(err, io.ErrUnexpectedEOF) {