fix(plugin): allow overriding server IP for NAT/private setups - #25
Open
Rushaway wants to merge 2 commits into
Open
fix(plugin): allow overriding server IP for NAT/private setups#25Rushaway wants to merge 2 commits into
Rushaway wants to merge 2 commits into
Conversation
Servers running behind NAT (e.g. in a container) auto-detect the private LAN "hostip", which never matches the public IP registered in the web panel, so bans/comms are never associated with the correct server. Add an optional "ServerIP" key to the Config section of sourcebans.cfg. When set, it overrides the auto-detected IP used in all SQL server lookups and INSERTs in sbpp_main and sbpp_comms. Empty by default, preserving existing auto-detect behaviour. Refs: sbpp#1555 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Harden the "ServerIP" override added for NAT/containerized gameservers: - Validate the configured value as a dotted-quad IPv4 and TrimString() it. ServerIp is interpolated into SQL unescaped, so a malformed/whitespace value would silently never match (or break) the sb_servers lookup. Invalid values are logged and fall back to the auto-detected hostip. - Reset ServerIpOverride at the start of every ReadConfig() so removing or emptying the key on a reload no longer keeps a stale override, and re-apply it over the auto-detected IP after each parse (UpdateServerIp() in sbpp_main, ServerInfo() in sbpp_comms) instead of writing ServerIp from inside the SMC key handler. - sbpp_main: parse the config before the first InsertServerInfo() when the database callback wins the race against OnMapStart, otherwise the AutoAddServer SELECT/INSERT could still run with the private hostip (and the default DatabasePrefix). - Guard hostip/hostport cvar lookups against null. - Document the IPv4 requirement, the invalid-value fallback, and that the port still comes from the hostport cvar (NAT port remaps are not covered). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
Author
Review: approve after fixes (pushed as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Ports upstream issue sbpp#1555.
A gameserver running behind NAT (for example inside a container) has its
hostipcvar set to a private LAN address (e.g.10.46.144.181). Theplugin uses that auto-detected value in every SQL statement that looks up
or inserts the server:
That never matches the public IP registered in the web panel, so bans and
comms are never associated with the server and stay stuck in the local
sourcebans-queue.sq3. The issue reporter tried aServerIPkey that didnot actually exist.
Fix
Add an optional
"ServerIP"key to theConfigsection ofsourcebans.cfg. When non-empty it overrides the auto-detected IP usedfor all server lookups/INSERTs in
sbpp_main.spandsbpp_comms.sp.Empty by default, so existing auto-detect behaviour is unchanged.
The override is applied both when the config key is parsed and right
after the hostip is formatted in
InsertServerInfo()/ServerInfo(),so it holds regardless of load ordering.
No local SourcePawn compiler available; relying on
plugin-buildCI.🤖 Generated with Claude Code