Commit Graph

57 Commits

Author SHA1 Message Date
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Peter Nelson c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Peter Nelson 72018badff Codechange: Swap SocketList map key/value around.
This map is used store socket and address together, and, other than
checking that the address does not already have a socket, the data layout
does not seem particularly important.

However, as address is the key, technically it should not be modified,
and address may self-modify itself during comparisons.
2023-05-18 12:18:30 +01:00
Rubidium 68ff3fd062 Change: include fmt.h C++ headers in stdafx.h
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Patric Stout 8adade26ed Feature: allow the use of STUN to connect client and server together
This method doesn't require port-forwarding to be used, and works for
most common NAT routers in home setups. But, for sure it doesn't work
for all setups, and not everyone will be able to use this.
2021-07-16 19:50:29 +02:00
Patric Stout 1baec41542 Change: groundwork to allow ServerAddress to use invite codes
Normally TCPConnecter will do a DNS resolving of the connection_string
and connect to it. But for SERVER_ADDRESS_INVITE_CODE this is different:
the Game Coordinator does the "resolving".

This means we need to allow TCPConnecter to not setup a connection
and allow it to be told when a connection has been setup by an external
(to TCPConnecter) part of the code. We do this by telling the (active)
socket for the connection.

This means the rest of the code doesn't need to know the TCPConnecter
is not doing a simple resolve+connect. The rest of the code only
cares the connection is established; not how it was established.
2021-07-11 20:38:42 +02:00
Patric Stout cee8174d02 Codechange: track servers with a ServerAddress instead of a NetworkAddress
This allows future extensions to have different ways of referencing
a server, instead of forcing to use IP:port.
2021-07-11 20:38:42 +02:00
rubidium42 667301e3ec Codechange: [Network] Make hostname/client IP return strings instead of a C-string 2021-06-15 06:13:00 +02:00
rubidium42 a91e29b656 Codechange: [Network] Let IsInNetmask use std::string 2021-06-15 06:13:00 +02:00
rubidium42 36705f1dc0 Codechange: [Network] Simplify formatting of network addresses to string 2021-06-15 06:13:00 +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 6c4a65eeb8 Codechange: [Network] Use std::string for NetworkAddress' host name 2021-05-06 20:33:26 +02:00
Jonathan G Rennison 1ac0d4a5b2 Fix: Thread unsafe use of NetworkAddress::GetAddressAsString
Remove static buffer form of NetworkAddress::GetAddressAsString.
This is used in multiple threads concurrently, and is not thread-safe.

Replace it with a form returning std::string.
2020-06-21 11:47:56 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Charles Pigott 71a3e83468 Fix: GCC9's warnings about deprecated implicit assignment operators 2019-09-30 14:00:06 +01:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Michael Lutz e804173595 Codechange: If something is a vector of strings, use a vector of strings instead of an AutoFreeSmallVector. 2019-04-09 22:45:15 +02:00
Henry Wilson cc62f4163f Cleanup: Remove unused size template parameters from SmallMap and Auto[Free|Delete]SmallVector 2019-03-26 20:15:57 +00:00
Henry Wilson c01a2e2a81 Codechange: Removed SmallVector completely 2019-03-26 20:15:57 +00:00
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 19:24:55 +01:00
rubidium 289133be14 (svn r22695) -Fix [FS#4697]: mark addresses that could not be resolved as 'do not resolve anymore' as well, instead of trying to resolve them each and every time the address is accessed 2011-07-30 10:28:52 +00:00
rubidium 99ec3a044a (svn r22403) -Document: some more network/core code 2011-05-01 13:29:40 +00:00
rubidium eb299736c1 (svn r21886) -Codechange: move documentation towards the code to make it more likely to be updated [n]. 2011-01-22 09:53:15 +00:00
alberth 7303f7d199 (svn r21595) -Codechange: Some header files had their name changed, update the ifndef/define/endif lines. 2010-12-22 11:46:41 +00:00
smatz 0ef33548c2 (svn r19614) -Codechange: "it's" => "its" where appropriate 2010-04-12 14:12:47 +00:00
rubidium 5ff6053326 (svn r17699) -Codechange: move #ifdef ENABLE_NETWORK till after the 'generic' includes so compilation without network support doesn't get broken as easily by changes in header files 2009-10-04 20:00:56 +00:00
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 2009-08-21 20:21:05 +00:00
rubidium 951b9e7615 (svn r16238) -Change: improve/clarify some network related debug "error" messages by adding more information to them. Also give some clues on how to fix certain issues (like failing advertising). 2009-05-06 09:52:52 +00:00
rubidium 5db32d1dc5 (svn r16134) -Change: do not add duplicates to the broadcast list 2009-04-24 10:33:16 +00:00
rubidium d04ebf2fa5 (svn r16065) -Fix: don't readd (and resolve) the last joined server each time the window gets repainted 2009-04-15 20:37:00 +00:00
rubidium 47e2901e18 (svn r16034) -Fix: compile warnings generated by 64 bits MSVC. 2009-04-11 20:26:25 +00:00
rubidium 460fbc7c92 (svn r16007) -Fix (r16004): when we want to bind to both IPv4 and IPv6, make the master socket do that too; too bad getaddrinfo can't handle binding to any address on any port at the same time :( 2009-04-10 09:23:35 +00:00
rubidium c0f9af5607 (svn r16000) -Feature: IPv6 support 2009-04-09 01:22:45 +00:00
rubidium 882e495f5c (svn r15993) -Codechange: clean up/generalise the handling of the server list 2009-04-08 23:41:48 +00:00
rubidium 0f0cc67d62 (svn r15990) -Codechange: provide a thread safe variant of GetAddressAsString. 2009-04-08 21:11:16 +00:00
rubidium 9d6edae94d (svn r15981) -Fix: don't print the address family when writing the IP+port to the config file. 2009-04-08 12:09:07 +00:00
rubidium a5a424ce28 (svn r15978) -Codechange: support parsing [] enclosed IPv6 addresses. 2009-04-08 01:22:57 +00:00
rubidium 1eb4aa971e (svn r15975) -Codechange: register each of the IPs we have bound to to the masterserver 2009-04-08 00:26:49 +00:00
rubidium c0f8214218 (svn r15972) -Codechange: remove unneeded parameter 2009-04-08 00:03:05 +00:00
rubidium 6db7f15b3a (svn r15970) -Codechange: make it possible to resolve a single address into multiple sockets. 2009-04-07 19:52:01 +00:00
rubidium 82f8badc07 (svn r15969) -Codechange: make the list of broadcast addresses virtually unlimited. 2009-04-07 19:06:36 +00:00
rubidium fdddfd6269 (svn r15968) -Codechange: do not allocate a buffer for NetworkAddresses so passing it around is easier. 2009-04-07 19:04:37 +00:00
rubidium edfc2e536e (svn r15954) -Fix: comparing addresses kinda fails (sometimes) causing duplicates in the game list 2009-04-04 13:09:36 +00:00
rubidium a779611665 (svn r15948) -Fix: resolve network addresses before comparing them 2009-04-04 01:51:32 +00:00
rubidium 2fd9f0fffa (svn r15946) -Codechange: move netmask matching to NetworkAddress and add some support for IPv6 netmask matching. 2009-04-04 00:47:08 +00:00
rubidium ce06df313d (svn r15941) -Codechange: jonty-comp's wish partly implemented (content server) ;) 2009-04-03 17:20:57 +00:00
rubidium e05e1822d6 (svn r15935) -Codechange: function to compare IP addresses (to sort them) 2009-04-03 15:42:41 +00:00
rubidium 11723c40b2 (svn r15926) -Codechange: make the broadcast IP list less AF dependent. 2009-04-03 11:02:41 +00:00
rubidium dccfba6e20 (svn r15924) -Codechange: replace NetworkResolveHost with something less AF dependant. 2009-04-03 09:07:16 +00:00
rubidium 632d74c6b1 (svn r15922) -Codechange: unify the ways to listen on a socket 2009-04-03 01:24:52 +00:00