Skip to content

feat: Automatically map ports via scanning - #31

Merged
mikew merged 7 commits into
mainfrom
automat-ports-scan
Aug 1, 2025
Merged

feat: Automatically map ports via scanning#31
mikew merged 7 commits into
mainfrom
automat-ports-scan

Conversation

@mikew

@mikew mikew commented Jul 15, 2025

Copy link
Copy Markdown
Owner

This works by scanning terminal output for something that looks like a port being logged.

Closes #10

Comment thread src/client/main.go Outdated
Comment on lines +593 to +597
local detach = vim.api.nvim_buf_attach(bufnr, false, {
on_lines = on_lines,
})

nvrh_port_scanner.active_watchers[bufnr] = detach

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought this returned a function, but it's just a boolean. can remove the assignment

@mikew

mikew commented Jul 17, 2025

Copy link
Copy Markdown
Owner Author

I've been using this for about a week now. Very few false positives, but I did notice slowdown after keeping nvim-qt open for a couple of days. Didn't delve into whether it was this change tho 🤦

@mikew

mikew commented Jul 28, 2025

Copy link
Copy Markdown
Owner Author

Followup could be to make sure the port is actually open on the machine, to further guard ports being tunnelled that don't need to be. Something like this works across macos / linux, but needs lsof or netstat

#!/usr/bin/env bash
set -ex

if command -v lsof; then
  lsof -i ":$1"
elif command -v netstat; then
  netstat -an | grep LISTEN | grep ":$1"
else
  true
fi

@mikew

mikew commented Aug 1, 2025

Copy link
Copy Markdown
Owner Author

Eh, works well enough.

@mikew
mikew merged commit fe605f9 into main Aug 1, 2025
2 checks passed
@mikew
mikew deleted the automat-ports-scan branch August 1, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically detect ports

1 participant