Skip to content

Directory ignores --serverpublicip for servers behind a UDP proxy or load balancer #3694

@stefan1000

Description

@stefan1000

Describe the bug
--serverpublicip is ignored when a server registers through a UDP proxy or load balancer. The directory always advertises the backend's UDP source IP instead of the declared one, making the server unreachable for clients.

Seems historically --serverpublicip was only added for the same network use case, but I think it should be a general option to register with a given public IP.

To Reproduce

  1. Put a Jamulus server behind a UDP proxy/LB
  2. Register with a directory using --serverpublicip <your-public-ip>
  3. Check what IP clients receive in the server list — it's the backend source IP, not the one you passed

Expected behavior
Clients get the IP from --serverpublicip.

Screenshots
N/A

Operating system
N/A — directory-side logic issue, OS independent

Version of Jamulus
3.11

Additional context
Root cause is in CServerListManager::RetrieveAll: the wantHostAddr condition always resolves to true for an external client + external server, so LHostAddr (where --serverpublicip ends up) is never consulted.

LHostAddr should take precedence when it is set to a public IP, bypassing the normal routing logic.

Something like an "hasExplicitPublicOverride" (serverlist.cpp):

bool hasExplicitPublicOverride =
    siCurListEntry.LHostAddr.InetAddr != CHostAddress().InetAddr &&
    !NetworkUtil::IsPrivateNetworkIP ( siCurListEntry.LHostAddr.InetAddr );

bool wantHostAddr = !hasExplicitPublicOverride &&
                    ( clientIsInternal ||
                      ( !serverIsInternal &&
                        InetAddr.InetAddr != siCurListEntry.HostAddr.InetAddr ) );```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions