summaryrefslogtreecommitdiff
path: root/src/network
AgeCommit message (Collapse)Author
2021-05-13Codechange: move hostnames in settings to std::stringrubidium42
2021-05-13Codechange: move passwords in settings to std::stringrubidium42
2021-05-13Change: further support for std::string in settingsrubidium42
2021-05-13Codechange: [Network] split CloseSocket and CloseConnection more clearly (#9261)Patric Stout
* Codechange: [Network] split CloseSocket and CloseConnection more clearly - CloseSocket now closes the actual OS socket. - CloseConnection frees up the resources to just before CloseSocket. - dtors call CloseSocket / CloseConnection where needed.
2021-05-13Codechange: remove pointless close call due to resolving virtual functions ↵Rubidium
statically in destructors In the destructors of many of the network related classes Close() is called, just like the top class in that hierarchy. However, due to virtual functions getting resolved statically in the destructor it would always call the empty Close() of the top class. Document the other cases where a virtual call is resolved statically.
2021-05-13Fix #9255: [Network] TCPConnecter crashes when hostname not found (#9259)Patric Stout
2021-05-12Change: reworked the debug levels for network facility (#9251)Patric Stout
It now follows very simple rules: 0 - Fatal, user should know about this 1 - Error, but we are recovering 2 - Warning, wrong but okay if you don't know 3 - Info, information you might care about 4 - 5 - Debug #1 - High level debug messages 6 - Debug #2 - Low level debug messages 7 - Trace information
2021-05-11Fix: [Network] mark server as offline when no longer reachable (#9244)Patric Stout
2021-05-11Fix #9243: [Network] For a dedicated server use a fallback client and server ↵rubidium42
name Also warn when the client or server name has not been set and provide pointers on how to set them
2021-05-11Fix: [Network] don't rebuild the host-list during iterating the list (#9240)Patric Stout
Additionally, only rebuild it when we added a new manual server, as otherwise it is a noop anyway.
2021-05-11Fix: [Network] don't mark the last-joined server as manual (#9239)Patric Stout
2021-05-11Fix: [Network] clients leaving because of broken connections was not ↵Patric Stout
broadcasted (#9238) The code mixed up "client has quit but we already told everyone" with "client lost connection, handle this". Split up those two signals: - CLIENT_QUIT means we told everyone and the connection is now dead - CONNECTION_LIST means we should tell everyone we lost a client
2021-05-10Fix: leaking file descriptorsRubidium
2021-05-10Change: reworded many of the network errors during connect/listen (#9230)Patric Stout
Also changed some levels to 0, as a failing listen() is something we should tell the user about. Hiding this information is a bit evil.
2021-05-09Fix: lobby window doesn't close if no connection could be established (#9223)Patric Stout
2021-05-08Fix: only query a manually added server if it isn't there yetPatric Stout
But always mark it as manually, no matter if it was there or not.
2021-05-08Fix: don't do a network disconnect between two queriesPatric Stout
This meant that on opening the Multiplayer window, if you had more than one server configured, it would one by one cancel all pending queries and send a new. Result: only the last server was updated.
2021-05-08Fix: destroying a TCPConnecter that was still resolving made illegal writesPatric Stout
Basically, we should join the resolve thread before we destruct the object.
2021-05-08Codechange: move connection_string to private for TCPConnecterPatric Stout
The most common case never needs access to it anymore. Make the one exception to this explicit. This means the fact that we store it is now an implementation detail.
2021-05-08Change: Use gender-neutral pronouns in console command messages (and ↵William Davis
comments) (#9203)
2021-05-08Fix f7e390bd: getpeername() doesn't work on closed sockets (#9213)Patric Stout
2021-05-08Codechange: [Network] Change ChatMessage's message to std::string and ↵rubidium42
simplify some code
2021-05-06Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)Patric Stout
Hostnames like "content.openttd.org" resolve into multiple IPv4 and IPv6. It is possible that either of the IPs is not working, either due to a poorly configured OS (having IPv6 but no valid route), broken network paths, or a service that is temporary unavailable. Instead of trying the IPs one by one, waiting for a 3s timeout between each, be a bit more like browsers, and stack attempts on top of each other with slight delays. This is called Happy Eyebells. Initially, try the first IPv6 address. If within 250ms there is no connection yet, try the first IPv4 address. 250ms later, try the second IPv6 address, etc, till all addresses are tried. If any connection is created, abort all the other (pending) connections and use the one that is created. If all fail 3s after the last connect(), trigger a timeout for all.
2021-05-06Codechange: [Network] Use std::string for NetworkGameInforubidium42
2021-05-06Codechange: [Network] Move connection string parsing away from C-stringsrubidium42
2021-05-06Codechange: [Network] Use std::string for NetworkAddress' host namerubidium42
2021-05-06Codechange: [Network] Use new/delete instead of calloc/free for NetworkGameListrubidium42
2021-05-05Codechange: use connection_string in favour of NetworkAddress (#9197)Patric Stout
We now resolve the connection_string to a NetworkAddress in a much later state. This means there are fewer places constructing a NetworkAddress. The main benefit of this is in later PRs that introduce different types of NetworkAddresses. Storing this in things like NetworkGameList is rather complex, especially as NetworkAddress has to be mutable at all times. Additionally, the NetworkAddress is a complex object to store simple information: how to connect to this server.
2021-05-05Cleanup: [Network] Remove variable from NetworkGameInfo that is only used ↵Rubidium
during deserialisation
2021-05-05Change: [Network] Update server's NetworkServerGameInfo only when neededrubidium42
Split the updating in a "static" version that only needs to be called when a new map is loaded or some settings are changed, and a "dynamic" version that updates everything that changes regularly such as the current game date or the number of spectators.
2021-05-05Codechange: [Network] Use a single NetworkServerGameInfo object at server ↵rubidium42
side and serialize that for the clients
2021-05-03Add: [Network] Reading std::string from a packetrubidium42
2021-05-03Add: [Network] Writing std::string to a packetrubidium42
2021-05-02Fix: [Network] Reading beyond the length of the server's ID when hashing ↵rubidium42
password Under normal circumstances the server's ID is 32 characters excluding '\0', however this can be changed at the server. This ID is sent to the server for company name hashing. The client reads it into a statically allocated buffer of 33 bytes, but fills only the bytes it received from the server. However, the hash assumes all 33 bytes are set, thus potentially reading uninitialized data, or a part of the server ID of a previous game in the hashing routine. It is still reading from memory assigned to the server ID, so nothing bad happens, except that company passwords might not work correctly.
2021-05-01Codechange: move some OS abstraction method implementations out of the headerrubidium42
2021-05-01Codechange: encapsulate network error handlingrubidium42
2021-05-01Codechange: rename NetworkError to ShowNetworkErrorrubidium42
2021-05-01Fix #6598: Prevent invalid memory accesses when abandoning a join from ↵rubidium42
within a network game One could join a network game from within an already running network game. This would call a NetworkDisconnect, but keeps the UI alive. If, during that process the join is aborted, e.g. by cancelling on a password dialog, you would still be in your network game but also get shown the server list. Solve all the underlying problems by falling back to the main UI when (re)connecting to a(nother) server.
2021-05-01Codechange: Move join information into a single structurerubidium42
2021-05-01Change: [Console] Show help when passing invalid company numberrubidium42
2021-04-30Fix: Recalculate padding and minimum sizes when GUI or Font zoom is changed.Peter Nelson
2021-04-30Change: use TCP for everything except for master-server and initial server ↵Patric Stout
scan (#9130) This means that pressing Refresh button and adding servers manually now uses TCP. The master-server and initial scan are still UDP as they will be replaced by Game Coordinator; no need to change this now. If we query a server that is too old, show a proper warning to the user informing him the server is too old.
2021-04-29Change: [Network] Encapsulate logic about the connection string to the ↵rubidium42
network code (#23)
2021-04-29Codechange: use NetworkAddress instead of two host/port variables where possiblePatric Stout
This also means we no longer need last_host/last_port, but can just use a single last_joined setting.
2021-04-29Codechange: use std::string over stack-based strings if possiblePatric Stout
2021-04-29Cleanup: remove write-only variable "hostname" in NetworkGameListPatric Stout
2021-04-29Fix: [MinGW] Set minimum OS version to Windows XP (#9135)Loïc Guilloux
2021-04-28Fix b3003dd1: swap SERVER_GAME_INFO with CLIENT_GAME_INFO (#9129)Patric Stout
The idea is that if you query an older server that does not support this packet yet, the client receives an error. The assumption was that on every "illegal packet" the connection would be closed. This turns out to be false. Now CLIENT_GAME_INFO aligns with the old PACKET_CLIENT_NEWGRFS_CHECKED, which does a pre-check (which fails), and an error is sent back and the connection is closed. This is not a nice solution, but it is the best we got.
2021-04-27Fix: missing <limits> include in network/core/packet.h (#9123)Milek7
2021-04-27Change: no longer use UDP when entering the lobby of a serverPatric Stout
The lobby of a server requested some parts via UDP and some via TCP. This is strictly seen fine, but for future extensions it is a lot easier if just one protocol is used.