From cd7d9fc4f5efcc6de678a1ba21747adc5b663769 Mon Sep 17 00:00:00 2001
From: Skyxim <me@skyxim.dev>
Date: Sat, 18 Feb 2023 17:18:58 +0800
Subject: [PATCH] fix: socks5 serialize error #376

---
 constant/metadata.go    | 2 +-
 rules/common/geosite.go | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/constant/metadata.go b/constant/metadata.go
index f1c68f68..599a6055 100644
--- a/constant/metadata.go
+++ b/constant/metadata.go
@@ -165,7 +165,7 @@ func (m *Metadata) SourceDetail() string {
 
 func (m *Metadata) AddrType() int {
 	switch true {
-	case m.Host != "" || m.SniffHost != "" || !m.DstIP.IsValid():
+	case m.Host != "" || !m.DstIP.IsValid():
 		return socks5.AtypDomainName
 	case m.DstIP.Is4():
 		return socks5.AtypIPv4
diff --git a/rules/common/geosite.go b/rules/common/geosite.go
index c0a3a1da..e89dc19b 100644
--- a/rules/common/geosite.go
+++ b/rules/common/geosite.go
@@ -9,7 +9,6 @@ import (
 	_ "github.com/Dreamacro/clash/component/geodata/standard"
 	C "github.com/Dreamacro/clash/constant"
 	"github.com/Dreamacro/clash/log"
-	"github.com/Dreamacro/clash/transport/socks5"
 )
 
 type GEOSITE struct {
@@ -25,11 +24,10 @@ func (gs *GEOSITE) RuleType() C.RuleType {
 }
 
 func (gs *GEOSITE) Match(metadata *C.Metadata) (bool, string) {
-	if metadata.AddrType() != socks5.AtypDomainName {
+	domain := metadata.RuleHost()
+	if len(domain) == 0 {
 		return false, ""
 	}
-
-	domain := metadata.RuleHost()
 	return gs.matcher.ApplyDomain(domain), gs.adapter
 }