Commit Graph
46 Commits
Author SHA1 Message Date
DrSmugleafandGitHub 667b16c225 Fix RobustIntegrationTest not raising a OnConnecting event for dummy sessions (#6880) 2026-08-01 15:10:47 +10:00
83c2a1be11 [Dependency] source generator part 2 (#6550)
* [Dependency] source generator

No more reflection, no more codegen at runtime

Also various changes to Roslyn helpers to make this easier to write.

Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback.

No fallback is available for [field: Dependency] properties, due to a Roslyn bug.

Code Fixes exist. We love Roslyn

* Apply dependencies generator changes to all code

* Release notes

* Preprocessor got hands

* Handle nullable dependencies

These are bad but gotta deal with it.

* Apply suggestions from code review

Co-authored-by: Moony <moony@hellomouse.net>

* Fine, let's not use collection expressions

---------

Co-authored-by: Moony <moony@hellomouse.net>
2026-05-08 12:38:33 +02:00
Pieter-Jan BriersandGitHub dc1464b462 High-bandwidth transfer system (#6373)
* WebSocket-based data transfer system

* Move resource downloads/uploads to the new transfer system

Should drastically increase the permitted practical size

* Transfer impl for Lidgren

* Async impl for receive stream

* Use unbounded channel for Lidgren

* Add metrics

* More comments

* Add serverside stream limit to avoid being a DoS vector

* Fix tests

* Oops forgot to actually implement sequence channels in NetMessage

* Doc comment for NetMessage.SequenceChannel

* Release notes
2026-01-19 20:44:44 +01:00
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00
PJB3005 b4863dcc38 Properly stop sending messages to disconnected channels.
Log errors, and fix the ChannelClosedException it caused.
2025-08-05 17:12:43 +02:00
Pieter-Jan BriersandGitHub f40ccb7558 New HWID system prep (#5446)
* New HWID system prep

* Allow HWID to be disabled.

Both client and server can now request HWID to be disabled.

On the server via CVar, if disabled the client won't send it.

On the client via env var, if disabled it won't be sent to the client.

This involved moving legacy HWID to be sent in MsgEncryptionResponse instead of MsgLoginStart. This means the legacy HWID won't be available anymore if the connection isn't authenticated.

* Fix tests

* Fix another test

* Review

* Thanks Rider
2024-09-29 00:29:02 +02:00
Leon FriedrichandGitHub 75626a86a3 Add dummy sessions for integration tests (#5202)
* Add dummy sessions

* if FULL_RELEASE
2024-06-05 16:50:06 +10:00
Pieter-Jan Briers f5ade69f6d Show MTU in network debug panel. 2024-03-22 22:19:17 +01:00
Pieter-Jan BriersandGitHub af98933173 Isolate net messages in integration tests. (#4838)
* Isolate net messages in integration tests.

Integration tests don't use Lidgren to connect client and send, instead they just use some in-process channels to communicate. Because of this, the original implementation of net messages *directly* passed the net message instances between client and server instances. This caused issues whenever content would mutate data in a NetMessage after it "passed through".

Now we run the messages through WriteToBuffer() and ReadFromBuffer() so they pass through binary serialization. This means there's no more implicit sharing of the objects.

Note that this requires some trickery: Lidgren's message types have internal constructors. Really ideally we'd change the engine to make this more testable... but that's a content breaking change. Instead I just added InternalsVisibleTo to Lidgren so we can mess with it. We maintain the library ourselves anyways I can do what I want.

Fixes #4836

* Register Robust.UnitTesting as assembly for reflection.

This is necessary so that serialized types in the assembly can be picked up by NetSerializer.

Have to disable automatic reflection on all entity systems/components that tests register manually right now, because otherwise tests break.

* Stop shallow cloning specific net messages in integration tests.

This isn't necessary anymore now that we have a thorough fix.

* Wow I really forgot to copy-paste that line to the other side huh.

* Add test that serializer hash matches.

* Another test one I missed earlier.

* Changelog
2024-01-16 21:04:39 +01:00
Leon FriedrichandGitHub eba58cb893 Remove RobustTree & PVSCollection (#4759)
* Cut down RobustTree

* Better LoD

* Add PvsPriority flag

* Undo cvar name change

* reorganize grafana metrics

* Fix tests

* Fix replays

* Don't try process empty chunks

* Fix move benchmark

* Fix benchmark

* Remove obsolete audio methods

* Moar benchmarks

* Rename EntityData

* A

* B
2023-12-28 09:10:13 +11:00
Leon FriedrichandGitHub 3e43b88518 Fix bad disconnects in tests (#4217) 2023-08-02 10:29:17 +10:00
Leon FriedrichandGitHub f856ac0efa Misc replay related engine changes (#3508) 2022-11-28 12:11:44 +11:00
wrexbeandGitHub 17ec51b74c Add reusing username+id in tests (#3143) 2022-08-22 05:57:07 +10:00
Leon FriedrichandGitHub 6a8266af7e Revert "Revert "PVS & client state handling changes"" (#3152) 2022-08-21 08:30:28 +10:00
Leon FriedrichandGitHub 9cd8adae93 Revert "PVS & client state handling changes" (#3151) 2022-08-21 05:27:16 +10:00
Leon FriedrichandGitHub b4358a9e33 PVS & client state handling changes (#3000) 2022-08-21 03:40:18 +10:00
wrexbeandGitHub f90872b085 Various test changes (#2930) 2022-06-20 10:03:17 +10:00
Pieter-Jan Briers 3ae4bb03f5 Enable NetManager latency sim on release, add no-bye to INetChannel.
A minute amount of tomfoolery.
2022-05-09 15:43:30 +02:00
Pieter-Jan Briers 45d906ba7e Deprecate CreateNetMessage<T>. 2022-04-15 18:47:42 +02:00
Pieter-Jan Briers 24b124fb17 Fix client reconnect 2022-04-15 15:28:45 +02:00
Pieter-Jan BriersandGitHub de8c2c14bb Replace Lidgren encryption stuff with Libsodium (#2646) 2022-04-02 16:24:04 +02:00
04d029b9a2 Add test pooling (#2146)
* Add test pooling and global test setup

* WIP test pooling changes

* Make asynchronous tests the default again

* Finish fixing tests, make test threads background threads

* Un-pool tests with custom cvars

* Fix not changing FailureLogLevel cvar on instance return

* Fix error when overriding already overriden cvar

* Don't pool some physics integration tests

* Unpool engine tests, the technology just isn't there yet

* Remove explicit Pool = false from physics tests

* Change default pooling setting to false

* Didn't need this anyway

* Remove ConfigurationManager.ResetOverrides

* Bring back enum cvar override parsing

* Make integrationInstances name clearer > notPooledInstaces
Make clients ready and servers ready internal

* Add logging test instances

* Give more info on ran tests

* Show total clients and servers in test output

* Wipe LayerMap on SpriteComponent.AfterDeserialize

* Fix server not properly kicking clients

* Rider shut

* Make all test metrics report totals

* Format tests ran better

* Replace Console.WriteLine with TestContext.Out.WriteLine

* Fix two server test pooling info prints using total clients instead of total servers

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2021-11-06 11:18:18 +01:00
Pieter-Jan Briers cef92efd0f NetManager now enforces that only specific messages can be sent before serializer handshake completes. 2021-07-17 14:37:40 +02:00
mirrorcultandGitHub d992e47f30 Remove NetMessage deprecated boilerplate entirely (#1830)
* Remove NetMessage boilerplate in favor of virtual properties

* forgot some stuff
2021-07-12 10:28:46 +02:00
DrSmugleafandGitHub ac1705e41f Make NetMessage name and group virtual to remove required boilerplate (#1770) 2021-05-31 08:53:46 +02:00
DrSmugleafandGitHub a9f7c7a76f Fix no HWId userdata error in integration tests (#1667) 2021-03-30 15:39:43 +02:00
Pieter-Jan Briers 2959456bec Fix integration test networking. 2021-03-30 13:28:26 +02:00
Pieter-Jan Briers 2ace0e9e5a Expose Patreon tier info from auth server. 2021-02-28 18:45:01 +01:00
AcruidandGitHub 2183cd7ca1 Massive Namespace Cleanup (#1544)
* Removed the Interfaces folder.
* All objects inside the GameObjects subfolders are now in the GameObjects namespace.
* Added a Resharper DotSettings file to mark the GameObjects subfolders as not providing namespaces.
* Simplified Robust.client.Graphics namespace.
* Automated remove redundant using statements.
2021-02-10 23:27:19 -08:00
Pieter-Jan Briers 6973d43006 Network timing synchronization.
Lidgren NetTime.Now is now synchronized to IGameTiming.RealTime.

NetChannel is now a nested class of NetManager.

Add IGameTiming.ServerTime, INetChannel.RemoteTimeOffset, INetChannel.RemoteTime
2021-02-09 14:28:20 +01:00
DrSmugleafandGitHub 50f0a4389e Fix the server not setting IsConnected to false for disconnecting clients in integration tests (#1442) 2020-12-12 00:53:10 +01:00
Pieter-Jan Briers 8357940ef6 Try to fix integration test failures. 2020-12-04 13:04:01 +01:00
b8e5b47e7a Use 'new' expression in places where the type is evident for the engine (#1415)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2020-11-26 00:16:55 +01:00
Pieter-Jan Briers 362b7804d9 Fix issues with .NET 5. 2020-11-11 00:46:35 +01:00
DrSmugleafandGitHub 23c0984d2e Change integration tests to use LoginType.GuestAssigned instead of Guest (#1308) 2020-10-09 11:38:53 +02:00
Pieter-Jan BriersandGitHub aa64528a03 Auth (#1289)
* Some stuff for auth

* Holy crap auth works

* Enable encryption even if no auth token is provided.

It's still possible that the public key was retrieved over HTTPS via the status API, in which case it will be secure.

* Fix integration test compile.

* Secure CVar API.

* Literally rewrite the auth protocol to be minecraft's.

* Better exception tolerance in server handshake.

* Auth works from launcher.

* Fix some usages of UserID instead of UserName

* Fix auth.server CVar

* Kick existing connection if same account connects twice.

* Username assignment, guest session distinguishing.

* Necessary work to make bans work.

* Expose LoginType to OnConnecting.

* Fixing tests and warnings.
2020-09-29 14:18:12 +02:00
Pieter-Jan Briers 3f43e86530 NetMessageAccept, NetMessage dispatch cleanup.
Net message functions are now cached when the message is registered or the string table updates (client side). This removes the cache call from DispatchNetMessage.

Receiving net messages that we don't have reception callbacks for, or that are blocked with the new NetMessageAccept enum, will instantly cause the net manager to drop the offending connection to avoid malicious use.

This means trying to send string tables to the server will just result in an instant kick without even hitting ReadFromBuffer().

This allows us to move some if() checks to asserts.
2020-09-01 01:03:06 +02:00
Pieter-Jan Briers 9e5374ac86 Assert that messages have been registerd in integration tests. 2020-07-06 21:24:03 +02:00
Pieter-Jan Briers aaa09881cb Enable NRTs for unit tests. 2020-06-12 17:11:32 +02:00
Pieter-Jan Briers 9eeb1d1afa Fix compiler warnings 2020-05-28 17:44:31 +02:00
Pieter-Jan Briers b7f3627ef1 Remove List<>/Dictionary<,> usage from low-level GameState serialization.
NetSerializer does not handle these well and sends the entire backing array instead of a more compact representation. This can then cause it to start sending lists of length 1 with a *capacity* of 4096 resulting in 250 KiB/s down to send updates for a single entity. As it just did on the public server...
2020-05-12 18:34:16 +02:00
Jackson LewisandGitHub 10f98e2fca ServerEntityNetworkManager doesn't dispatch messages if the client got disconnected (#1030) 2020-04-20 15:46:11 +02:00
Pieter-Jan Briers ba933f7db0 Improvements to allow better connection dialog in content. 2020-04-17 14:41:22 +02:00
Pieter-Jan Briers 9cca7ce8ef Expose client connection state. 2020-04-04 15:07:31 +02:00
Pieter-Jan Briers ada2c3f39c Fix handling of disconnects in the integration test netmanager.
Clients would treat any message coming in as being from the server they're connected to, instead of ignoring them if they're not correct.

This made the client crash inside integration tests because messages came in while disconnected.

This fixes that.
2020-01-26 23:51:57 +01:00
Pieter-Jan Briers 9a4c1cae1e Networked integration tests work. 2019-06-28 16:03:58 +02:00