refactor: Move port mapping code to its own module
Summary:
This commit does not change behavior.
This is a backport of core#18077 [1/13]
https://github.com/bitcoin/bitcoin/pull/18077/commits/02ccf69dd6b772423acb343d16ef2bdbb3e3da03
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D12069