Commit Graph

1363 Commits

Author SHA1 Message Date
rubidium42 4d246cda73 Codechange: [Network] Let NetworkClientInfo use std::string 2021-05-16 10:07:51 +02:00
rubidium42 83679c0e57 Codechange: [Network] Use std::string to populate the client list for company stats 2021-05-16 10:07:51 +02:00
rubidium42 e90b2649b6 Codechange: [Network] Let NetworkCompanyInfo use std::string 2021-05-16 10:07:51 +02:00
rubidium42 fab120ee83 Codechange: [Network] Let chat communication use std::string 2021-05-15 10:20:50 +02:00
rubidium42 ae85af98eb Codechange: Use std::string GetString where convenient 2021-05-15 10:20:50 +02:00
rubidium42 e6703eac68 Codechange: [Network] Let NetworkTextMessage use std::string 2021-05-15 10:20:50 +02:00
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 2021-05-15 10:16:48 +02:00
Rubidium bb9121dbd4 Fix: comparison of narrow type to wide type in loop (potential for infinite loops) 2021-05-15 10:16:10 +02:00
Rubidium 031e91de6e Fix: [Network] Check on CIDR for netmask check considered everything valid 2021-05-15 10:16:10 +02:00
rubidium42 297d6e20bf Codechange: [Network] Pass passwords as std::string to the network code 2021-05-14 23:22:04 +02:00
rubidium42 ebe32ad912 Codechange: [Network] Use std::string for the internal handling of admin/rcon passwords 2021-05-14 23:22:04 +02:00
rubidium42 6db52d52d0 Codechange: [Network] Use std::string for the internal handling of server passwords 2021-05-14 23:22:04 +02:00
rubidium42 1de5cdeab8 Codechange: [Network] Use std::string for the internal handling of company passwords 2021-05-14 23:22:04 +02:00
rubidium42 98283116fa Codechange: [Network] Make company state password std::string 2021-05-14 23:22:04 +02:00
rubidium42 16437b7c0d Codechange: move client name in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 02fdb5b210 Codechange: move server name/id in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 cc6c078dec Codechange: move hostnames in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 c73d64adf9 Codechange: move passwords in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 f219354f89 Change: further support for std::string in settings 2021-05-13 23:13:17 +02:00
Patric Stout a403653805
Codechange: [Network] split CloseSocket and CloseConnection more clearly (#9261)
* 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-13 11:46:51 +02:00
Rubidium 187a3f20bf Codechange: remove pointless close call due to resolving virtual functions 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-13 10:03:26 +02:00
Patric Stout d7ce61f106
Fix #9255: [Network] TCPConnecter crashes when hostname not found (#9259) 2021-05-13 08:13:48 +02:00
Patric Stout b136e65cf9
Change: reworked the debug levels for network facility (#9251)
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-12 16:34:02 +02:00
Patric Stout d0eb3e4bc4
Fix: [Network] mark server as offline when no longer reachable (#9244) 2021-05-11 19:19:37 +02:00
rubidium42 0968d009c8 Fix #9243: [Network] For a dedicated server use a fallback client and server name
Also warn when the client or server name has not been set and provide pointers on how to set them
2021-05-11 19:09:04 +02:00
Patric Stout 9e7e87ce3e
Fix: [Network] don't rebuild the host-list during iterating the list (#9240)
Additionally, only rebuild it when we added a new manual server,
as otherwise it is a noop anyway.
2021-05-11 12:32:27 +02:00
Patric Stout 9841ebb0bd
Fix: [Network] don't mark the last-joined server as manual (#9239) 2021-05-11 12:26:30 +02:00
Patric Stout 36e22f3a7b
Fix: [Network] clients leaving because of broken connections was not 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-11 12:26:16 +02:00
Rubidium 495d73a67f Fix: leaking file descriptors 2021-05-10 16:03:31 +02:00
Patric Stout 8f4a612a7c
Change: reworded many of the network errors during connect/listen (#9230)
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-10 13:40:28 +02:00
Patric Stout 583011bca0
Fix: lobby window doesn't close if no connection could be established (#9223) 2021-05-09 18:48:21 +02:00
Patric Stout b9ab3bd6b3 Fix: only query a manually added server if it isn't there yet
But always mark it as manually, no matter if it was there or not.
2021-05-08 17:26:10 +02:00
Patric Stout fc91f1d1b2 Fix: don't do a network disconnect between two queries
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-08 17:26:10 +02:00
Patric Stout 1b75a29d12 Fix: destroying a TCPConnecter that was still resolving made illegal writes
Basically, we should join the resolve thread before we destruct
the object.
2021-05-08 17:26:10 +02:00
Patric Stout 664a8c3e85 Codechange: move connection_string to private for TCPConnecter
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-08 17:26:10 +02:00
William Davis 881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 2021-05-08 11:02:30 +01:00
Patric Stout f187708b3b
Fix f7e390bd: getpeername() doesn't work on closed sockets (#9213) 2021-05-08 11:57:41 +02:00
rubidium42 e2774354b4
Codechange: [Network] Change ChatMessage's message to std::string and simplify some code 2021-05-08 10:19:42 +02:00
Patric Stout f7e390bdc0
Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)
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-06 23:13:35 +02:00
rubidium42 f1dfa661a1 Codechange: [Network] Use std::string for NetworkGameInfo 2021-05-06 21:45:36 +02:00
rubidium42 3d91eee919 Codechange: [Network] Move connection string parsing away from C-strings 2021-05-06 20:33:26 +02:00
rubidium42 6c4a65eeb8 Codechange: [Network] Use std::string for NetworkAddress' host name 2021-05-06 20:33:26 +02:00
rubidium42 dcef3209a6 Codechange: [Network] Use new/delete instead of calloc/free for NetworkGameList 2021-05-06 20:33:26 +02:00
Patric Stout f94fb93779
Codechange: use connection_string in favour of NetworkAddress (#9197)
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-05 23:21:14 +02:00
Rubidium ead30dc725 Cleanup: [Network] Remove variable from NetworkGameInfo that is only used during deserialisation 2021-05-05 21:01:23 +02:00
rubidium42 e7581fd42d Change: [Network] Update server's NetworkServerGameInfo only when needed
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-05 21:01:23 +02:00
rubidium42 72bd62fd70 Codechange: [Network] Use a single NetworkServerGameInfo object at server side and serialize that for the clients 2021-05-05 21:01:23 +02:00
rubidium42 7bcc472f73 Add: [Network] Reading std::string from a packet 2021-05-03 17:56:05 +02:00
rubidium42 ba409e8c45 Add: [Network] Writing std::string to a packet 2021-05-03 17:56:05 +02:00
rubidium42 56aa6d0edd Fix: [Network] Reading beyond the length of the server's ID when hashing 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-02 11:51:28 +02:00