forked from mirror/serenity
Fix geosite usage
This commit is contained in:
parent
9fb2abc833
commit
17101f7d11
@ -114,48 +114,18 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error
|
||||
if !t.DisableTrafficBypass {
|
||||
if t.DisableRuleSet || (metadata.Version != nil && metadata.Version.LessThan(semver.ParseVersion("1.8.0-alpha.10"))) {
|
||||
options.DNS.Rules = append(options.DNS.Rules, option.DNSRule{
|
||||
Type: C.RuleTypeLogical,
|
||||
LogicalOptions: option.LogicalDNSRule{
|
||||
Mode: C.LogicalTypeAnd,
|
||||
Rules: []option.DNSRule{
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultDNSRule{
|
||||
Geosite: []string{"geolocation-!cn"},
|
||||
Invert: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultDNSRule{
|
||||
Geosite: []string{"cn"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Server: DNSLocalTag,
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultDNSRule{
|
||||
Geosite: []string{"geolocation-cn"},
|
||||
Server: DNSLocalTag,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
options.DNS.Rules = append(options.DNS.Rules, option.DNSRule{
|
||||
Type: C.RuleTypeLogical,
|
||||
LogicalOptions: option.LogicalDNSRule{
|
||||
Mode: C.LogicalTypeAnd,
|
||||
Rules: []option.DNSRule{
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultDNSRule{
|
||||
RuleSet: []string{"geosite-geolocation-!cn"},
|
||||
Invert: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultDNSRule{
|
||||
RuleSet: []string{"geosite-cn"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Server: DNSLocalTag,
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultDNSRule{
|
||||
RuleSet: []string{"geosite-geolocation-cn"},
|
||||
Server: DNSLocalTag,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -68,19 +68,10 @@ func (t *Template) renderGeoResources(metadata M.Metadata, options *option.Optio
|
||||
},
|
||||
{
|
||||
Type: C.RuleSetTypeRemote,
|
||||
Tag: "geosite-cn",
|
||||
Tag: "geosite-geolocation-cn",
|
||||
Format: C.RuleSetFormatBinary,
|
||||
RemoteOptions: option.RemoteRuleSet{
|
||||
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-cn.srs",
|
||||
DownloadDetour: downloadDetour,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.RuleSetTypeRemote,
|
||||
Tag: "geosite-geolocation-!cn",
|
||||
Format: C.RuleSetFormatBinary,
|
||||
RemoteOptions: option.RemoteRuleSet{
|
||||
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-!cn.srs",
|
||||
URL: downloadURL + "SagerNet/sing-geosite" + branchSplit + "rule-set/geosite-geolocation-cn.srs",
|
||||
DownloadDetour: downloadDetour,
|
||||
},
|
||||
},
|
||||
|
@ -121,50 +121,19 @@ func (t *Template) renderRoute(metadata M.Metadata, options *option.Options) err
|
||||
if !t.DisableTrafficBypass {
|
||||
if t.DisableRuleSet || disable18Features {
|
||||
options.Route.Rules = append(options.Route.Rules, option.Rule{
|
||||
Type: C.RuleTypeLogical,
|
||||
LogicalOptions: option.LogicalRule{
|
||||
Mode: C.LogicalTypeAnd,
|
||||
Rules: []option.Rule{
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultRule{
|
||||
Geosite: []string{"geolocation-!cn"},
|
||||
Invert: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultRule{
|
||||
GeoIP: []string{"cn"},
|
||||
Geosite: []string{"cn"},
|
||||
Domain: []string{"download.jetbrains.com"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultRule{
|
||||
GeoIP: []string{"cn"},
|
||||
Geosite: []string{"geolocation-cn"},
|
||||
Outbound: directTag,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
options.Route.Rules = append(options.Route.Rules, option.Rule{
|
||||
Type: C.RuleTypeLogical,
|
||||
LogicalOptions: option.LogicalRule{
|
||||
Mode: C.LogicalTypeAnd,
|
||||
Rules: []option.Rule{
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultRule{
|
||||
RuleSet: []string{"geosite-geolocation-!cn"},
|
||||
Invert: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultRule{
|
||||
RuleSet: []string{"geoip-cn", "geosite-cn"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Outbound: "direct",
|
||||
Type: C.RuleTypeDefault,
|
||||
DefaultOptions: option.DefaultRule{
|
||||
RuleSet: []string{"geoip-cn", "geosite-geolocation-cn"},
|
||||
Outbound: directTag,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user