diff --git a/ClashX/AppDelegate.swift b/ClashX/AppDelegate.swift index e8f7cf1..1ca72c3 100644 --- a/ClashX/AppDelegate.swift +++ b/ClashX/AppDelegate.swift @@ -100,7 +100,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { setupData() runAfterConfigReload = { [weak self] in self?.selectOutBoundModeWithMenory() - self?.selectAllowLanWithMenory() + if !ConfigManager.builtInApiMode { + self?.selectAllowLanWithMenory() + } } updateConfig(showNotification: false) updateLoggingLevel() @@ -353,7 +355,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } Logger.log("Trying start proxy") - let string = run(ConfigManager.builtInApiMode.goObject())?.toString() ?? "" + let string = run(ConfigManager.builtInApiMode.goObject(), ConfigManager.allowConnectFromLan.goObject())?.toString() ?? "" let jsonData = string.data(using: .utf8) ?? Data() if let res = try? JSONDecoder().decode(StartProxyResp.self, from: jsonData) { let port = res.externalController.components(separatedBy: ":").last ?? "9090" diff --git a/ClashX/goClash/go.mod b/ClashX/goClash/go.mod index 27ea653..6ee3bde 100644 --- a/ClashX/goClash/go.mod +++ b/ClashX/goClash/go.mod @@ -1,7 +1,7 @@ module github.com/yichengchen/clashX/ClashX require ( - github.com/Dreamacro/clash v0.20.1-0.20200508135217-3638b077cdc5 + github.com/Dreamacro/clash v0.20.1-0.20200512032953-3a27cfc4a130 github.com/oschwald/geoip2-golang v1.4.0 github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 ) diff --git a/ClashX/goClash/go.sum b/ClashX/goClash/go.sum index 5c20dbe..1efd444 100644 --- a/ClashX/goClash/go.sum +++ b/ClashX/goClash/go.sum @@ -1,5 +1,5 @@ -github.com/Dreamacro/clash v0.20.1-0.20200508135217-3638b077cdc5 h1:0B7URouk7YzZoVOTNl6/rTCvu39+zFe7sroCVf6RT0Y= -github.com/Dreamacro/clash v0.20.1-0.20200508135217-3638b077cdc5/go.mod h1:KiPMTu1n6emQzUyY/A7W4mZYzQLfhToryDUp8ypta7E= +github.com/Dreamacro/clash v0.20.1-0.20200512032953-3a27cfc4a130 h1:d4iusQxlY7rPXzkIUIczLZazoRXusB1bEth07CkPVY8= +github.com/Dreamacro/clash v0.20.1-0.20200512032953-3a27cfc4a130/go.mod h1:KiPMTu1n6emQzUyY/A7W4mZYzQLfhToryDUp8ypta7E= github.com/Dreamacro/go-shadowsocks2 v0.1.5 h1:BizWSjmwzAyQoslz6YhJYMiAGT99j9cnm9zlxVr+kyI= github.com/Dreamacro/go-shadowsocks2 v0.1.5/go.mod h1:LSXCjyHesPY3pLjhwff1mQX72ItcBT/N2xNC685cYeU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/ClashX/goClash/main.go b/ClashX/goClash/main.go index 5ae221d..c005883 100644 --- a/ClashX/goClash/main.go +++ b/ClashX/goClash/main.go @@ -36,7 +36,7 @@ func initClashCore() { constant.SetConfig(configFile) } -func parseConfig(checkPort bool) (*config.Config, error) { +func parseDefaultConfigThenStart(checkPort, allowLan bool) (*config.Config, error) { cfg, err := executor.Parse() if err != nil { return nil, err @@ -50,8 +50,8 @@ func parseConfig(checkPort bool) (*config.Config, error) { cfg.General.ExternalController = "127.0.0.1:" + strconv.Itoa(port) cfg.General.Secret = "" } + cfg.General.AllowLan = allowLan } - go route.Start(cfg.General.ExternalController, cfg.General.Secret) executor.ApplyConfig(cfg, true) @@ -74,8 +74,8 @@ func verifyClashConfig(content *C.char) *C.char { } //export run -func run(checkConfig bool) *C.char { - cfg, err := parseConfig(checkConfig) +func run(checkConfig, allowLan bool) *C.char { + cfg, err := parseDefaultConfigThenStart(checkConfig,allowLan) if err != nil { return C.CString(err.Error()) }