Skip to content

Commit

Permalink
fix: api does not return configuration value
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Feb 21, 2024
1 parent 9e7eaf7 commit 1c7e011
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
34 changes: 31 additions & 3 deletions component/geodata/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@ package geodata
import (
"errors"
"fmt"
"golang.org/x/sync/singleflight"
"strings"

"golang.org/x/sync/singleflight"

"github.com/metacubex/mihomo/component/geodata/router"
C "github.com/metacubex/mihomo/constant"
"github.com/metacubex/mihomo/log"
)

var geoLoaderName = "memconservative"
var geoSiteMatcher = "succinct"
var (
geoMode bool
AutoUpdate bool
UpdateInterval int
geoLoaderName = "memconservative"
geoSiteMatcher = "succinct"
)

// geoLoaderName = "standard"

func GeodataMode() bool {
return geoMode
}

func GeoAutoUpdate() bool {
return AutoUpdate
}

func GeoUpdateInterval() int {
return UpdateInterval
}

func LoaderName() string {
return geoLoaderName
}
Expand All @@ -24,6 +42,16 @@ func SiteMatcherName() string {
return geoSiteMatcher
}

func SetGeodataMode(newGeodataMode bool) {
geoMode = newGeodataMode
}
func SetGeoAutoUpdate(newAutoUpdate bool) {
AutoUpdate = newAutoUpdate
}
func SetGeoUpdateInterval(newGeoUpdateInterval int) {
UpdateInterval = newGeoUpdateInterval
}

func SetLoader(newLoader string) {
if newLoader == "memc" {
newLoader = "memconservative"
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) {
}

func parseGeneral(cfg *RawConfig) (*General, error) {
geodata.SetGeodataMode(cfg.GeodataMode)
geodata.SetGeoAutoUpdate(cfg.GeoAutoUpdate)
geodata.SetGeoUpdateInterval(cfg.GeoUpdateInterval)
geodata.SetLoader(cfg.GeodataLoader)
geodata.SetSiteMatcher(cfg.GeositeMatcher)
C.GeoAutoUpdate = cfg.GeoAutoUpdate
Expand Down
21 changes: 12 additions & 9 deletions hub/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,18 @@ func GetGeneral() *config.General {
AllowLan: listener.AllowLan(),
BindAddress: listener.BindAddress(),
},
Controller: config.Controller{},
Mode: tunnel.Mode(),
LogLevel: log.Level(),
IPv6: !resolver.DisableIPv6,
GeodataLoader: G.LoaderName(),
GeositeMatcher: G.SiteMatcherName(),
Interface: dialer.DefaultInterface.Load(),
Sniffing: tunnel.IsSniffing(),
TCPConcurrent: dialer.GetTcpConcurrent(),
Controller: config.Controller{},
Mode: tunnel.Mode(),
LogLevel: log.Level(),
IPv6: !resolver.DisableIPv6,
GeodataMode: G.GeodataMode(),
GeoAutoUpdate: G.GeoAutoUpdate(),
GeoUpdateInterval: G.GeoUpdateInterval(),
GeodataLoader: G.LoaderName(),
GeositeMatcher: G.SiteMatcherName(),
Interface: dialer.DefaultInterface.Load(),
Sniffing: tunnel.IsSniffing(),
TCPConcurrent: dialer.GetTcpConcurrent(),
}

return general
Expand Down

0 comments on commit 1c7e011

Please sign in to comment.