730 Commits

Author SHA1 Message Date
Cthulhu-throwaway
b0928cd0f8
[Netplay] Disable savestates on stateless mode (#13634)
Stateless mode is currently not working correctly and still using savestates.
2022-02-18 17:08:18 +01:00
Cthulhu-throwaway
cd74221d33
[Networking] GetBestRoute refactor (#13553)
Refactor to support UWP.
2022-01-27 11:38:31 +01:00
Cthulhu-throwaway
b71be7efd2
(Netplay/LAN Discovery) Disable GetBestRoute for UWP (#13518) 2022-01-20 14:52:11 +01:00
Cthulhu-throwaway
0c0d19e3f1 (Netplay) Fix dummy notification
No longer shows a netplay initialization failed notification when netplay is not enabled.
2022-01-13 01:49:51 +01:00
Cthulhu-throwaway
4dda10b86d
(Netplay) Disable netplay on init failure (#13479)
* (Netplay) Disable netplay on init failure

Make sure netplay is disabled and properly deinitialized after an initialization failure.

* missing comma
2022-01-11 13:50:09 +01:00
Cthulhu-throwaway
4cf1bcf70f
(Netplay/UPnP) Delay lobby server announcing (#13473)
Delay the announcing in order to give UPnP's port forwarding more time.

Fix the remaining truncation warnings.
2022-01-11 08:48:59 +01:00
twinaphex
18dae9ce73 remove unused variables 2021-12-27 19:57:32 +01:00
Autechre
68713b46b0
Revert "Netplay clean-up (#13421)" (#13422)
This reverts commit 5efd2a64a483995cbf1bd5dc9daabbce5e8f5d94.
2021-12-26 16:54:19 +01:00
Cthulhu-throwaway
5efd2a64a4
Netplay clean-up (#13421) 2021-12-26 16:30:38 +01:00
Cthulhu-throwaway
9579810579
Build fix for --disable-menu (#13419) 2021-12-26 15:18:57 +01:00
Cthulhu-throwaway
26132a2330
Netplay and NAT struct improvements (#13416)
Reordered netplay and NAT structs to follow the coding guidelines more closely.

Moved part of the chat struct out of the program's image and into the heap.
2021-12-25 13:42:22 +01:00
Cthulhu-throwaway
9e208198f2
Endianness fix for netplay_is_lan_address (#13413) 2021-12-25 04:07:55 +01:00
Cthulhu-throwaway
98bed89d6f
Netplay custom relay server to use default port (#13411)
Allow the custom server to use the default port if a port was not provided.
2021-12-25 02:30:33 +01:00
Cthulhu-throwaway
6a100272a8
Netplay spectator notification fix (#13409)
Fix double notification when the host switches to spectator.
2021-12-24 16:42:16 +01:00
Cthulhu-throwaway
736ab4c964
MSVC 2005 build fix (#13408) 2021-12-24 14:58:18 +01:00
Cthulhu-throwaway
b67b93ebfe
Enable GetBestRoute for MSVC 2005 (#13407) 2021-12-24 14:15:20 +01:00
Cthulhu-throwaway
ec97c86756
Attempt to fix UPnP for some Windows devices (#13402)
Yet another attempt at it.
2021-12-23 23:52:01 +01:00
Cthulhu-throwaway
c6369b7861
MSVC 2005 Build Fix (#13401) 2021-12-23 22:08:13 +01:00
Cthulhu-throwaway
c4049b9597
NAT and netplay Fixes (#13400)
* NAT and netplay Fixes

Fix a crash when announcing your room to the internet without being in a tunnel.

Fix improper interface for UPnP for some Windows devices.

* Final edits
2021-12-23 21:28:30 +01:00
Cthulhu-throwaway
c752f9b0de
Custom relay server support (#13395)
* Custom relay server support

Add support for custom user-ran relay servers.

* snprintf NULL fix
2021-12-23 13:54:52 +01:00
Cthulhu-throwaway
b9041995f0
Add asian relay server (#13393)
Replace the canadian server with an asian one.
2021-12-22 16:33:41 +01:00
Cthulhu-throwaway
eff6f41a38
Netplay protocol macro (#13391)
Wrap protocol checks inside of a guard macro.
2021-12-22 03:05:35 +01:00
Jamiras
3d84a9960e
(cheevos) check netplay status when unlocking achievements (#13379)
* check netplay status when unlocking achievements instead of permanently disabling them in spectate mode

* fix c89 build

* add RARCH_NETPLAY_CTL_IS_SPECTATING
2021-12-21 15:58:42 +01:00
Cthulhu-throwaway
966335e367
Smaller Netplay Changes (#13387)
Lobby Viewer: Filter out rooms that are not running RetroArch
Lobby Viewer: Display a non-connectable tag to non-connectable rooms.
Host: Display warning if we are announcing to the internet but our room isn't connectable from there.
2021-12-21 15:58:25 +01:00
Cthulhu-throwaway
568a30380b Buildfix for some platforms
Buildfix for some platforms that do not have HAVE_TRANSLATE defined aswell as platforms that define sockaddr_storage as sockaddr/sockaddr_in.
2021-12-20 14:26:50 +01:00
Cthulhu-throwaway
cae793e39f
Update netplay readme (#13380)
Fixes typos, removes outdated info and adds new commands for protocol 6.
2021-12-20 14:15:52 +01:00
Cthulhu-throwaway
cda66d09c3
Netplay Stuff - Addendum (#13378)
Prevents long-term pausing from clients dishonoring allow pausing.

Missing crediting.
2021-12-19 20:43:59 +01:00
Cthulhu-throwaway
690c802921
Netplay Stuff (#13375)
* Netplay Stuff

## PROTOCOL FALLBACK
In order to support older clients a protocol fallback system was introduced.
The host will no longer send its header automatically after a TCP connection is established, instead, it awaits for the client to send his before determining which protocol this connection is going to operate on.
Netplay has now two protocols, a low protocol and a high protocol; the low protocol is the minimum protocol it supports, while the high protocol is the highest protocol it can operate on.
To fully support older clients, a hack was necessary: sending the high protocol in the unused client's header salt field, while keeping the protocol field to the low protocol. Without this hack we would only be able to support older clients if a newer client was the host.
Any future system can make use of this system by checking connection->netplay_protocol, which is available for both the client and host.

## NETPLAY CHAT
Starting with protocol 6, netplay chat is available through the new NETPLAY_CMD_PLAYER_CHAT command.
Limitations of the command code, which causes a disconnection on unknown commands, makes this system not possible on protocol 5.
Protocol 5 connections can neither send nor receive chat, but other netplay operations are unaffected.
Clients send chat as a string to the server, and it's the server's sole responsability to relay chat messages.
As of now, sending chat uses RetroArch's input menu, while the display of on-screen chat uses a widget overlay and RetroArch's notifications as a fallback.
If a new overlay and/or input system is desired, no backwards compatibility changes need to be made.
Only clients in playing mode (as opposed to spectating mode) can send and receive chat.

## SETTINGS SHARING
Some settings are better used when both host and clients share the same configuration.
As of protocol 6, the following settings will be shared from host to clients (without altering a client's configuration file): input latency frames and allow pausing.

## NETPLAY TUNNEL/MITM
With the current MITM system being defunct (at least as of 1.9.X), a new system was in order to solve most if not all of the problems with the current system.
This new system uses a tunneling approach, which is similar to most VPN and tunneling services around.

Tunnel commands:
RATS[unique id] (RetroArch Tunnel Session) - 16 bytes -> When this command is sent with a zeroed unique id, the tunnel server interprets this as a netplay host wanting to create a new session, in this case, the same command is returned to the host, but now with its unique session id. When a client needs to connect to a host, this command is sent with the unique session id of the host, causing the tunnel server to send a RATL command to the host.
RATL[unique id] (RetroArch Tunnel Link) - 16 bytes -> The tunnel server sends this command to the host when a client wants to connect to the host. Once the host receives this command, it establishes a new connection to the tunnel server, sending this command together with the client's unique id through this new connection, causing the tunnel server to link this connection to the connection of the client.
RATP (RetroArch Tunnel Ping) - 4 bytes -> The tunnel server sends this command to verify that the host, whom the session belongs to, is still around. The host replies with the same command. A session is closed if the tunnel server can not verify that the host is alive.

Operations:
Host -> Instead of listening and accepting connections, it connects to the tunnel server, requests a new session and then monitor this connection for new linking requests. Once a request is received, it establishes a new connection to the tunnel server for linking with a client. The tunnel server's address and port are obtained by querying the lobby server. The host will publish its session id together with the rest of its info to the lobby server.
Client -> It connects to the tunnel server and then sends the session id of the host it wants to connect to. A host's session id is obtained from the json data sent by the lobby server.

Improvements (from current MITM system):
No longer a risk of TCP port exhaustion; we only use one port now at the tunnel server.
Very little cpu usage. About 95% net I/O bound now.
Future backwards compatible with any and all changes to netplay as it no longer runs any netplay logic at MITM servers.
No longer operates the host in client mode, which was a source of many of the current problems.
Cleaner and more maintainable system and code.

Notable functions:
netplay_mitm_query -> Grabs the tunnel's address and port from the lobby server.
init_tcp_socket -> Handles the creation and operation mode of the TCP socket based on whether it's host, host+MITM or client.
handle_mitm_connection -> Creates and completes linking connections and replies to ping commands (only 1 of each per call to not affect performance).

## MISC
Ping Limiter: If a client's estimated latency to the server is higher than this value, connection will be dropped just before finishing the netplay handshake.
Ping Counter: A ping counter (similar to the FPS one) can be shown in the bottom right corner of the screen, if you are connected to a host.
LAN Discovery: Refactored and moved to its own "Refresh Netplay LAN List" button.

## FIXES
Many minor fixes to the current netplay implementation are also included.

* Remove NETPLAY_TEST_BUILD
2021-12-19 16:58:01 +01:00
Autechre
3b1a1ac8da
Remove miniupnpc dependency (#13340)
* use custom libretro-common UPNP

* Remove miniupnpc
2021-12-09 05:52:42 +01:00
Autechre
fbbe351f7d
UPnP cleanups and refactorings (#13325) 2021-12-04 21:16:34 +01:00
twinaphex
bfeffb2423 Fix local header path includes 2021-12-04 16:11:02 +01:00
Autechre
a44f5bbf78
Fix UPNP port mapping failed error - switch to a permanent lease time, (#13324)
but request it to be removed when we do netplay_free
2021-12-04 15:45:29 +01:00
Autechre
b6695d8921
Netplay changes proposed for 1.9.14 (#13314)
* Added setting to allow/disallow players other than the host from pausing the game.
* Added a sublabel for netplay max connections.
* Fixed port override macro from not being set immediately after the port setting.
* Fixed memory leaks.
2021-12-04 02:34:21 +01:00
Jamiras
b6fef13109
disallow achievement when spectating netplay (#13318) 2021-12-04 02:00:53 +01:00
Autechre
5f49899343
Bluetooth refactor (#13266)
* Use HAVE_BLUETOOTH ifdef to strip out this code when not defined

* Split up bluetooth code into its own file
2021-11-21 20:44:08 +01:00
Autechre
71b30d7846
Split up wifi networking code - move it into separate file (#13262) 2021-11-21 12:37:39 +01:00
twinaphex
680b631ad6 Revert "(Netplay) Cthulhu88 - Remove forced disconnection on unknown netplay command -"
This reverts commit 65a421d90fa8050eb56767aa6b582fc63009ac02.
2021-11-12 19:08:34 +01:00
twinaphex
a6ed23d031 Revert "(cthulhu88) Add netplay chat command"
This reverts commit 6a490c03832a2d48607a99b17309faa46db0fa80.
2021-11-12 19:01:31 +01:00
twinaphex
efa16a8fca Revert "(Netplay) Cthulhu88 -"
This reverts commit cb4028fd3d770241100708c8fea66782cfa6b4de.
2021-11-12 19:00:42 +01:00
twinaphex
4025b678bf Revert "Add missing netplay_protocol.h"
This reverts commit 1fc73f11b55c8245ba0ef5912bddfff5b58c1291.
2021-11-12 19:00:33 +01:00
twinaphex
d7a8bc55a3 Revert "(Cthulhu88) Add netplay hotkey bind"
This reverts commit deaf116d38904f80bbcfa18f56bcf7f6560c6aa3.
2021-11-12 19:00:24 +01:00
twinaphex
3b6196144f Revert "Bump NETPLAY_PROTOCOL_VERSION up to 6"
This reverts commit 823c54a39d1e3b4e2293400d047840bc2b051aa5.
2021-11-12 19:00:16 +01:00
twinaphex
9c7a55352d Revert "(Cthulhu88) Netplay polishing patch"
This reverts commit 82b8c0a60efa727022a9d5fbdea57df5275f09c6.
2021-11-12 18:59:59 +01:00
twinaphex
62a8b13b1a Revert "(Cthulhu88) Netplay - initial netplay tunnel"
This reverts commit 369cafe1ad488eaec304fb12bc395ea7e34ca96d.
2021-11-12 18:59:52 +01:00
twinaphex
9fe56d6865 Revert "(Cthulhu88) Fix build errors of previous commit"
This reverts commit 393f9bdd484b3c31f480eec985cd822e838f0d6b.
2021-11-12 18:59:42 +01:00
twinaphex
753332ff18 Revert "(Cthulhu88) Fix for multi-char arrays"
This reverts commit e64cd247150de4cadaab62a574d219eef3fdbd84.
2021-11-12 18:59:35 +01:00
twinaphex
fc460dbb9c Revert "Fix final warning and remove unused variables"
This reverts commit 5dd0e90fca50787ce5010b027642dab3c1f18aef.
2021-11-12 18:59:29 +01:00
twinaphex
70ee3fbca7 Revert "(Cthulhu88) New Netplay MITM Part 2"
This reverts commit 34c374737c1c09497bf28af090a045656ac07bde.
2021-11-12 18:58:40 +01:00
twinaphex
34c374737c (Cthulhu88) New Netplay MITM Part 2 2021-11-12 06:31:54 +01:00
twinaphex
5dd0e90fca Fix final warning and remove unused variables 2021-11-11 05:48:29 +01:00