修复跨端问题

This commit is contained in:
2026-06-04 17:49:31 +08:00
parent f84a9a3cdd
commit 6fb6fc4f10
4 changed files with 49 additions and 3 deletions
+12 -1
View File
@@ -178,11 +178,19 @@ func defaultWebSocketPath() string {
func defaultWebSocketPathForGOOS(goos string) string {
if goos == "windows" {
return filepath.Join(".", "win", "opt", "mesh_mqtt_go", "web.sock")
return ""
}
return filepath.Join(string(filepath.Separator), "opt", "mesh_mqtt_go", "web.sock")
}
func clearWebSocketPathOnUnsupportedGOOS(cfg *config, goos string) bool {
if goos != "windows" || cfg.Web.SocketPath == "" {
return false
}
cfg.Web.SocketPath = ""
return true
}
func defaultSQLitePathForGOOS(goos string) string {
if goos == "windows" {
return filepath.Join(".", "win", "etc", "mesh_mqtt_go", "mesh_mqtt_go.db")
@@ -221,6 +229,9 @@ func loadConfig(path string) (*config, error) {
}
cfg, changed := normalizeConfig(raw)
if clearWebSocketPathOnUnsupportedGOOS(cfg, runtime.GOOS) {
changed = true
}
if err := validateConfig(cfg); err != nil {
return nil, err
}