Delta-v/Content.Server.Database/Migrations/Postgres
Julian Giebel 0ba5b81a6a Kick on ban for entire server group (#28649)
* Start work on PostgresNotificationManager
Implement initial version of init and listening code

* Finish implementing PostgresNotificationManager
Implement ban insert trigger

* Implement ignoring notifications if the ban was from the same server

* Address reviews

* Fixes and refactorings

Fix typo in migration SQL

Pull new code in BanManager out into its own partial file.

Unify logic to kick somebody with that when a new ban is placed directly on the server.

New bans are now checked against all parameters (IP, HWID) instead of just user ID.

Extracted SQLite ban matching code into a new class so that it can mostly be re-used by the ban notification code. No copy-paste here.

Database notifications are now not implicitly sent to the main thread, this means basic checks will happen in the thread pool beforehand.

Bans without user ID are now sent to servers. Bans are rate limited to avoid undue work from mass ban imports, beyond the rate limit they are dropped.

Improved error handling and logging for the whole system.

Matching bans against connected players requires knowing their ban exemption flags. These are now cached when the player connects.

ServerBanDef now has exemption flags, again to allow matching full ban details for ban notifications.

Made database notifications a proper struct type to reduce copy pasting a tuple.

Remove copy pasted connection string building code by just... passing the string into the constructor.

Add lock around _notificationHandlers just in case.

Fixed postgres connection wait not being called in a loop and therefore spamming LISTEN commands for every received notification.

Added more error handling and logging to notification listener.

Removed some copy pasting from SQLite database layer too while I was at it because god forbid we expect anybody else to do all the work in this project.

Sorry Julian

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2024-08-21 16:16:41 +01:00
..
20200929113117_Init.Designer.cs Holy crap auth works (#2099) 2020-09-29 14:26:00 +02:00
20200929113117_Init.cs Holy crap auth works (#2099) 2020-09-29 14:26:00 +02:00
20201006223000_SelectedCharacterSlotFk.cs Foreign key for selected character slots. 2020-10-07 10:42:53 +02:00
20201028210620_Admins.Designer.cs ConGroups are gone. Long live admin flags in content. 2020-10-30 16:06:48 +01:00
20201028210620_Admins.cs ConGroups are gone. Long live admin flags in content. 2020-10-30 16:06:48 +01:00
20201109092921_ExtraIndices.Designer.cs Permissions panel. 2020-11-10 16:50:28 +01:00
20201109092921_ExtraIndices.cs Permissions panel. 2020-11-10 16:50:28 +01:00
20201203093409_ClothingAndPronouns.Designer.cs Clothing and pronoun fields (#2689) 2020-12-24 14:42:40 +01:00
20201203093409_ClothingAndPronouns.cs Clothing and pronoun fields (#2689) 2020-12-24 14:42:40 +01:00
20210103151756_BackpackPreference.Designer.cs Backpack preferences. (#2864) 2021-01-03 16:22:14 +01:00
20210103151756_BackpackPreference.cs Backpack preferences. (#2864) 2021-01-03 16:22:14 +01:00
20210211211033_AdminOOCColor.Designer.cs OOC sent by an admin will have a different color (#3117) 2021-02-14 15:59:56 +01:00
20210211211033_AdminOOCColor.cs OOC sent by an admin will have a different color (#3117) 2021-02-14 15:59:56 +01:00
20210321230012_HWID.Designer.cs Use HWIDs for bans. 2021-03-22 01:32:09 +01:00
20210321230012_HWID.cs Cleanup the namespaces (#8132) 2022-05-13 17:59:03 +10:00
20210915093340_UniqueHighPriorityJob.Designer.cs Add extra unique constraints to DB jobs. 2021-09-15 11:37:05 +02:00
20210915093340_UniqueHighPriorityJob.cs Add extra unique constraints to DB jobs. 2021-09-15 11:37:05 +02:00
20211120202701_AdminLogs.Designer.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20211120202701_AdminLogs.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20211121123543_AdminLogsImpact.Designer.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20211121123543_AdminLogsImpact.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20220103235647_whitelist.Designer.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220103235647_whitelist.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220108185749_add-species.Designer.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220108185749_add-species.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220127170845_UnifyMore.Designer.cs Unify remaining DB model classes between SQLite and Postgres. 2022-01-27 18:12:09 +01:00
20220127170845_UnifyMore.cs Unify remaining DB model classes between SQLite and Postgres. 2022-01-27 18:12:09 +01:00
20220129005644_ServerBanHit.Designer.cs Revert "Revert "Log ban hits in DB. ( (#6361) 2022-02-02 22:57:11 +01:00
20220129005644_ServerBanHit.cs Revert "Revert "Log ban hits in DB. ( (#6361) 2022-02-02 22:57:11 +01:00
20220214061058_RoleBans.Designer.cs Role bans (#6703) 2022-02-21 23:11:39 +01:00
20220214061058_RoleBans.cs Role bans (#6703) 2022-02-21 23:11:39 +01:00
20220308222742_Cleanup.Designer.cs Fix database model migrations after role bans. 2022-03-08 23:36:02 +01:00
20220308222742_Cleanup.cs Fix database model migrations after role bans. 2022-03-08 23:36:02 +01:00
20220310173734_SpeciesMarkings.Designer.cs Markings (#7072) 2022-05-05 10:07:42 +02:00
20220310173734_SpeciesMarkings.cs Markings (#7072) 2022-05-05 10:07:42 +02:00
20220313151800_ServerNameFts.Designer.cs Server names and admin log full-text search (#6327) 2022-03-13 18:36:48 +01:00
20220313151800_ServerNameFts.cs Server names and admin log full-text search (#6327) 2022-03-13 18:36:48 +01:00
20220324144654_AdminNotes.Designer.cs Admin notes (#7259) 2022-04-16 20:57:50 +02:00
20220324144654_AdminNotes.cs Admin notes (#7259) 2022-04-16 20:57:50 +02:00
20220325170225_PlayerReadRules.Designer.cs Track rule reading in database, don't show popup locally (#7278) 2022-03-26 20:16:57 +01:00
20220325170225_PlayerReadRules.cs Track rule reading in database, don't show popup locally (#7278) 2022-03-26 20:16:57 +01:00
20220326104916_UploadedResourcesLog.Designer.cs Adds Network Resource Uploading for admins. (#6904) 2022-03-26 12:46:37 +01:00
20220326104916_UploadedResourcesLog.cs Adds Network Resource Uploading for admins. (#6904) 2022-03-26 12:46:37 +01:00
20220503222955_FixIndices.Designer.cs Fix admin log indices. (#7920) 2022-05-04 16:18:55 +02:00
20220503222955_FixIndices.cs Fix admin log indices. (#7920) 2022-05-04 16:18:55 +02:00
20220505084828_MarkingsJsonb.Designer.cs Make Profile.Markings db column jsonb (#7947) 2022-05-05 11:23:48 +02:00
20220505084828_MarkingsJsonb.cs Make Profile.Markings db column jsonb (#7947) 2022-05-05 11:23:48 +02:00
20220509060724_FlavorText.Designer.cs Flavor text (#8070) 2022-05-13 15:58:45 -07:00
20220509060724_FlavorText.cs Flavor text (#8070) 2022-05-13 15:58:45 -07:00
20220724000132_PlayTime.Designer.cs Play time tracking: Job timers 3: more titles: when the (#9978) 2022-08-07 16:00:42 +10:00
20220724000132_PlayTime.cs Play time tracking: Job timers 3: more titles: when the (#9978) 2022-08-07 16:00:42 +10:00
20220816163319_Traits.Designer.cs Implement traits system (#10693) 2022-09-10 08:40:06 -07:00
20220816163319_Traits.cs Implement traits system (#10693) 2022-09-10 08:40:06 -07:00
20230319110655_ProfileTraitIndexUnique.Designer.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230319110655_ProfileTraitIndexUnique.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230319112124_ServerBanExemption.Designer.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230319112124_ServerBanExemption.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230402214647_BanAutoDelete.Designer.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230402214647_BanAutoDelete.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230503001749_AdminNotesImprovement.Designer.cs Better notes and bans (#14228) 2023-07-21 13:38:52 +02:00
20230503001749_AdminNotesImprovement.cs Admin notes bugfixes (#18189) 2023-07-21 15:43:47 +02:00
20230725193102_AdminNotesImprovementsForeignKeys.Designer.cs GDPR stuff update (#18300) 2023-07-26 20:05:51 +02:00
20230725193102_AdminNotesImprovementsForeignKeys.cs GDPR stuff update (#18300) 2023-07-26 20:05:51 +02:00
20230727190902_AdminLogCompoundKey.Designer.cs Remove autogenerated from admin log key. (#18377) 2023-07-29 16:44:28 +10:00
20230727190902_AdminLogCompoundKey.cs Remove autogenerated from admin log key. (#18377) 2023-07-29 16:44:28 +10:00
20231021071411_RoundStartDate.Designer.cs Store round start date in the database (#21153) 2023-10-23 23:54:01 +02:00
20231021071411_RoundStartDate.cs Store round start date in the database (#21153) 2023-10-23 23:54:01 +02:00
20231024041204_DropAdminLogEntity.Designer.cs Drop admin log entity db table (#21216) 2023-10-24 18:03:52 +02:00
20231024041204_DropAdminLogEntity.cs Drop admin log entity db table (#21216) 2023-10-24 18:03:52 +02:00
20231126234054_ConnectionLogServer.Designer.cs Log server ID in connection logs table (#21911) 2023-12-16 19:27:08 +01:00
20231126234054_ConnectionLogServer.cs Log server ID in connection logs table (#21911) 2023-12-16 19:27:08 +01:00
20231226154937_AdminLogPk.Designer.cs Fix admin log key order. (#23052) 2024-01-26 22:26:15 +01:00
20231226154937_AdminLogPk.cs Fix admin log key order. (#23052) 2024-01-26 22:26:15 +01:00
20240201091301_SpawnPriorityPreference.Designer.cs Client customization late-join spawner priority for arrivals/cryostorage (#24586) 2024-02-08 12:16:20 +01:00
20240201091301_SpawnPriorityPreference.cs Client customization late-join spawner priority for arrivals/cryostorage (#24586) 2024-02-08 12:16:20 +01:00
20240301130641_ClothingRemoval.Designer.cs Partial cherry-pick: Loadouts redux (#25715) 2024-04-22 03:28:58 +02:00
20240301130641_ClothingRemoval.cs Partial cherry-pick: Loadouts redux (#25715) 2024-04-22 03:28:58 +02:00
20240318022005_AdminMessageDismiss.Designer.cs Improve admin message seen/dismiss state. (#26223) 2024-03-24 00:08:01 +01:00
20240318022005_AdminMessageDismiss.cs Fix missing semicolon after migration. (#26337) 2024-03-24 00:13:47 +01:00
20240403072242_Loadouts.Designer.cs Partial cherry-pick: Loadouts redux (#25715) 2024-04-22 03:28:58 +02:00
20240403072242_Loadouts.cs Partial cherry-pick: Loadouts redux (#25715) 2024-04-22 03:28:58 +02:00
20240409013837_FixRoundStartDateNullability.Designer.cs Fix database round start date issues (#26838) 2024-04-21 21:57:13 +02:00
20240409013837_FixRoundStartDateNullability.cs Fix database round start date issues (#26838) 2024-04-21 21:57:13 +02:00
20240531011555_RoleWhitelist.Designer.cs Add job whitelist system (#28085) 2024-06-01 18:02:43 +02:00
20240531011555_RoleWhitelist.cs Add job whitelist system (#28085) 2024-06-01 18:02:43 +02:00
20240606065731_RemoveLastReadRules.Designer.cs Convert rules to use guidebook parsing (#28647) 2024-07-13 04:18:15 +02:00
20240606065731_RemoveLastReadRules.cs Convert rules to use guidebook parsing (#28647) 2024-07-13 04:18:15 +02:00
20240606121555_ban_notify_trigger.Designer.cs Kick on ban for entire server group (#28649) 2024-08-21 16:16:41 +01:00
20240606121555_ban_notify_trigger.cs Kick on ban for entire server group (#28649) 2024-08-21 16:16:41 +01:00
20240606175154_ReturnLastReadRules.Designer.cs Fixes client having authority over rules popup cvars (#28655) 2024-07-13 04:21:16 +02:00
20240606175154_ReturnLastReadRules.cs Fixes client having authority over rules popup cvars (#28655) 2024-07-13 04:21:16 +02:00
20240621120713_ConnectionLogTimeIndex.Designer.cs Add time index to connection log (#29281) 2024-07-25 00:41:18 +02:00
20240621120713_ConnectionLogTimeIndex.cs Add time index to connection log (#29281) 2024-07-25 00:41:18 +02:00
20240623005121_BanTemplate.Designer.cs Ban template system (#29365) 2024-07-25 01:44:27 +02:00
20240623005121_BanTemplate.cs Ban template system (#29365) 2024-07-25 01:44:27 +02:00
PostgresServerDbContextModelSnapshot.cs Ban template system (#29365) 2024-07-25 01:44:27 +02:00