Skip to content

feat(rules): extend slash-separated OR payload support to GEOSITE, GEOIP, and IP-ASN#2774

Open
aJC7737 wants to merge 1 commit into
MetaCubeX:Alphafrom
aJC7737:more-slash-support
Open

feat(rules): extend slash-separated OR payload support to GEOSITE, GEOIP, and IP-ASN#2774
aJC7737 wants to merge 1 commit into
MetaCubeX:Alphafrom
aJC7737:more-slash-support

Conversation

@aJC7737

@aJC7737 aJC7737 commented May 8, 2026

Copy link
Copy Markdown

Summary

Extend slash-separated payload support to more proxy rule types so a single rule can OR-match multiple values.

This adds support for:

  • GEOSITE,cn/gfw,...
  • GEOIP,lan/cn,...
  • IP-ASN,1/13335,...

The behavior is consistent with existing slash-separated matching patterns already used in some rule payloads: values are split by / and matched with OR semantics.

What changed

Rule behavior

  • GEOSITE now accepts multiple slash-separated categories and matches if any category matches.
  • GEOIP now accepts multiple slash-separated countries/pseudo-values and matches if any value matches.
    • Mixed payloads such as lan/cn are supported.
    • Existing lan behavior is preserved.
  • IP-ASN now accepts multiple slash-separated ASNs and matches if any ASN matches.

Parsing

  • Added a shared payload parser for slash-separated rule values.
  • The parser:
    • trims spaces around each segment
    • rejects empty segments
    • deduplicates values while preserving order
    • supports optional normalization for specific rule types

Internal improvements

  • Canonicalized stored payload strings for logging and UI display.
  • Added combined matcher support for multi-value GEOSITE and GEOIP.
  • Cached combined GEOSITE/GEOIP matchers on rule instances to avoid repeated matcher loading during match calls.
  • Made pure GEOIP,lan,... record-size behavior explicit.

Documentation

  • Added examples in docs/config.yaml
  • Added a short note that supported slash-separated payloads are OR-matched after trimming and deduplication

Examples

rules:
  - IP-ASN,1/13335,PROXY
  - GEOSITE,cn/gfw,PROXY
  - GEOIP,lan/cn,DIRECT

Tests

Added/updated tests covering:

  • slash-separated payload parsing
  • trimming and canonicalization
  • deduplication with preserved order
  • empty segment rejection
  • mixed GEOIP payload behavior such as lan/cn
  • pure lan record-size behavior
  • constructor-level coverage for GEOSITE and IP-ASN

@wwqgtxx wwqgtxx force-pushed the Alpha branch 5 times, most recently from 61b8d7f to 17bed79 Compare May 15, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant