Merge pull request #5857 from Citadel-Station-13/upstream-merge-35947

[MIRROR] [READY] NTNet airlocks
This commit is contained in:
deathride58
2018-03-09 19:24:35 +00:00
committed by GitHub
14 changed files with 232 additions and 157 deletions
+21 -4
View File
@@ -6,7 +6,24 @@
var/plaintext_data
var/plaintext_data_secondary
var/plaintext_passkey
var/encrypted_passkey
var/list/passkey
// Process data before sending it
/datum/netdata/proc/pre_send(datum/component/ntnet_interface/interface)
// Decrypt the passkey.
if(encrypted_passkey && !passkey)
passkey = json_decode(XorEncrypt(hextostr(encrypted_passkey, TRUE), SScircuit.cipherkey))
// Encrypt the passkey.
if(!encrypted_passkey && passkey)
encrypted_passkey = strtohex(XorEncrypt(json_encode(passkey), SScircuit.cipherkey))
// If there is no sender ID, set the default one.
if(!sender_id && interface)
sender_id = interface.hardware_id
/datum/netdata/proc/json_list_generation_admin() //for admin logs and such.
. = list()
@@ -21,9 +38,9 @@
. = list()
.["recipient_ids"] = recipient_ids
.["sender_id"] = sender_id
.["plaintext_data"] = plaintext_data
.["plaintext_data_secondary"] = plaintext_data_secondary
.["plaintext_passkey"] = plaintext_passkey
.["data"] = plaintext_data
.["data_secondary"] = plaintext_data_secondary
.["passkey"] = encrypted_passkey
/datum/netdata/proc/generate_netlog()
return "[json_encode(json_list_generation_netlog())]"
@@ -0,0 +1,37 @@
/obj/item/integrated_circuit/input/card_reader
name = "card reader"
desc = "A circuit that can read registred name, assignment and a PassKey string from an ID card."
icon_state = "card_reader"
complexity = 4
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
outputs = list(
"registered name" = IC_PINTYPE_STRING,
"assignment" = IC_PINTYPE_STRING,
"passkey" = IC_PINTYPE_STRING
)
activators = list(
"on read" = IC_PINTYPE_PULSE_OUT
)
/obj/item/integrated_circuit/input/card_reader/attackby_react(obj/item/I, mob/living/user, intent)
var/obj/item/card/id/card = I.GetID()
var/list/access = I.GetAccess()
var/passkey = strtohex(XorEncrypt(json_encode(access), SScircuit.cipherkey))
if(card) // An ID card.
set_pin_data(IC_OUTPUT, 1, card.registered_name)
set_pin_data(IC_OUTPUT, 2, card.assignment)
else if(length(access)) // A non-card object that has access levels.
set_pin_data(IC_OUTPUT, 1, null)
set_pin_data(IC_OUTPUT, 2, null)
else
return FALSE
set_pin_data(IC_OUTPUT, 3, passkey)
push_data()
activate_pin(1)
return TRUE
@@ -629,17 +629,16 @@
var/datum/netdata/data = new
data.recipient_ids = splittext(target_address, ";")
data.sender_id = address
data.plaintext_data = message
data.plaintext_data_secondary = text
data.plaintext_passkey = key
data.encrypted_passkey = key
ntnet_send(data)
/obj/item/integrated_circuit/input/ntnet_recieve(datum/netdata/data)
set_pin_data(IC_OUTPUT, 1, data.sender_id)
set_pin_data(IC_OUTPUT, 2, data.plaintext_data)
set_pin_data(IC_OUTPUT, 3, data.plaintext_data_secondary)
set_pin_data(IC_OUTPUT, 4, data.plaintext_passkey)
set_pin_data(IC_OUTPUT, 4, data.encrypted_passkey)
push_data()
activate_pin(2)
+18 -35
View File
@@ -1,9 +1,4 @@
/obj/var/list/req_access = null
/obj/var/req_access_txt = "0" as text
/obj/var/list/req_one_access = null
/obj/var/req_one_access_txt = "0" as text
//returns TRUE if this mob has sufficient access to use this object
/obj/proc/allowed(mob/M)
//check if it doesn't require any access at all
@@ -60,48 +55,36 @@
for(var/b in text2access(req_one_access_txt))
req_one_access += b
// Check if an item has access to this object
/obj/proc/check_access(obj/item/I)
return check_access_list(I ? I.GetAccess() : null)
/obj/proc/check_access_list(list/access_list)
gen_access()
if(!istype(src.req_access, /list)) //something's very wrong
if(!islist(req_access)) //something's very wrong
return TRUE
var/list/L = src.req_access
if(!L.len && (!src.req_one_access || !src.req_one_access.len)) //no requirements
if(!req_access.len && !length(req_one_access))
return TRUE
if(!I)
if(!length(access_list) || !islist(access_list))
return FALSE
for(var/req in src.req_access)
if(!(req in I.GetAccess())) //doesn't have this access
for(var/req in req_access)
if(!(req in access_list)) //doesn't have this access
return FALSE
if(src.req_one_access && src.req_one_access.len)
for(var/req in src.req_one_access)
if(req in I.GetAccess()) //has an access from the single access list
if(length(req_one_access))
for(var/req in req_one_access)
if(req in access_list) //has an access from the single access list
return TRUE
return FALSE
return TRUE
/obj/proc/check_access_list(list/L)
if(!src.req_access && !src.req_one_access)
return TRUE
if(!istype(src.req_access, /list))
return TRUE
if(!src.req_access.len && (!src.req_one_access || !src.req_one_access.len))
return TRUE
if(!L)
return FALSE
if(!istype(L, /list))
return FALSE
for(var/req in src.req_access)
if(!(req in L)) //doesn't have this access
return FALSE
if(src.req_one_access && src.req_one_access.len)
for(var/req in src.req_one_access)
if(req in L) //has an access from the single access list
return TRUE
return FALSE
return TRUE
/obj/proc/check_access_ntnet(datum/netdata/data)
return check_access_list(data.passkey)
/proc/get_centcom_access(job)
switch(job)
+1
View File
@@ -182,6 +182,7 @@
var/obj/item/card/id/C = H.wear_id
if(istype(C))
C.access = J.get_access()
shuffle_inplace(C.access) // Shuffle access list to make NTNet passkeys less predictable
C.registered_name = H.real_name
C.assignment = J.title
C.update_label()