mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 23:06:30 -05:00
move geo loader conf to environment variable
This commit is contained in:
parent
19d1ff9003
commit
bf0e7e35c8
@ -6,6 +6,8 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v4/common/platform"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
|
||||
"github.com/v2fly/v2ray-core/v4/infra/conf/geodata"
|
||||
rule2 "github.com/v2fly/v2ray-core/v4/infra/conf/rule"
|
||||
@ -140,8 +142,6 @@ type DNSConfig struct {
|
||||
QueryStrategy string `json:"queryStrategy"`
|
||||
DisableCache bool `json:"disableCache"`
|
||||
DisableFallback bool `json:"disableFallback"`
|
||||
|
||||
GeoLoader string `json:"geoLoader"`
|
||||
}
|
||||
|
||||
type HostAddress struct {
|
||||
@ -194,11 +194,11 @@ func getHostMapping(ha *HostAddress) *dns.Config_HostMapping {
|
||||
func (c *DNSConfig) Build() (*dns.Config, error) {
|
||||
cfgctx := cfgcommon.NewConfigureLoadingContext(context.Background())
|
||||
|
||||
if c.GeoLoader == "" {
|
||||
c.GeoLoader = "standard"
|
||||
}
|
||||
geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {
|
||||
return "standard"
|
||||
})
|
||||
|
||||
if loader, err := geodata.GetGeoDataLoader(c.GeoLoader); err == nil {
|
||||
if loader, err := geodata.GetGeoDataLoader(geoloadername); err == nil {
|
||||
cfgcommon.SetGeoDataLoader(cfgctx, loader)
|
||||
} else {
|
||||
return nil, newError("unable to create geo data loader ").Base(err)
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v4/common/platform"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
|
||||
"github.com/v2fly/v2ray-core/v4/infra/conf/geodata"
|
||||
rule2 "github.com/v2fly/v2ray-core/v4/infra/conf/rule"
|
||||
@ -61,7 +63,6 @@ type RouterConfig struct {
|
||||
Balancers []*BalancingRule `json:"balancers"`
|
||||
|
||||
DomainMatcher string `json:"domainMatcher"`
|
||||
GeoLoader string `json:"geoLoader"`
|
||||
}
|
||||
|
||||
func (c *RouterConfig) getDomainStrategy() router.Config_DomainStrategy {
|
||||
@ -90,11 +91,11 @@ func (c *RouterConfig) Build() (*router.Config, error) {
|
||||
|
||||
cfgctx := cfgcommon.NewConfigureLoadingContext(context.Background())
|
||||
|
||||
if c.GeoLoader == "" {
|
||||
c.GeoLoader = "standard"
|
||||
}
|
||||
geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {
|
||||
return "standard"
|
||||
})
|
||||
|
||||
if loader, err := geodata.GetGeoDataLoader(c.GeoLoader); err == nil {
|
||||
if loader, err := geodata.GetGeoDataLoader(geoloadername); err == nil {
|
||||
cfgcommon.SetGeoDataLoader(cfgctx, loader)
|
||||
} else {
|
||||
return nil, newError("unable to create geo data loader ").Base(err)
|
||||
|
Loading…
Reference in New Issue
Block a user