Skip to content

Commit

Permalink
Add support of port forwarding
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Litvinov <jnashicq@gmail.com>
  • Loading branch information
Zensey committed Jan 22, 2024
1 parent 5cc40f0 commit 20a6e96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controller/native/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewController() *Controller {
}

func (c *Controller) GetCaps() int {
return 0
return 1
}

func (c *Controller) SetApp(a model_.AppState) {
Expand Down
16 changes: 13 additions & 3 deletions controller/native/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions gui-win32/networking_dlg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions model/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 20a6e96

Please sign in to comment.