feat: dedupe geoip rules

This commit is contained in:
2026-07-20 17:37:37 +08:00
parent 7ff3daa9d3
commit 8c574bf054
2 changed files with 77 additions and 1 deletions

View File

@ -31,3 +31,30 @@ func TestDedupeMatchRuleNonList(t *testing.T) {
t.Fatalf("expected nil passthrough, got %#v", got)
}
}
func TestDedupeGeoIPRule(t *testing.T) {
rules := []interface{}{
"GEOIP,CN,DIRECT",
"DOMAIN,example.com,sub-a | Proxy",
"GEOIP,CN,sub-b | Proxy,no-resolve",
"GEOIP,JP,sub-b | Proxy",
}
got := dedupeGeoIPRule(rules)
want := []interface{}{
"DOMAIN,example.com,sub-a | Proxy",
"GEOIP,CN,sub-b | Proxy,no-resolve",
"GEOIP,JP,sub-b | Proxy",
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("got %#v, want %#v", got, want)
}
}
func TestDedupeGeoIPRuleNonList(t *testing.T) {
if got := dedupeGeoIPRule(nil); got != nil {
t.Fatalf("expected nil passthrough, got %#v", got)
}
}