Skip to content

fxed \r errors#121

Open
KixtNorkazz wants to merge 2 commits intoxtjoeytx:masterfrom
KixtNorkazz:master
Open

fxed \r errors#121
KixtNorkazz wants to merge 2 commits intoxtjoeytx:masterfrom
KixtNorkazz:master

Conversation

@KixtNorkazz
Copy link
Copy Markdown

I fixed \r errors that were in the .txt files, which made it hard for GServers on Linux to get clients from other systems to connect.

…ings

and .gitattributes typo ('test' instead of 'text'). There is also a bug in dependencies/gs2lib/src/CSettings.cpp. CSettings::getSettings() was explicitly converting line endings to CRLF
before saving, causing localip to be read as '10.x.x.x\r' which fails validation silently. Servers appear on the serverlist but clients cannot connect. I fixed the file by commenting out 'options.replaceAllI(n, rn);'
…ings

and .gitattributes typo ('test' instead of 'text'). There is also a bug in dependencies/gs2lib/src/CSettings.cpp. CSettings::getSettings() was explicitly converting line endings to CRLF
before saving, causing localip to be read as '10.x.x.x\r' which fails validation silently. Servers appear on the serverlist but clients cannot connect. I fixed the file by commenting out 'options.replaceAllI(n, rn);'
@xx-shitai-xx
Copy link
Copy Markdown
Collaborator

  1. master branch is not the focus, all new work is being done in the beta4 branch currently
  2. changing the newline in the text files rather than doing a fix in code is patching a symptom rather than fixing at source
  3. I don't know why you're having issues, the master branch has had clients from Windows connect to Linux servers for years without issue, so please explain what is happening and file a proper bug report instead.
  4. Have you tested if the issue exists in the beta4 branch?
    @KixtNorkazz

@KixtNorkazz
Copy link
Copy Markdown
Author

KixtNorkazz commented Mar 15, 2026

Thanks for the clarification. To answer your questions:

  1. The bug is specifically that Linux-hosted servers appear on the serverlist but clients cannot connect. The issue is not Windows clients connecting to Linux servers in general.

  2. What I experienced after setting up a fresh GServer-v2 (master) on Gentoo Linux, the server appeared on the serverlist but clients on a separate system (Windows) on the same LAN could not connect. They received "connection couldn't be established" The server log showed no login attempts at all when clients tried to connect to it either.
    After manually removing \r\n from serveroptions.txt with sed -i 's/\r//', client could connect successfully. However after a client logged in and the server was shut down, the ^M carriage returns had reappeared in serveroptions.txt, that I confirmed with cat -A. Tracing the cause to CSettings::getSettings() in gs2lib explicitly calls options.replaceAllI("\n", "\r\n") before saving, which rewrites the config with Windows line endings on every save. This causes localip to be read as x.x.x.x\r with a trailing carriage return. This corrupted value passes validation in TServerList.cpp and gets sent to the listserver, which then hands it out to connecting clients as the address to connect to. Since x.x.x.x\r is not a valid IP address, clients cannot establish a connection. The workaround that confirmed the bug was chmod 444 on serveroptions.txt, preventing the server from rewriting it, after which clients could connect consistently. I commented out the part in the source code (// options.replaceAllI("\n", "\r\n"); ) before compiling a new version of the server with the line commented out and did not experience this challenge after.

  3. Regarding beta4: I confirmed the bug is already fixed, CSettings::getSettings() no longer exists in beta4, the settings system has been rewritten and doesn't save back to disk. However, the config files in the beta4 repo still ship with \r\n line endings, so a fresh Linux clone still starts with broken config files. All I find that might be something is in the .gitattributes: bin/servers/** binary is still there, which means the config files are still treated as binary and won't get LF conversion even with * text=auto

@LoneBoco
Copy link
Copy Markdown
Collaborator

I think that this is better fixed in the gs2lib. I've checked and the handling of \r in the CSettings class is very poor and could even be an issue in the beta4 branch. I'll fix the CSettings stuff myself. It won't be an issue in the beta4 branch much longer, though, as I've been working on replacing CSettings with something much better.

@KixtNorkazz
Copy link
Copy Markdown
Author

I think that this is better fixed in the gs2lib. I've checked and the handling of \r in the CSettings class is very poor and could even be an issue in the beta4 branch. I'll fix the CSettings stuff myself. It won't be an issue in the beta4 branch much longer, though, as I've been working on replacing CSettings with something much better.

While investigating further, I also noticed TPlayerRC.cpp line 318 has the same pattern as CSettings:
folders.replaceAllI("\n", "\r\n");
This writes foldersconfig.txt with Windows line endings on every save. The grep output also shows the codebase is inconsistent overall, some read paths defensively strip \r with removeAllI("\r"), while some write paths explicitly add \r\n, and others just pass through whatever they received.
Hope this helps you all :)

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.

3 participants