Skip to content

Commit b8196a2

Browse files
JimhHanJimhHan
authored andcommitted
Fix: matching type mismatch
1 parent 6471cfd commit b8196a2

3 files changed

Lines changed: 119 additions & 39 deletions

File tree

common/matcher/geosite/geosite.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,19 @@ func ToDomains(dms []*Domain) []*domain.Domain {
1515
}
1616

1717
func (d *Domain) ToDomain() *domain.Domain {
18-
return &domain.Domain{Type: d.Type, Value: d.Value}
18+
return &domain.Domain{Type: d.Type.ToMatchingType(), Value: d.Value}
19+
}
20+
21+
func (t Domain_Type) ToMatchingType() domain.MatchingType {
22+
switch t {
23+
case Domain_Plain:
24+
return domain.MatchingType_Keyword
25+
case Domain_Regex:
26+
return domain.MatchingType_Regex
27+
case Domain_Domain:
28+
return domain.MatchingType_Subdomain
29+
case Domain_Full:
30+
return domain.MatchingType_Full
31+
}
32+
panic("impossible")
1933
}

common/matcher/geosite/geosite.pb.go

Lines changed: 93 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/matcher/geosite/geosite.proto

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ option go_package = "github.com/xtls/xray-core/common/matcher/geosite";
66
option java_package = "com.xray.common.matcher.geosite";
77
option java_multiple_files = true;
88

9-
import "common/matcher/domain/domain.proto";
10-
119
message Domain {
10+
enum Type {
11+
// The value is used as is.
12+
Plain = 0;
13+
// The value is used as a regular expression.
14+
Regex = 1;
15+
// The value is a root domain.
16+
Domain = 2;
17+
// The value is a domain.
18+
Full = 3;
19+
}
1220
// Domain matching type.
13-
xray.common.matcher.domain.MatchingType type = 1;
21+
Type type = 1;
1422

1523
// Domain value.
1624
string value = 2;

0 commit comments

Comments
 (0)