Skip to content

Conversation

@Lucacux
Copy link
Contributor

@Lucacux Lucacux commented Jan 10, 2026

Motivation

  • Provide a way for netbridge to detect available NAT traversal operators and select an appropriate operator at runtime via DetectInfrastructure and a returned InfrastructureStatus.
  • Make operator selection deterministic and testable by adding ordering and an empty container constructor to the operator registry (OperatorContainer / NewEmptyOperatorContainer).
  • Introduce scaffolding for additional traversal methods (NAT-PMP, PCP, hole-punch) so protocol implementations can be added later using a common operator interface.
  • Enforce configured allowed port ranges in the netbridge implementation to prevent forwarding/discovery outside policy via parseAllowedPorts/isPortAllowed.

Description

  • Add DetectInfrastructure to the NetbridgeInterface, add InfrastructureStatus struct, and implement DetectInfrastructure in NetbridgeImpl to report enabled state, available operators, selected operator, and fallback availability.
  • Extend operators.OperatorContainer with ordering support, NewEmptyOperatorContainer, ObtainFrom, AvailableNames, and an orderedOperators helper to support prioritized and deterministic operator selection; register new operator scaffolds in NewOperatorContainer.
  • Add operator scaffolds operators/natpmp, operators/pcp, and operators/holepunch providing New... constructors and stubbed OperatorInterface methods that return clear "not implemented" errors.
  • Implement obtainOperator in NetbridgeImpl, delegate public/local IP and port operations to the obtained operator when available, and add parseAllowedPorts/isPortAllowed logic to enforce config.GetNetbridge().AllowedPorts.

Testing

  • No automated tests were executed as part of this change.
  • Unit tests were added/updated in internal/infrastructure/netbridge/netbridge_test.go to cover DetectInfrastructure and use a fakeOperator, but they were not run.
  • gofmt was applied to the modified files as part of the rollout.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants