Skip to content

Fix setting of public port different from YaCy port - #792

Open
mmeier86 wants to merge 4 commits into
yacy:masterfrom
mmeier86:fix-public-port
Open

Fix setting of public port different from YaCy port#792
mmeier86 wants to merge 4 commits into
yacy:masterfrom
mmeier86:fix-public-port

Conversation

@mmeier86

@mmeier86 mmeier86 commented May 30, 2026

Copy link
Copy Markdown
Contributor

This is a fix for #791.

I've had a look at the code, and it looks like the getPublicPort function was already used pretty consistently to get the public port send to peers, and didn't seem to be used for anything else. But it always expected the config key of the port setting to be handed in as an argument.

Instead of continuing that, I rewrote the function to instead only receive whether SSL is in use or not, and then decide where to fetch the port internally, doing the following:

  • If SERVER_PORT_PUBLIC is set, return that value
  • If SSL is used:
    • Return SERVER_SSLPORT from config or from UPnP map
  • If SSL is not used:
    • Return SERVER_PORT from config or from UPnP map

I've decided to introduce the new SERVER_PORT_PUBLIC/port.public setting instead of re-using the publicPort setting because for some reason, setting publicPort via the env variable YACY_PUBLICPORT did not work, and I'm still not sure why.

To make migration easier, I also introduced a migration step: If publicPort is set and port.public is not, port.public is automatically set to the value of publicPort.

One last point is my change in the SettingsAck_p.java file. I changed the code to call updateMySeed, because at least for me, the old way with just setting the seed's port didn't do anything, at least in all the setups I've tried, while calling updateMySeed updated the port send to peers for connections as expected.

Once I've got the okay about the introduction of the new port.public, I would also be happy to create another PR for the website to update the docs.

mmeier86 added 4 commits May 30, 2026 23:28
The old "publicPort" setting didn't seem to have any effect at all, peers
still tried to access the instance on the "port" value.

This commit changes the getPublicPort function to decide on which port to
return without receiving an explicit key. This centralizes the decision on
which port is communicated to other peers.
If publicPort is set at startup and port.public is not, the publicPort
value is written into port.public.
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.

1 participant