From b367f76c62adfe370eaa0247905dfca0cc0318a6 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Wed, 24 Jun 2020 07:49:45 -0700
Subject: [PATCH 1/4] autobunker
---
.../configuration/entries/comms.dm | 21 +++++++++++-
code/datums/world_topic.dm | 19 +++++++++++
code/modules/client/verbs/autobunker.dm | 34 +++++++++++++++++++
tgstation.dme | 1 +
4 files changed, 74 insertions(+), 1 deletion(-)
create mode 100644 code/modules/client/verbs/autobunker.dm
diff --git a/code/controllers/configuration/entries/comms.dm b/code/controllers/configuration/entries/comms.dm
index 012c3ec9fe..e56ff3f0d1 100644
--- a/code/controllers/configuration/entries/comms.dm
+++ b/code/controllers/configuration/entries/comms.dm
@@ -25,4 +25,23 @@
/datum/config_entry/string/medal_hub_address
/datum/config_entry/string/medal_hub_password
- protection = CONFIG_ENTRY_HIDDEN
\ No newline at end of file
+ protection = CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/keyed_list/cross_server_bunker_override
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_TEXT
+ protection = CONFIG_ENTRY_LOCKED
+
+/datum/config_entry/keyed_list/cross_server_bunker_override/ValidateAndSet(str_val)
+ . = ..()
+ if(.)
+ var/list/newv = list()
+ for(var/I in config_entry_value)
+ newv[replacetext(I, "+", " ")] = config_entry_value[I]
+ config_entry_value = newv
+
+/datum/config_entry/keyed_list/cross_server_bunker_override/ValidateListEntry(key_name, key_value)
+ return key_value != "byond:\\address:port" && ..()
+
+/datum/config_entry/flag/allow_cross_server_bunker_override
+ protection = CONFIG_ENTRY_LOCKED
diff --git a/code/datums/world_topic.dm b/code/datums/world_topic.dm
index 30699d36f4..261e423640 100644
--- a/code/datums/world_topic.dm
+++ b/code/datums/world_topic.dm
@@ -74,6 +74,25 @@
for(var/client/C in GLOB.clients)
C.AnnouncePR(final_composed)
+/datum/world_topic/auto_bunker_passthrough
+ keyword = "auto_bunker_override"
+ require_comms_key = TRUE
+
+/datum/world_topic/auto_bunker_passthrough/Run(list/input)
+ if(!CONFIG_GET(flag/allow_cross_server_bunker_override))
+ return "Function Disabled"
+ var/ckeytobypass = input["ckey"]
+ var/is_new_ckey = !(ckey(ckeytobypass) in GLOB.bunker_passthrough)
+ var/sender = input["source"] || "UNKNOWN"
+ GLOB.bunker_passthrough |= ckey(ckeytobypass)
+ GLOB.bunker_passthrough[ckey(ckeytobypass)] = world.realtime
+ SSpersistence.SavePanicBunker() //we can do this every time, it's okay
+ if(!is_new_ckey)
+ log_admin("AUTO BUNKER: [ckeytobypass] given access (incoming comms from [sender]).")
+ message_admins("AUTO BUNKER: [ckeytobypass] given access (incoming comms from [sender]).")
+ send2irc("Panic Bunker", "AUTO BUNKER: [ckeytobypass] given access (incoming comms from [sender]).")
+ return "Success"
+
/datum/world_topic/ahelp_relay
keyword = "Ahelp"
require_comms_key = TRUE
diff --git a/code/modules/client/verbs/autobunker.dm b/code/modules/client/verbs/autobunker.dm
new file mode 100644
index 0000000000..7fba73bda8
--- /dev/null
+++ b/code/modules/client/verbs/autobunker.dm
@@ -0,0 +1,34 @@
+/client/verb/bunker_auto_authorize()
+ set name = "Auto Authorize Panic Bunker"
+ set desc = "Authorizes your account in the panic bunker of any servers connected to this function."
+ set category = "OOC"
+
+ world.send_cross_server_bunker_overrides(key, src)
+
+/world/proc/send_cross_server_bunker_overrides(key, client/C)
+ var/comms_key = CONFIG_GET(string/comms_key)
+ if(!comms_key)
+ return
+ var/list/message = list()
+ message["ckey"] = key
+ message["source"] = "[CONFIG_GET(string/cross_comms_name)]"
+ message["key"] = comms_key
+ message["auto_bunker_override"] = TRUE
+ var/list/servers = CONFIG_GET(keyed_list/cross_server_bunker_override)
+ if(!length(servers))
+ to_chat(C, "AUTOBUNKER: No servers are configured to receive from this one.")
+ return
+ var/logtext = "[key] ([key_name(C)]) has initiated an autobunker authentication with linked servers."
+ message_admins(logtext)
+ log_admin(logtext)
+ for(var/name in servers)
+ var/returned = world.Export("[servers[name]]?[list2params(message)]")
+ switch(returned)
+ if("Bad Key")
+ to_chat(C, "AUTOBuNKER: [name] failed to authenticate with this server.")
+ if("Function Disabled")
+ to_chat(C, "AUTOBUNKER: [name] has autobunker receive disabled.")
+ if("Success")
+ to_chat(C, "AUTOBUNKER: Successfully authenticated with [name]. Panic bunker bypass granted to [key]..")
+ else
+ to_chat(C, "AUTOBUNKER: Unknown error ([name]).")
diff --git a/tgstation.dme b/tgstation.dme
index 78cce84a0c..21f167de78 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -1792,6 +1792,7 @@
#include "code\modules\client\preferences_toggles.dm"
#include "code\modules\client\preferences_vr.dm"
#include "code\modules\client\verbs\aooc.dm"
+#include "code\modules\client\verbs\autobunker.dm"
#include "code\modules\client\verbs\etips.dm"
#include "code\modules\client\verbs\looc.dm"
#include "code\modules\client\verbs\minimap.dm"
From d6a7f91b81fb76988a8e69b48c6d03d25c8bab58 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Mon, 29 Jun 2020 04:45:05 -0700
Subject: [PATCH 2/4] Update autobunker.dm
---
code/modules/client/verbs/autobunker.dm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/code/modules/client/verbs/autobunker.dm b/code/modules/client/verbs/autobunker.dm
index 7fba73bda8..8954901eef 100644
--- a/code/modules/client/verbs/autobunker.dm
+++ b/code/modules/client/verbs/autobunker.dm
@@ -2,6 +2,12 @@
set name = "Auto Authorize Panic Bunker"
set desc = "Authorizes your account in the panic bunker of any servers connected to this function."
set category = "OOC"
+
+ var/static/lastuse = 0
+ if(lastuse + 5 SECONDS > world.time)
+ to_chat(src, "Function on cooldown, try again in 5 seconds.")
+ return
+ lastuse = world.time
world.send_cross_server_bunker_overrides(key, src)
From ae5fb008c737759defbdf9e2c385ad370e9c95fe Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Sat, 4 Jul 2020 00:13:34 -0700
Subject: [PATCH 3/4] Update client_defines.dm
---
code/modules/client/client_defines.dm | 2 ++
1 file changed, 2 insertions(+)
diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm
index 0402dc683f..0901c110b9 100644
--- a/code/modules/client/client_defines.dm
+++ b/code/modules/client/client_defines.dm
@@ -19,6 +19,8 @@
///Next tick to reset the total message counter
var/total_count_reset = 0
var/ircreplyamount = 0
+ /// last time they tried to do an autobunker auth
+ var/autobunker_last_try = 0
/////////
//OTHER//
From 03aa8fcc2be56615e5f8b8e1f89d4f72c6d5726e Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Sat, 4 Jul 2020 00:14:32 -0700
Subject: [PATCH 4/4] Update autobunker.dm
---
code/modules/client/verbs/autobunker.dm | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/code/modules/client/verbs/autobunker.dm b/code/modules/client/verbs/autobunker.dm
index 8954901eef..03200c5f0b 100644
--- a/code/modules/client/verbs/autobunker.dm
+++ b/code/modules/client/verbs/autobunker.dm
@@ -3,11 +3,10 @@
set desc = "Authorizes your account in the panic bunker of any servers connected to this function."
set category = "OOC"
- var/static/lastuse = 0
- if(lastuse + 5 SECONDS > world.time)
+ if(autobunker_last_try + 5 SECONDS > world.time)
to_chat(src, "Function on cooldown, try again in 5 seconds.")
return
- lastuse = world.time
+ autobunker_last_try = world.time
world.send_cross_server_bunker_overrides(key, src)
@@ -24,9 +23,7 @@
if(!length(servers))
to_chat(C, "AUTOBUNKER: No servers are configured to receive from this one.")
return
- var/logtext = "[key] ([key_name(C)]) has initiated an autobunker authentication with linked servers."
- message_admins(logtext)
- log_admin(logtext)
+ log_admin("[key] ([key_name(C)]) has initiated an autobunker authentication with linked servers.")
for(var/name in servers)
var/returned = world.Export("[servers[name]]?[list2params(message)]")
switch(returned)