Skip to content

Commit

Permalink
new client security and refactors and playtimes and--- (#5603)
Browse files Browse the repository at this point in the history
cleans up config
adds new role time.tracking system
adds new panic bunker
adds new VPN detection system
unfucks the automated age gate
does a bunch more cleanups
refactors client security checks a little

---------

Co-authored-by: VM_USER <VM_USER>
Co-authored-by: silicons <[email protected]>
  • Loading branch information
silicons and silicons authored Jun 26, 2023
1 parent ed78515 commit 78a633b
Show file tree
Hide file tree
Showing 83 changed files with 1,636 additions and 1,189 deletions.
50 changes: 50 additions & 0 deletions SQL/database_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,56 @@ CREATE TABLE IF NOT EXISTS `%_PREFIX_%player` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Playtime / JEXP --

-- Role Time Table - Master --
-- Stores total role time. --

CREATE TABLE IF NOT EXISTS `%_PREFIX_%playtime` (
`player` INT(11) NOT NULL,
`roleid` VARCHAR(64) NOT NULL,
`minutes` INT UNSIGNED NOT NULL,
PRIMARY KEY(`player`, `roleid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Role Time - Logging --
-- Stores changes in role time --
CREATE TABLE IF NOT EXISTS `%_PREFIX_%playtime_log` (
`player` INT(11),
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`roleid` VARCHAR(64) NOT NULL,
`delta` INT(11) NOT NULL,
`datetime` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),
PRIMARY KEY (`id`),
KEY `player` (`player`),
KEY `roleid` (`roleid`),
KEY `datetime` (`datetime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

DELIMITER $$
CREATE TRIGGER `playtimeTlogupdate` AFTER UPDATE ON `%_PREFIX_%playtime` FOR EACH ROW BEGIN INSERT into `%_PREFIX_%playtime_log` (player, roleid, delta) VALUES (NEW.player, NEW.roleid, NEW.minutes-OLD.minutes);
END
$$
CREATE TRIGGER `playtimeTloginsert` AFTER INSERT ON `%_PREFIX_%playtime` FOR EACH ROW BEGIN INSERT into `%_PREFIX_%playtime_log` (player, roleid, delta) VALUES (NEW.player, NEW.roleid, NEW.minutes);
END
$$
CREATE TRIGGER `playtimeTlogdelete` AFTER DELETE ON `%_PREFIX_%playtime` FOR EACH ROW BEGIN INSERT into `%_PREFIX_%playtime_log` (player, roleid, delta) VALUES (OLD.player, OLD.roleid, 0-OLD.minutes);
END
$$
DELIMITER ;

-- Security - Ipintel --

-- Ipintel Cache Table --
-- Stores cache entries for IPIntel --
-- IP is in INET_ATON. --
CREATE TABLE IF NOT EXISTS `%_PREFIX_%ipintel` (
`ip` INT(10) unsigned NOT NULL,
`date` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),
`intel` double NOT NULL DEFAULT '0',
PRIMARY KEY (`ip`),
KEY `idx_ipintel` (`ip`, `intel`, `date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `round`
Expand Down
52 changes: 51 additions & 1 deletion SQL/database_schema_prefixed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS `rp_pictures` (
-- picture is picture hash in picture table --
CREATE TABLE IF NOT EXISTS `rp_photographs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`picture` char(40) NULL,
`picture` char(40) NOT NULL,
`created` datetime NOT NULL DEFAULT Now(),
`scene` MEDIUMTEXT null,
`desc` MEDIUMTEXT null,
Expand Down Expand Up @@ -77,6 +77,56 @@ CREATE TABLE IF NOT EXISTS `rp_player` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Playtime / JEXP --

-- Role Time Table - Master --
-- Stores total role time. --

CREATE TABLE IF NOT EXISTS `rp_playtime` (
`player` INT(11) NOT NULL,
`roleid` VARCHAR(64) NOT NULL,
`minutes` INT UNSIGNED NOT NULL,
PRIMARY KEY(`player`, `roleid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Role Time - Logging --
-- Stores changes in role time --
CREATE TABLE IF NOT EXISTS `rp_playtime_log` (
`player` INT(11),
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`roleid` VARCHAR(64) NOT NULL,
`delta` INT(11) NOT NULL,
`datetime` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),
PRIMARY KEY (`id`),
KEY `player` (`player`),
KEY `roleid` (`roleid`),
KEY `datetime` (`datetime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

DELIMITER $$
CREATE TRIGGER `playtimeTlogupdate` AFTER UPDATE ON `rp_playtime` FOR EACH ROW BEGIN INSERT into `rp_playtime_log` (player, roleid, delta) VALUES (NEW.player, NEW.roleid, NEW.minutes-OLD.minutes);
END
$$
CREATE TRIGGER `playtimeTloginsert` AFTER INSERT ON `rp_playtime` FOR EACH ROW BEGIN INSERT into `rp_playtime_log` (player, roleid, delta) VALUES (NEW.player, NEW.roleid, NEW.minutes);
END
$$
CREATE TRIGGER `playtimeTlogdelete` AFTER DELETE ON `rp_playtime` FOR EACH ROW BEGIN INSERT into `rp_playtime_log` (player, roleid, delta) VALUES (OLD.player, OLD.roleid, 0-OLD.minutes);
END
$$
DELIMITER ;

-- Security - Ipintel --

-- Ipintel Cache Table --
-- Stores cache entries for IPIntel --
-- IP is in INET_ATON. --
CREATE TABLE IF NOT EXISTS `rp_ipintel` (
`ip` INT(10) unsigned NOT NULL,
`date` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),
`intel` double NOT NULL DEFAULT '0',
PRIMARY KEY (`ip`),
KEY `idx_ipintel` (`ip`, `intel`, `date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Table structure for table `round`
Expand Down
26 changes: 19 additions & 7 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
#include "code\__DEFINES\atmospherics\pipes.dm"
#include "code\__DEFINES\cargo\supply.dm"
#include "code\__DEFINES\client\player_flags.dm"
#include "code\__DEFINES\client\playtime.dm"
#include "code\__DEFINES\color\color.dm"
#include "code\__DEFINES\color\colour_priority.dm"
#include "code\__DEFINES\color\lights.dm"
Expand Down Expand Up @@ -476,18 +477,19 @@
#include "code\controllers\configuration\config_entry.dm"
#include "code\controllers\configuration\configuration.dm"
#include "code\controllers\configuration\whitelists.dm"
#include "code\controllers\configuration\entries\bot.dm"
#include "code\controllers\configuration\entries\comms.dm"
#include "code\controllers\configuration\entries\compile.dm"
#include "code\controllers\configuration\entries\dbconfig.dm"
#include "code\controllers\configuration\entries\fail2topic.dm"
#include "code\controllers\configuration\entries\game_options.dm"
#include "code\controllers\configuration\entries\admin.dm"
#include "code\controllers\configuration\entries\chat_bridge.dm"
#include "code\controllers\configuration\entries\cross_server.dm"
#include "code\controllers\configuration\entries\database.dm"
#include "code\controllers\configuration\entries\game.dm"
#include "code\controllers\configuration\entries\general.dm"
#include "code\controllers\configuration\entries\health.dm"
#include "code\controllers\configuration\entries\lobby.dm"
#include "code\controllers\configuration\entries\logging.dm"
#include "code\controllers\configuration\entries\photography.dm"
#include "code\controllers\configuration\entries\playtime.dm"
#include "code\controllers\configuration\entries\resources.dm"
#include "code\controllers\configuration\entries\security.dm"
#include "code\controllers\configuration\entries\shadowban.dm"
#include "code\controllers\configuration\entries\skills.dm"
#include "code\controllers\configuration\entries\urls.dm"
Expand Down Expand Up @@ -520,6 +522,7 @@
#include "code\controllers\subsystem\icon_smooth.dm"
#include "code\controllers\subsystem\inactivity.dm"
#include "code\controllers\subsystem\input.dm"
#include "code\controllers\subsystem\ipintel.dm"
#include "code\controllers\subsystem\legacy_atc.dm"
#include "code\controllers\subsystem\legacy_lore.dm"
#include "code\controllers\subsystem\lighting.dm"
Expand All @@ -538,6 +541,7 @@
#include "code\controllers\subsystem\ping.dm"
#include "code\controllers\subsystem\planets.dm"
#include "code\controllers\subsystem\plants.dm"
#include "code\controllers\subsystem\playtime.dm"
#include "code\controllers\subsystem\radiation.dm"
#include "code\controllers\subsystem\repository.dm"
#include "code\controllers\subsystem\server_maint.dm"
Expand Down Expand Up @@ -2208,22 +2212,30 @@
#include "code\modules\catalogue\cataloguer.dm"
#include "code\modules\catalogue\cataloguer_visuals.dm"
#include "code\modules\catalogue\cataloguer_vr.dm"
#include "code\modules\client\client procs_vr.dm"
#include "code\modules\client\client.dm"
#include "code\modules\client\client_data.dm"
#include "code\modules\client\client_procs.dm"
#include "code\modules\client\connection.dm"
#include "code\modules\client\cutscene.dm"
#include "code\modules\client\legacy.dm"
#include "code\modules\client\perspective.dm"
#include "code\modules\client\player_data.dm"
#include "code\modules\client\security.dm"
#include "code\modules\client\spam_prevention.dm"
#include "code\modules\client\statpanel.dm"
#include "code\modules\client\throttling.dm"
#include "code\modules\client\ui_style.dm"
#include "code\modules\client\viewport.dm"
#include "code\modules\client\wrappers.dm"
#include "code\modules\client\onboarding\_onboarding.dm"
#include "code\modules\client\onboarding\age_verification.dm"
#include "code\modules\client\onboarding\panic_bunker.dm"
#include "code\modules\client\onboarding\security_checks.dm"
#include "code\modules\client\verbs\minimap.dm"
#include "code\modules\client\verbs\ooc.dm"
#include "code\modules\client\verbs\panic_bunker_player.dm"
#include "code\modules\client\verbs\ping.dm"
#include "code\modules\client\verbs\preferences.dm"
#include "code\modules\client\verbs\view.dm"
#include "code\modules\clothing\chameleon.dm"
#include "code\modules\clothing\clothing.dm"
Expand Down
1 change: 0 additions & 1 deletion code/__DEFINES/admin/bans.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//? roleban types
/// full server ban - currently just a shim to go to legacy isbanned, eventually just will go to server_ban.dm

#define BAN_ROLE_SERVER "server"
/// OOC + LOOC + deadchat ban
#define BAN_ROLE_OOC "ooc"
Expand Down
8 changes: 7 additions & 1 deletion code/__DEFINES/client/player_flags.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
//! player flags
/// exempt from any job timelock system
/// exempt from any job timelock system: this includes the VPN bunker!
#define PLAYER_FLAG_JEXP_EXEMPT (1<<0)
/// age verified
#define PLAYER_FLAG_AGE_VERIFIED (1<<1)
/// connected, recorded, and *not* blocked through panic bunker when operating in connection mode
#define PLAYER_FLAG_CONSIDERED_SEEN (1<<2)

DEFINE_BITFIELD(player_flags, list(
BITFIELD(PLAYER_FLAG_JEXP_EXEMPT),
BITFIELD(PLAYER_FLAG_AGE_VERIFIED),
BITFIELD(PLAYER_FLAG_CONSIDERED_SEEN),
))
11 changes: 11 additions & 0 deletions code/__DEFINES/client/playtime.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// playtime key for alive
#define PLAYER_PLAYTIME_LIVING "living"
/// playtime key for died/as observer from a dead character
#define PLAYER_PLAYTIME_DEAD "dead"
/// playtime key for observer (but not because they died ofcourse)
#define PLAYER_PLAYTIME_OBSERVER "observer"
/// playtime key for lobby
#define PLAYER_PLAYTIME_LOBBY "lobby"
/// playtime key for role id
#define PLAYER_PLAYTIME_ROLE(id) "role-[id]"

1 change: 1 addition & 0 deletions code/__DEFINES/controllers/_subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ DEFINE_BITFIELD(runlevels, list(
// todo: tg init brackets

#define INIT_ORDER_FAIL2TOPIC 200
#define INIT_ORDER_IPINTEL 197
#define INIT_ORDER_TIMER 195
#define INIT_ORDER_DBCORE 190
#define INIT_ORDER_EARLY_INIT 185
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/preferences/savefiles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//* We store this on savefile because you can handle global migrations
//* and advanced direct savefile migrations directly with this.
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 15
#define SAVEFILE_VERSION_MAX 16

//! Character version - stored in character data list
//* Slot gets wiped if version < MIN
Expand Down
6 changes: 6 additions & 0 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global"))

GLOB.round_text_log += "<b>([time_stamp()])</b> (<b>[user]</b>) <u>LOOC:</u> - <span style='color:orange'><b>[text]</b></span>"

/proc/log_ipintel(text)
WRITE_LOG(GLOB.world_runtime_log, "IPINTEL: [text]")

/proc/log_vote(text)
if (config_legacy.log_vote)
WRITE_LOG(GLOB.world_game_log, "VOTE: [text]")
Expand All @@ -213,6 +216,9 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global"))
/proc/log_reagent_transfer(text)
log_reagent("TRANSFER: [text]")

/proc/log_security(text)
WRITE_LOG(GLOB.world_game_log, "SECURITY: [text]")

/proc/log_subsystem(subsystem, text)
WRITE_LOG(GLOB.subsystem_log, "[subsystem]: [text]")

Expand Down
3 changes: 3 additions & 0 deletions code/__HELPERS/time.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
GLOBAL_VAR_INIT(startup_year, text2num(time2text(world.time, "YYYY")))
GLOBAL_VAR_INIT(startup_month, text2num(time2text(world.time, "MM")))
GLOBAL_VAR_INIT(startup_day, text2num(time2text(world.time, "DD")))

#define TimeOfGame (get_game_time())
#define TimeOfTick (TICK_USAGE*0.01*world.tick_lag)
Expand Down
1 change: 1 addition & 0 deletions code/controllers/configuration/entries/admin.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/datum/config_entry/flag/enable_localhost_rank
2 changes: 0 additions & 2 deletions code/controllers/configuration/entries/compile.dm

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/datum/config_entry/string/comms_key/ValidateAndSet(str_val)
return str_val != "default_pwd" && length(str_val) > 6 && ..()

// todo: remove
/datum/config_entry/keyed_list/cross_server_bunker_override
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_TEXT
Expand All @@ -23,4 +24,5 @@
/datum/config_entry/flag/allow_cross_server_bunker_override
protection = CONFIG_ENTRY_LOCKED

// todo: remove, cluster staging/organization should be in a database
/datum/config_entry/string/cross_comms_name
19 changes: 0 additions & 19 deletions code/controllers/configuration/entries/fail2topic.dm

This file was deleted.

18 changes: 3 additions & 15 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/datum/config_entry/flag/minimaps_enabled
default = TRUE

/datum/config_entry/number/max_bunker_days
default = 7
min_val = 1

/datum/config_entry/string/invoke_youtubedl
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN

Expand Down Expand Up @@ -32,24 +28,16 @@
default = null
min_val = 0

/datum/config_entry/string/community_shortname

/datum/config_entry/string/community_link

/datum/config_entry/string/tagline
default = "<br><small><a href='https://discord.gg/citadelstation'>Roleplay focused 18+ server with extensive species choices.</a></small></br>"

/datum/config_entry/flag/usetaglinestrings

/datum/config_entry/flag/cache_assets
default = TRUE

/datum/config_entry/flag/show_irc_name

/// allows admins with relevant permissions to have their own ooc colour
/datum/config_entry/flag/allow_admin_ooccolor
default = TRUE

/datum/config_entry/number/rounds_until_hard_restart
default = -1
min_val = 0

/// Enable or disable the toast notification when the the instance finishes initializing.
/datum/config_entry/flag/toast_notification_on_init
9 changes: 9 additions & 0 deletions code/controllers/configuration/entries/lobby.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@

/// Enforce flavortext
/datum/config_entry/flag/enforce_flavor_text

/datum/config_entry/string/community_shortname

/datum/config_entry/string/community_link

/datum/config_entry/string/tagline
default = "<br><small><a href='https://discord.gg/citadelstation'>Roleplay focused 18+ server with extensive species choices.</a></small></br>"

/datum/config_entry/flag/usetaglinestrings
Loading

0 comments on commit 78a633b

Please sign in to comment.