722 Commits

Author SHA1 Message Date
Dylan K. Taylor
1ef538b69e LoginSessionHandler: fix crash when disconnected during login handling 2018-07-31 19:40:24 +01:00
Dylan K. Taylor
32a78e679a Fixed JWT padding 2018-07-31 18:36:36 +01:00
Dylan K. Taylor
488c03c200 Make timings for player network more detailed 2018-07-31 16:34:15 +01:00
Dylan K. Taylor
2bf6764112
Implemented network encryption (#2343)
For those who fuss about performance, you can disable the `network.enable-encryption` option to use sessions without encryption.
2018-07-31 15:54:18 +01:00
Dylan K. Taylor
bdd42d6a78 Added NetworkSession->sendEncoded(), clean up some code 2018-07-27 18:39:14 +01:00
Dylan K. Taylor
2647b3f404 VerifyLoginTask: remove unnecessary wordwrap()
I don't recall why this was needed, but it's not.
2018-07-27 18:33:10 +01:00
Dylan K. Taylor
7541a6070f Player: clean up handling of authentication 2018-07-27 18:04:13 +01:00
Dylan K. Taylor
c3bc751b04 Merge branch 'release/3.2' 2018-07-26 16:00:46 +01:00
Dylan K. Taylor
b3f2396ea5 UPnP: Make error message less useless 2018-07-26 16:00:35 +01:00
Dylan K. Taylor
98b34aaac8 Merge remote-tracking branch 'origin/release/3.2' 2018-07-25 15:51:39 +01:00
Dylan K. Taylor
706c620d04
Move Internet-related functions from Utils into their own class (#2324)
- Added `Internet::getIP()`, `Internet::getURL()`, `Internet::postURL()`, and `Internet::simpleCurl()`.
- Deprecated the corresponding functions in `Utils`. Updating to the new functions is as simple as replacing `Utils` with `Internet`, since this doesn't break backwards compatibility.

The deprecations should be catered for by plugin developers. These deprecated redirects will be removed no later than 4.0.0.
2018-07-25 15:51:18 +01:00
Dylan K. Taylor
622fe99982 NetworkSession: Don't crash on failure to decode compressed batches
this could be an outdated version (pre-1.1 for example).
2018-07-23 14:38:46 +01:00
Dylan K. Taylor
cc84ec8629 Fixed Player/NetworkSession/SessionHandler cycle memory leak
NetworkSession and some SessionHandlers hold cyclic refs to each other, stopping them getting destroyed. Unfortunately, these also reference the player, stopping that getting destroyed too.

The cycle garbage collector will deal with this, but it's best to get rid of the cyclic refs for immediate collection.
2018-07-22 13:41:06 +01:00
Dylan K. Taylor
85105ed066 Inseparable set of network changes - these all need each other to work
- Separated player handling and creation from network interfaces
- Rewire disconnects to make them not be recursive
- Batching now uses sessions instead of players
- Fixed DisconnectPacket getting sent to players who disconnect of their own accord
2018-07-21 20:03:05 +01:00
Dylan K. Taylor
a86d3fe071 PlayerCreationEvent: Remove useless crap from constructor 2018-07-21 18:42:18 +01:00
Dylan K. Taylor
b93318b2cf RakLibInterface: Use NetworkSession API for getting IP instead of Player
soon the network interfaces won't be dealing with Players at all.
2018-07-21 18:41:15 +01:00
Dylan K. Taylor
ca1a0c8643 Move responsibility for ping handling to NetworkSession 2018-07-21 16:33:12 +01:00
Dylan K. Taylor
57e5b1309d NetworkSession: Stop processing batch if player gets disconnected during handling 2018-07-21 16:27:30 +01:00
Dylan K. Taylor
34d64be427 CompressBatchedTask: players aren't strings 2018-07-21 16:10:25 +01:00
Dylan K. Taylor
c5bf746e4c typo 2018-07-21 14:45:22 +01:00
Dylan K. Taylor
7d8624b12f ResourcePacksSessionHandler: clean up error reporting 2018-07-21 14:44:54 +01:00
Dylan K. Taylor
da876cc8f3 ResourcePacksSessionHandler: Prevent clients requesting the same chunk more than once
Currently this can be used to attack the server by spamming requests for the same chunks forever. This commit prevents that by disconnecting the client if a chunk is requested more than 1 time. It is not necessary to allow more than 1 request per chunk, since RakNet should ensure that these are always delivered correctly.
2018-07-21 14:31:34 +01:00
Dylan K. Taylor
d6e61e3e00 ResourcePacksSessionHandler: Account for out-of-bounds chunk requests 2018-07-21 14:19:24 +01:00
Dylan K. Taylor
b9cd96f6e0 ResourcePacksSessionHandler: remove useless brackets 2018-07-21 13:36:20 +01:00
Dylan K. Taylor
c257a791e1 ResourcePacksSessionHandler: move max pack chunk size to const 2018-07-21 09:37:15 +01:00
Dylan K. Taylor
59f6821c29 Allow parameterizing ResourcePackManager to session handler
this will open the way (in the future) for custom managers to be used, instead of a global thing.
2018-07-20 20:08:12 +01:00
Dylan K. Taylor
30c044f028 Unwrap more code from packet handlers 2018-07-20 18:48:46 +01:00
Dylan K. Taylor
015ee90571 Split PlayerActionPacket handling into two classes, death is now a session state 2018-07-20 18:11:29 +01:00
Dylan K. Taylor
f626b9e8a0 Initial mass migration to session handlers
This introduces several new session handlers, splitting up session handling into several new states:

- Login: Only allows handling the LoginPacket. This is the only time LoginPacket can be sent, and it'll be discarded when sent at any other time.
- Resource packs: Handles only the resource packs sequence (downloading packs and such). This is the only time ResourcePackClientResponse and ResourcePackChunkRequest will be handled.
- Pre-spawn: Only chunk radius requests are accepted during this state.

SimpleNetworkHandler handles all the "rest" of the logic that hasn't yet been separated out into their own dedicated handlers. There's also a NullNetworkHandler which discards all packets while it's active.

This solves a large number of issues with the security of the login sequence. It solves a range of possible DoS attacks and crashes, while also allowing great code simplification and cleanup.
2018-07-20 17:09:04 +01:00
Dylan K. Taylor
3cd105ff33 Remove remnants of needACK functionality
this has been broken for a long time and hasn't been used for even longer.
2018-07-20 13:07:06 +01:00
Dylan K. Taylor
57a86d9ed7 Player: remove useless InteractPacket handler
all the things we cared about in here don't exist anymore, so there's no sense in the handler still existing. It can be restored when we want to use the things it still does.
2018-07-20 12:39:48 +01:00
Dylan K. Taylor
25cfcada26 Player: clean up container close handling 2018-07-20 12:36:44 +01:00
Dylan K. Taylor
e16f20affa NetworkSession: added getHandler() and setHandler(), SessionHandler->setUp() now not useless 2018-07-20 12:36:44 +01:00
Dylan K. Taylor
08621604cd PacketPool: remove redundant comment
this was added to signify that these were normal, while BatchPacket was a hack. Since this has now been corrected, there's no need for the comment.
2018-07-20 12:36:44 +01:00
Dylan K. Taylor
cdcafb1e75 PacketPool: Properly deal with varint packet IDs now that BatchPacket is gone 2018-07-20 12:36:44 +01:00
Dylan K. Taylor
64ecc373be Split up session base logic and packet handling
this will allow for mutable packet handlers which can be used to cleanly implement multi-stage game sessions.
2018-07-20 12:36:44 +01:00
Dylan K. Taylor
bdd9a7eb52 Kill BatchPacket, clean up batching related things
DataPacketSendEvent and DataPacketReceiveEvent will no longer capture BatchPackets
In most places strings are now used instead of DataPackets, to remove limitations on what data can be sent to a network interface
Removed CraftingManager's cyclic dependency on Server

There is a lot more work to do aside from this, but this commit is intended to clean up what is necessary to fix the handling of BatchPacket.
2018-07-20 12:36:44 +01:00
Dylan K. Taylor
85647c03bf Move IP/port to NetworkSession 2018-07-20 12:36:43 +01:00
Dylan K. Taylor
f969f3b77f Flatten NetworkSession hierarchy in preparation for refactor 2018-07-20 12:36:43 +01:00
Dylan K. Taylor
424e9f4a49 Merge branch 'release/3.2' 2018-07-20 11:30:46 +01:00
Dylan K. Taylor
dd8499e202 Merge branch 'release/3.0' into release/3.1 2018-07-20 11:30:27 +01:00
Dylan K. Taylor
124ebf69c5 PlayStatusPacket: default to current protocol if not specified 2018-07-20 11:29:40 +01:00
Dylan K. Taylor
36e197e2a9 Move more session logic out of Player 2018-07-18 12:48:58 +01:00
Dylan K. Taylor
4d1e2d1b3a Rename SourceInterface -> NetworkInterface
SourceInterface doesn't make sense really...
2018-07-18 11:03:21 +01:00
Dylan K. Taylor
965f0d670d Improve documentation of SourceInterface and AdvancedSourceInterface 2018-07-18 11:01:16 +01:00
Dylan K. Taylor
bc9a387b0b Fixed merge error 2018-07-17 18:46:27 +01:00
Dylan K. Taylor
df3870a112 Merge branch 'release/3.2' 2018-07-17 18:35:43 +01:00
Dylan K. Taylor
165aac1ba3 Merge branch 'release/3.0' into mc-broken-ed-1.5 2018-07-14 16:09:57 +01:00
Dylan K. Taylor
25022b3144 Merge branch 'release/3.1' 2018-07-13 12:38:41 +01:00
Dylan K. Taylor
65e44364e5 Added some debug for raw packets and Query handling 2018-07-13 10:07:11 +01:00