Commit Graph

73 Commits

Author SHA1 Message Date
5250a432d1 NetworkSession: add a dedicated PrefixedLogger, clean up some boilerplate code 2019-05-06 16:32:34 +01:00
0dac982f16 Merge branch 'stable' 2019-04-21 16:56:53 +01:00
939dfd9269 First look at separating chunk sending from Level 2019-04-17 19:33:37 +01:00
0e3e984db9 Player: Disconnects no longer nuke player internals, (mostly) fixes #1239
there are some problems that haven't been accounted for yet, but this fixes all the direct crashes.
2019-04-03 17:44:34 +01:00
e5756dbf0b Move a whole bunch of packet crap to NetworkSession 2019-04-02 18:31:16 +01:00
9ec62643d5 Player construction now happens when we're ready to create the player entity
this fixes a wide range of bugs with the initial spawn sequence, and allows to simplify a whole lot of player setup logic.
2019-03-23 10:13:14 +00:00
433dab078b DataPacket events now use network sessions instead of players 2019-03-23 09:52:03 +00:00
cce99b07af 1.10.0 updates 2019-03-20 19:17:41 +00:00
ebfe9caca3 Move too-early-send check to NetworkSession 2019-03-14 14:45:30 +00:00
26a5d97499 Some cleanup to player net session handling for connect/disconnect 2019-03-14 14:32:43 +00:00
f680a239f7 NetworkSession: some exception handling cleanup 2019-02-28 16:36:03 +00:00
19f0d7f336 NetworkSession: Don't apply handlers to a disconnected session
closes #2756
2019-02-15 10:11:31 +00:00
b8703d5dff Protocol changes for 1.9.0 2019-02-07 21:56:42 +00:00
467caf347d NetworkSession: Consistently don't use 0x prefix 2019-01-20 11:06:47 +00:00
5d8568b1a4 Add NetworkSession->getDisplayName(), clean up ip/port ad-hoc usages 2019-01-20 11:05:12 +00:00
76f1ee1827 Add restrictions on packet send directions with interfaces
This prevents plugins sending wrong packets at the compiler level (or would, if we had a compiler). It's more robust than a getter for client/server and throwing an exception since a static analysis tool can detect faults created by sending wrong packets from the server. This is also used to deny service to dodgy clients which send wrong packets to the server to attack it.
2019-01-17 12:51:24 +00:00
b82e00ffdf Extract a Packet interface from DataPacket
this is in preparation for clientbound/serverbound packet separation. I did this already on another branch, but the changeset was dependent on a massive refactor to split apart packets and binarystream which i'm still not fully happy with.
2019-01-17 12:21:56 +00:00
23269da1a6 Fixed the disaster of packet receive error handling 2019-01-16 19:53:48 +00:00
728bc95d73 NetworkSession: remove premature GC optimization
The only cyclic references here are both destroyed during normal collection directly (net interface removes from sessions array, player destroys its session reference), so there's no need to destroy them again here. This just causes a giant swathe of potential crashes for no real benefit.

close #2669
2019-01-16 16:50:16 +00:00
acdd0fec5f NetworkSession: player may be null 2019-01-16 16:19:39 +00:00
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
f81bbd60e8 Avoid use of internal fields in BinaryStream 2019-01-01 16:42:14 +00:00
30f5a8fac6 Protocol changes for 1.8.0 release 2018-12-11 21:05:03 +00:00
839d5eab7b Protocol changes for 1.7
there's also some new cases in stats, but we don't care about those anyway.
2018-10-16 17:13:52 +01:00
4608ecde9b Merge branch 'release/3.3' 2018-10-05 18:29:37 +01:00
535d4e2c9b Added NetworkSession->getPlayer() 2018-09-12 10:51:37 +01:00
986077e03c Protocol changes for 1.6.0.1 2018-08-21 17:14:53 +01:00
15bac8c58a Implement send buffering and queuing for network sessions (#2358)
Async compression and broadcasts are now reliable and don't have race condition bugs.
This features improved performance and significantly reduced bandwidth wastage.

Reduce Level broadcast latency by ticking network after levels. This ensures that session buffers get flushed as soon as possible after level tick, if level broadcasts were done.
2018-08-13 14:37:18 +01:00
a5383b4a82 Use SetLocalPlayerAsInitializedPacket for spawning, fixed a bunch of bugs
this should fix forms not working during PlayerJoinEvent, and also removes the spurious PlayerItemHeldEvent firing on spawn bug.

The player MUST now send this packet. Bots take note.
2018-08-05 10:45:41 +01:00
10ba3d6359 Network: add ability to tick sessions
moved responsibility for login timeout checks to NetworkSession instead of Server
2018-08-02 17:39:09 +01:00
7560880168 Added DataPacketBroadcastEvent, refactor broadcast handling, close #1521
batchPackets() is now considered internal and shouldn't be used by plugins.

Added Server->broadcastPackets(Player[], DataPacket[]) : bool
2018-08-02 15:54:30 +01:00
488c03c200 Make timings for player network more detailed 2018-07-31 16:34:15 +01:00
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
bdd42d6a78 Added NetworkSession->sendEncoded(), clean up some code 2018-07-27 18:39:14 +01:00
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
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
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
ca1a0c8643 Move responsibility for ping handling to NetworkSession 2018-07-21 16:33:12 +01:00
57e5b1309d NetworkSession: Stop processing batch if player gets disconnected during handling 2018-07-21 16:27:30 +01:00
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
015ee90571 Split PlayerActionPacket handling into two classes, death is now a session state 2018-07-20 18:11:29 +01:00
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
e16f20affa NetworkSession: added getHandler() and setHandler(), SessionHandler->setUp() now not useless 2018-07-20 12:36:44 +01:00
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
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
85647c03bf Move IP/port to NetworkSession 2018-07-20 12:36:43 +01:00
f969f3b77f Flatten NetworkSession hierarchy in preparation for refactor 2018-07-20 12:36:43 +01:00
b5dcdea6d8 Protocol changes for 1.5.0 "release"
what a piece of shit this version is...
2018-07-11 10:00:15 +01:00
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
91486a23a5 some changes for 1.2.14.2 beta 2018-05-02 12:03:29 +01:00