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