fix: socks5 serialize error #376

This commit is contained in:
Skyxim 2023-02-18 17:18:58 +08:00
parent a61685ce01
commit cd7d9fc4f5
2 changed files with 3 additions and 5 deletions

View File

@ -165,7 +165,7 @@ func (m *Metadata) SourceDetail() string {
func (m *Metadata) AddrType() int { func (m *Metadata) AddrType() int {
switch true { switch true {
case m.Host != "" || m.SniffHost != "" || !m.DstIP.IsValid(): case m.Host != "" || !m.DstIP.IsValid():
return socks5.AtypDomainName return socks5.AtypDomainName
case m.DstIP.Is4(): case m.DstIP.Is4():
return socks5.AtypIPv4 return socks5.AtypIPv4

View File

@ -9,7 +9,6 @@ import (
_ "github.com/Dreamacro/clash/component/geodata/standard" _ "github.com/Dreamacro/clash/component/geodata/standard"
C "github.com/Dreamacro/clash/constant" C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/log"
"github.com/Dreamacro/clash/transport/socks5"
) )
type GEOSITE struct { type GEOSITE struct {
@ -25,11 +24,10 @@ func (gs *GEOSITE) RuleType() C.RuleType {
} }
func (gs *GEOSITE) Match(metadata *C.Metadata) (bool, string) { func (gs *GEOSITE) Match(metadata *C.Metadata) (bool, string) {
if metadata.AddrType() != socks5.AtypDomainName { domain := metadata.RuleHost()
if len(domain) == 0 {
return false, "" return false, ""
} }
domain := metadata.RuleHost()
return gs.matcher.ApplyDomain(domain), gs.adapter return gs.matcher.ApplyDomain(domain), gs.adapter
} }