Skip to content

Commit

Permalink
wip automap ports
Browse files Browse the repository at this point in the history
  • Loading branch information
mikew committed Oct 20, 2024
1 parent 80b1686 commit 5b83956
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,23 @@ os.execute('chmod +x ' .. browser_script_path)
return true
`, nil, nvrhContext.BrowserScriptPath, nvrhContext.RemoteSocketOrPort(), nv.ChannelID())





// Prepare the list-open-ports script.
listOpenPortsScriptPath := "/tmp/nvrh-list-open-ports"
batch.ExecLua(`
local script_path = ...
local script_contents = [[
#!/bin/sh
lsof -i4 -n -P | grep LISTEN | awk '{ print $9 }' | cut -d : -f 2
]]
script_contents = string.format(script_contents, socket_path, channel_id)
vim.fn.writefile(vim.fn.split(script_contents, '\n'), script_path)
os.execute('chmod +x ' .. script_path)
return true
`, nil, listOpenPortsScriptPath)

if err := batch.Execute(); err != nil {
return err
Expand Down

0 comments on commit 5b83956

Please sign in to comment.