Skip to content

Conversation

@akrem-chabchoub
Copy link
Contributor

@akrem-chabchoub akrem-chabchoub commented Jan 5, 2026

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Allow hostname to pass the validation for public address.

Test:
./dist/bee start --nat-addr="example.com:1234" --config=config.yml

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

@akrem-chabchoub akrem-chabchoub self-assigned this Jan 5, 2026
@akrem-chabchoub akrem-chabchoub marked this pull request as ready for review January 5, 2026 12:40
Copilot AI review requested due to automatic review settings January 5, 2026 12:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modifies the validatePublicAddress function to accept hostnames in addition to IP addresses for the NAT address configuration. Previously, the function would reject any input that wasn't a valid IP address.

Key Changes:

  • Modified validation logic to only perform IP-specific checks (loopback, private) when the host is a valid IP address
  • Updated test cases to reflect that hostnames are now valid inputs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pkg/node/node.go Refactored validatePublicAddress to validate IP-specific constraints only when the host is an IP, allowing hostnames to pass through
pkg/node/node_test.go Updated test cases to expect hostnames to be valid and added new test cases for hostname formats

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@martinconic
Copy link
Contributor

Is there a benefit or it is ok to allow any valid hostname? I think we should only have hostnames that point to the IP where Bee is installed, right? Bee should not start if we provide nat-addr: example.com:1634. The example.com is not a valid valid hostname, any other hostname that does not point to the Bee instance from where Bee started should not be allowed, right?

@akrem-chabchoub
Copy link
Contributor Author

akrem-chabchoub commented Jan 5, 2026

Is there a benefit or it is ok to allow any valid hostname? I think we should only have hostnames that point to the IP where Bee is installed, right? Bee should not start if we provide nat-addr: example.com:1634. The example.com is not a valid valid hostname, any other hostname that does not point to the Bee instance from where Bee started should not be allowed, right?

The current validation only checks hostname format, not DNS resolution or whether the resolved IP is valid/public. This allows example.com:1634 to pass.
For hostname lookup, its already happening here.
We may keep the current validation as it is to not repeat the same lookup in 2 different places and add validation for public/private IP in static resolver.
What do you think ?

cc @janos

@bcsorvasi bcsorvasi added this to the v2.7.0 milestone Jan 6, 2026
@akrem-chabchoub akrem-chabchoub requested a review from acud January 7, 2026 16:49
@akrem-chabchoub akrem-chabchoub merged commit 55d4864 into master Jan 8, 2026
17 checks passed
@akrem-chabchoub akrem-chabchoub deleted the fix/public-addr-validation branch January 8, 2026 14:04
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.

5 participants