Skip to content

Propagate the OS assigned port value (fixes LocalPort 0) - #87

Open
zeroSteiner wants to merge 3 commits into
rapid7:masterfrom
zeroSteiner:fix/local-comm-0-localport
Open

Propagate the OS assigned port value (fixes LocalPort 0)#87
zeroSteiner wants to merge 3 commits into
rapid7:masterfrom
zeroSteiner:fix/local-comm-0-localport

Conversation

@zeroSteiner

Copy link
Copy Markdown
Contributor

Propagate the OS-assigned port value. This means when LocalPort is 0, you get the value that the OS assigned.

See this comment for context rapid7/metasploit-framework#21604 (comment)

@kx7m2qd

kx7m2qd commented Jul 26, 2026

Copy link
Copy Markdown

core change in local.rb looks right, gating the localport update in the else branch means it only runs after a successful bind, and the specs check out for both tcp server and udp.

one thing I couldn't figure out though proxies.rb only has require 'uri' added, nothing else changed there. not obvious how that ties into propagating the os-assigned port, is it needed for something else in this PR or just something you noticed while working on this?

also since proxies.rb is touched, should there be a spec for LocalPort 0 going through a proxy too, or are the two direct-bind specs enough for what this PR is trying to fix?

asking because rapid7/metasploit-framework#21604 depends on this landing, wanted to actually understand what's changing before that work gets built on top of it

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.

2 participants