Skip to content

Commit

Permalink
using hub.ApplyConfig to start the external controller
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Aug 31, 2024
1 parent 90f3a09 commit e548b93
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions core/src/main/golang/native/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"gopkg.in/yaml.v2"

"cfa/native/app"
"github.com/metacubex/mihomo/log"

"github.com/metacubex/mihomo/config"
"github.com/metacubex/mihomo/hub/executor"
"github.com/metacubex/mihomo/hub/route"
"github.com/metacubex/mihomo/hub"
"github.com/metacubex/mihomo/log"
)

func logDns(cfg *config.RawConfig) {
Expand Down Expand Up @@ -79,16 +78,7 @@ func Load(path string) error {

// Start the external controller like in hub.Parse(), but we have set its
// default override value to end with ":0" for security.
//
// It would be difficult to update configurations for external controller
// inbound, so changes will require a restart after a profile is loaded.
if cfg.Controller.ExternalController != "" && !strings.HasSuffix(cfg.Controller.ExternalController, ":0") {
go route.Start(cfg.Controller.ExternalController, cfg.Controller.ExternalControllerTLS,
cfg.Controller.Secret, cfg.TLS.Certificate, cfg.TLS.PrivateKey, cfg.Controller.ExternalDohServer,
cfg.General.LogLevel == log.DEBUG)
}

executor.ApplyConfig(cfg, true)
hub.ApplyConfig(cfg)

app.ApplySubtitlePattern(rawCfg.ClashForAndroid.UiSubtitlePattern)

Expand All @@ -103,5 +93,5 @@ func LoadDefault() {
panic(err.Error())
}

executor.ApplyConfig(cfg, true)
hub.ApplyConfig(cfg)
}

0 comments on commit e548b93

Please sign in to comment.