MCPcopy Create free account
hub / github.com/V2RaySSR/RealityChecker / shouldExcludeDomain

Function shouldExcludeDomain

internal/cmd/csv.go:121–175  ·  view source on GitHub ↗

shouldExcludeDomain 判断是否应该排除某个域名

(domain string)

Source from the content-addressed store, hash-verified

119
120// shouldExcludeDomain 判断是否应该排除某个域名
121func shouldExcludeDomain(domain string) bool {
122 // 1. 排除包含通配符(*)的域名
123 if strings.Contains(domain, "*") {
124 return true
125 }
126
127 // 2. 排除列表
128 excludePatterns := []string{
129 "localhost",
130 "server.domain.com",
131 "johnnasmalley.hostname",
132 "Kubernetes Ingress Controller Fake Certificate",
133 "CloudFlare Origin Certificate",
134 "FortiGate",
135 "Unspecified",
136 }
137
138 domainLower := strings.ToLower(domain)
139
140 for _, pattern := range excludePatterns {
141 if strings.Contains(domainLower, strings.ToLower(pattern)) {
142 return true
143 }
144 }
145
146 // 3. 排除IP地址格式
147 if strings.Contains(domain, ".") && !strings.Contains(domain, "..") {
148 parts := strings.Split(domain, ".")
149 if len(parts) == 4 {
150 // 可能是IP地址,简单检查
151 isIP := true
152 for _, part := range parts {
153 if len(part) > 3 {
154 isIP = false
155 break
156 }
157 }
158 if isIP {
159 return true // 是IP地址,排除
160 }
161 }
162 }
163
164 // 4. 排除无效域名(太短或包含特殊字符)
165 if len(domain) < 3 {
166 return true
167 }
168
169 // 5. 排除包含多个连续点的域名
170 if strings.Contains(domain, "..") {
171 return true
172 }
173
174 return false
175}

Callers 1

extractDomainsFromCSVFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected