diff --git a/cmd/resource/resource.go b/cmd/resource/resource.go index dde6fb1..251031c 100644 --- a/cmd/resource/resource.go +++ b/cmd/resource/resource.go @@ -19,9 +19,9 @@ import ( var ( // fixed non-string version. used for launcher version checks - intVersion = [4]uint16{1, 0, 44, 0} + intVersion = [4]uint16{1, 0, 45, 0} // display version - strVersion = "1.0.44" + strVersion = "1.0.45" ) func getIcon(path string) *winres.Icon { diff --git a/controller/native/node.go b/controller/native/node.go index f3bbe5d..adeb767 100644 --- a/controller/native/node.go +++ b/controller/native/node.go @@ -37,7 +37,7 @@ func NewController() *Controller { } func (c *Controller) GetCaps() int { - return 0 + return 1 } func (c *Controller) SetApp(a model_.AppState) { diff --git a/controller/native/runner.go b/controller/native/runner.go index 2828244..fe7e70c 100644 --- a/controller/native/runner.go +++ b/controller/native/runner.go @@ -121,21 +121,31 @@ func KillPreviousLauncher() { func (r *NodeRunner) startNode() error { log.Println("!startNode") fullExePath := getNodeExePath() + c := r.mod.Config + log.Println("!startNode", c.EnablePortForwarding) + portsArg := "" + if c.EnablePortForwarding { + portsArg = fmt.Sprintf("--udp.ports=%d:%d", c.PortRangeBegin, c.PortRangeEnd) + } + userspaceArg := "--userspace" versionArg := fmt.Sprintf("--launcher.ver=%s", r.mod.GetProductVersionString()) configDirArg := fmt.Sprintf("--config-dir=%s", r.configpath) dataDirArg := fmt.Sprintf("--data-dir=%s", r.configpath) logDirArg := fmt.Sprintf("--log-dir=%s", r.configpath) nodeuiDirArg := fmt.Sprintf("--node-ui-dir=%s", path.Join(r.configpath, "nodeui")) - userspaceArg := "--userspace" - args2 := make([]string, 0) if r.mod.NodeFlags != "" { args2 = strings.Split(r.mod.NodeFlags, " ") } - args := []string{userspaceArg, versionArg} + args := []string{} + if portsArg != "" { + args = append(args, portsArg) + } + args = append(args, userspaceArg, versionArg) + if len(args2) > 0 { args = append(args, args2...) } else { diff --git a/gui-win32/networking_dlg.go b/gui-win32/networking_dlg.go index 4913071..7319702 100644 --- a/gui-win32/networking_dlg.go +++ b/gui-win32/networking_dlg.go @@ -138,9 +138,11 @@ func (g *Gui) NetworkingDlg() { walk.MsgBoxTopMost|walk.MsgBoxOK|walk.MsgBoxIconExclamation) return } - g.model.GetConfig().EnablePortForwarding = manualPortForwarding.Checked() - g.model.GetConfig().PortRangeBegin = portRangeBegin - g.model.GetConfig().PortRangeEnd = portRangeLen + cfg := g.model.GetConfig() + cfg.EnablePortForwarding = manualPortForwarding.Checked() + cfg.PortRangeBegin = portRangeBegin + cfg.PortRangeEnd = portRangeLen + cfg.Save() dialog.Accept() g.model.App.TriggerAction("restart") diff --git a/model/state.go b/model/state.go index 99e2d66..5128c5e 100644 --- a/model/state.go +++ b/model/state.go @@ -160,6 +160,7 @@ func (c *Config) Read() { json.NewDecoder(file).Decode(&c) // for version check c.getDefaultValues(false) + file.Seek(0, 0) json.NewDecoder(file).Decode(&c) } diff --git a/myst/manager.go b/myst/manager.go index e9fa80e..e916d61 100644 --- a/myst/manager.go +++ b/myst/manager.go @@ -15,6 +15,8 @@ import ( "io" "log" "os" + "path/filepath" + "runtime" "strconv" "strings" "time" @@ -24,6 +26,7 @@ import ( "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/strslice" "github.com/docker/docker/client" + "github.com/docker/go-connections/nat" errors2 "github.com/pkg/errors" @@ -60,6 +63,18 @@ type Manager struct { } func NewManager(model *model.UIModel) (*Manager, error) { + + if runtime.GOOS == "darwin" { + // Prefer DOCKER_HOST, don't override it + _, hasDockerHost := os.LookupEnv("DOCKER_HOST") + if !hasDockerHost { + if _, err := os.Stat("/var/run/docker.sock"); os.IsNotExist(err) { + // path does not exist + os.Setenv("DOCKER_HOST", "unix://"+filepath.Join(utils.GetUserProfileDir(), ".docker/run/docker.sock")) + } + } + } + dc, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { return nil, errors2.Wrap(err, ErrCouldNotConnect.Error())