mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
[MIRROR] The Great Radio Rework: NTNET Part 1 of many. (#2384)
* The Great Radio Rework: NTNET Part 1 of many. * Update airlock.dm Co-authored-by: WarlockD <warlockd@gmail.com> Co-authored-by: Gandalf2k15 <jzo123@hotmail.com>
This commit is contained in:
co-authored by
WarlockD
Gandalf2k15
parent
12841a4c68
commit
4c5433d5cf
@@ -1,20 +1,102 @@
|
||||
/datum/netdata //this requires some thought later on but for now it's fine.
|
||||
var/network_id
|
||||
// This netlink class shares a list to two devices
|
||||
// This allows skipping of sending many many packets
|
||||
// just to update simple data
|
||||
/datum/netlink
|
||||
var/server_id
|
||||
var/server_network
|
||||
var/port
|
||||
var/passkey = null // sends auth data used to check if we can connect or send data to a device
|
||||
var/list/data
|
||||
|
||||
var/autopasskey = TRUE
|
||||
/datum/netlink/New(datum/component/ntnet_interface/conn, port)
|
||||
data = conn.registered_sockets[port]
|
||||
ASSERT(data != null)
|
||||
server_id = conn.hardware_id
|
||||
server_network = conn.network.network_id
|
||||
src.port = port
|
||||
RegisterSignal(conn, COMSIG_COMPONENT_NTNET_PORT_DESTROYED, .proc/_server_disconnected)
|
||||
..()
|
||||
|
||||
var/list/recipient_ids = list()
|
||||
/datum/netlink/proc/_server_disconnected(datum/component/com)
|
||||
SIGNAL_HANDLER
|
||||
data = null
|
||||
|
||||
/datum/netlink/Destroy()
|
||||
passkey = null
|
||||
data = null
|
||||
return ..()
|
||||
|
||||
// If you don't want to use this fine, but this just shows how the system works
|
||||
|
||||
// I hate you all. I want to operator overload []
|
||||
// So fuck you all, Do NOT access data directly you freaks
|
||||
// or this breaks god knows what.
|
||||
// FINE, you don't have to use get, is dirty or even clean
|
||||
// proc overhead is WAY more important than fucking clarity or
|
||||
// sealed classes. But for the LOVE OF GOD make sure _updated
|
||||
// is set if your going to do this.
|
||||
/datum/netlink/proc/get(idx)
|
||||
return data ? data[idx] : null
|
||||
|
||||
/datum/netlink/proc/put(idx, V)
|
||||
// is it posable to do this async without worry about racing conditions?
|
||||
if(data && data[idx] != V)
|
||||
data["_updated"] = TRUE
|
||||
data[idx] = V
|
||||
|
||||
|
||||
/datum/netlink/proc/is_dirty()
|
||||
return data && data["_updated"]
|
||||
|
||||
/datum/netlink/proc/clean()
|
||||
if(data)
|
||||
data["_updated"] = FALSE
|
||||
|
||||
/datum/netlink/proc/is_connected()
|
||||
return data != null
|
||||
|
||||
|
||||
|
||||
/datum/netdata
|
||||
//this requires some thought later on but for now it's fine. (WarlockD) ARRRRG
|
||||
// Packets are kind of shaped like IPX. IPX had a network, a node (aka id) and a port.
|
||||
// Special case with receiver_id == null, that wil broadcast to the network_id
|
||||
// Also, if the network id is not the same for both sender and receiver the packet is dropped.
|
||||
var/sender_id
|
||||
var/broadcast = FALSE //Whether this is a broadcast packet.
|
||||
|
||||
var/receiver_id
|
||||
var/network_id
|
||||
var/passkey = null // sends auth data used to check if we can connect or send data to a device
|
||||
var/list/data = list()
|
||||
// Used for packet queuing
|
||||
var/datum/netdata/next = null
|
||||
var/mob/user = null // used for sending error messages
|
||||
|
||||
var/list/passkey
|
||||
/datum/netdata/New(list/data = null)
|
||||
if(!data)
|
||||
data = list()
|
||||
src.data = data
|
||||
|
||||
/datum/netdata/proc/standard_format_data(primary, secondary, passkey)
|
||||
data["data"] = primary
|
||||
data["data_secondary"] = secondary
|
||||
data["encrypted_passkey"] = passkey
|
||||
/datum/netdata/Destroy()
|
||||
data = null
|
||||
passkey = null
|
||||
next = null
|
||||
user = null
|
||||
return ..()
|
||||
|
||||
/datum/netdata/proc/clone(deep_copy=FALSE)
|
||||
var/datum/netdata/C = new
|
||||
C.sender_id = sender_id
|
||||
C.receiver_id = receiver_id
|
||||
C.network_id = network_id
|
||||
C.passkey = passkey
|
||||
C.user = user
|
||||
C.next = null
|
||||
if(deep_copy)
|
||||
C.data = deepCopyList(data)
|
||||
else
|
||||
C.data = data
|
||||
return C
|
||||
|
||||
|
||||
/datum/netdata/proc/json_to_data(json)
|
||||
data = json_decode(json)
|
||||
@@ -32,12 +114,12 @@
|
||||
/datum/netdata/proc/json_list_generation()
|
||||
. = list()
|
||||
. |= json_list_generation_netlog()
|
||||
.["network_id"] = network_id
|
||||
|
||||
/datum/netdata/proc/json_list_generation_netlog()
|
||||
. = list()
|
||||
.["recipient_ids"] = recipient_ids
|
||||
.["network_id"] = network_id
|
||||
.["sender_id"] = sender_id
|
||||
.["receiver_id"] = receiver_id
|
||||
.["data_list"] = data
|
||||
|
||||
/datum/netdata/proc/generate_netlog()
|
||||
|
||||
+271
-123
@@ -1,21 +1,247 @@
|
||||
/*
|
||||
* # /datum/ntnet
|
||||
*
|
||||
* This class defines each network of the world. Each root network is accessible by any device
|
||||
* on the same network but NOT accessible to any other "root" networks. All normal devices only have
|
||||
* one network and one network_id.
|
||||
*
|
||||
* This thing replaces radio. Think of wifi but better, bigger and bolder! The idea is that any device
|
||||
* on a network can reach any other device on that same network if it knows the hardware_id. You can also
|
||||
* search or broadcast to devices if you know what branch you wish. That is to say you can broadcast to all
|
||||
* devices on "SS13.ATMOS.SCRUBBERS" to change the settings of all the scrubbers on the station or to
|
||||
* "SS13.AREA.FRED_HOME.SCRUBBERS" to all the scrubbers at one area. However devices CANNOT communicate cross
|
||||
* networks normality.
|
||||
*
|
||||
*/
|
||||
|
||||
/datum/ntnet
|
||||
var/network_id = "Network"
|
||||
var/list/connected_interfaces_by_id = list() //id = datum/component/ntnet_interface
|
||||
/// The full network name for this network ex. SS13.ATMOS.SCRUBBERS
|
||||
var/network_id
|
||||
/// The network name part of this leaf ex ATMOS
|
||||
var/network_node_id
|
||||
/// All devices on this network. ALL devices on this network, not just this branch.
|
||||
/// This list is shared between all leaf networks so we don't have to keep going to the
|
||||
/// parents on lookups. It is an associated list of hardware_id AND tag_id's
|
||||
var/list/root_devices
|
||||
/// This lists has all the networks in this node. Each name is fully qualified
|
||||
/// ie. SS13.ATMOS.SCRUBBERS, SS13.ATMOS.VENTS, etc
|
||||
var/list/networks
|
||||
/// All the devices on this branch of the network
|
||||
var/list/linked_devices
|
||||
/// Network children. Associated list using the network_node_id of the child as the key
|
||||
var/list/children
|
||||
/// Parrnt of the network. If this is null, we are a oot network
|
||||
var/datum/ntnet/parent
|
||||
|
||||
|
||||
/*
|
||||
* Creates a new network
|
||||
*
|
||||
* Used for /datum/controller/subsystem/networks/proc/create_network so do not
|
||||
* call yourself as new doesn't do any checking itself
|
||||
*
|
||||
* Arguments:
|
||||
* * net_id - Fully qualified network id for this network
|
||||
* * net_part_id - sub part of a network if this is a child of P
|
||||
* * P - Parent network, this will be attached to that network.
|
||||
*/
|
||||
/datum/ntnet/New(net_id, net_part_id, datum/ntnet/P = null)
|
||||
linked_devices = list()
|
||||
children = list()
|
||||
network_id = net_id
|
||||
|
||||
if(P)
|
||||
network_node_id = net_part_id
|
||||
parent = P
|
||||
parent.children[network_node_id] = src
|
||||
root_devices = parent.root_devices
|
||||
networks = parent.networks
|
||||
else
|
||||
network_node_id = net_id
|
||||
parent = null
|
||||
networks = list()
|
||||
root_devices = list()
|
||||
SSnetworks.root_networks[network_id] = src
|
||||
|
||||
SSnetworks.networks[network_id] = src
|
||||
|
||||
SSnetworks.add_log("Network was created: [network_id]")
|
||||
|
||||
return ..()
|
||||
|
||||
/// A network should NEVER be deleted. If you don't want to show it exists just check if its
|
||||
/// empty
|
||||
/datum/ntnet/Destroy()
|
||||
if(children.len > 0 || linked_devices.len > 0)
|
||||
CRASH("Trying to delete a network with devices still in them")
|
||||
|
||||
if(parent)
|
||||
parent.children.Remove(network_id)
|
||||
parent = null
|
||||
else
|
||||
SSnetworks.root_networks.Remove(network_id)
|
||||
|
||||
SSnetworks.networks.Remove(network_id)
|
||||
|
||||
root_devices = null
|
||||
networks = null
|
||||
network_node_id = null
|
||||
SSnetworks.add_log("Network was destroyed: [network_id]")
|
||||
network_id = null
|
||||
|
||||
return ..()
|
||||
|
||||
/*
|
||||
* Collects all the devices on this branch of the network and maybe its
|
||||
* children
|
||||
*
|
||||
* Used for broadcasting, this will collect all the interfaces on this
|
||||
* network and by default everything below this branch. Will return an
|
||||
* empty list if no devices were found
|
||||
*
|
||||
* Arguments:
|
||||
* * include_children - Include the children of all branches below this
|
||||
*/
|
||||
/datum/ntnet/proc/collect_interfaces(include_children=TRUE)
|
||||
if(!include_children || children.len == 0)
|
||||
return linked_devices.Copy()
|
||||
else
|
||||
/// Please no recursion. Byond hates recursion
|
||||
var/list/devices = list()
|
||||
var/list/queue = list(src) // add ourselves
|
||||
while(queue.len)
|
||||
var/datum/ntnet/net = queue[queue.len--]
|
||||
if(net.children.len > 0)
|
||||
for(var/net_id in net.children)
|
||||
queue += networks[net_id]
|
||||
devices += net.linked_devices
|
||||
return devices
|
||||
|
||||
|
||||
/*
|
||||
* Find if an interface exists on this network
|
||||
*
|
||||
* Used to look up a device on the network.
|
||||
*
|
||||
* Arguments:
|
||||
* * tag_or_hid - Ither the hardware id or the id_tag
|
||||
*/
|
||||
/datum/ntnet/proc/find_interface(tag_or_hid)
|
||||
return root_devices[tag_or_hid]
|
||||
|
||||
/**
|
||||
* Add this interface to this branch of the network.
|
||||
*
|
||||
* This will add a network interface to this branch of the network.
|
||||
* If the interface already exists on the network it will add it and
|
||||
* give the alias list in the interface this branch name. If the interface
|
||||
* has an id_tag it will add that name to the root_devices for map lookup
|
||||
*
|
||||
* Arguments:
|
||||
* * interface - ntnet component of the device to add to the network
|
||||
*/
|
||||
/datum/ntnet/proc/add_interface(datum/component/ntnet_interface/interface)
|
||||
if(interface.network)
|
||||
if(!networks[interface.network.network_id])
|
||||
/// If we are doing a hard jump to a new network, log it
|
||||
log_telecomms("The device {[interface.hardware_id]} is jumping networks from '[interface.network.network_id]' to '[network_id]'")
|
||||
interface.network.remove_interface(interface, TRUE)
|
||||
else // we are on the same network so we just want to be aliased to another branch
|
||||
if(!interface.alias[network_id])
|
||||
interface.alias[network_id] = src // add to the alias list
|
||||
linked_devices[interface.hardware_id] = interface
|
||||
else
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to join '[network_id]' for a second time!")
|
||||
return
|
||||
// we have no network
|
||||
interface.network = src // now we do!
|
||||
interface.alias[network_id] = src // add to the alias just to make removing easier.
|
||||
linked_devices[interface.hardware_id] = interface
|
||||
root_devices[interface.hardware_id] = interface
|
||||
if(interface.id_tag != null) // could be a type, never know
|
||||
root_devices[interface.id_tag] = interface
|
||||
|
||||
/*
|
||||
* Remove this interface from the network
|
||||
*
|
||||
* This will remove an interface from this network and null the network field on the
|
||||
* interface. Be sure that add_interface is run as soon as posable as an interface MUST
|
||||
* have a network
|
||||
*
|
||||
* Arguments:
|
||||
* * interface - ntnet component of the device to remove to the network
|
||||
* * remove_all_alias - remove ALL references to this device on this network
|
||||
*/
|
||||
/datum/ntnet/proc/remove_interface(datum/component/ntnet_interface/interface, remove_all_alias=FALSE)
|
||||
if(!interface.alias[network_id])
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to leave a '[network_id]'' when its on '[interface.network.network_id]'")
|
||||
return
|
||||
// just cashing it
|
||||
var/hardware_id = interface.hardware_id
|
||||
// Handle the quick case
|
||||
interface.alias.Remove(network_id)
|
||||
linked_devices.Remove(hardware_id)
|
||||
if(remove_all_alias)
|
||||
var/datum/ntnet/net
|
||||
for(var/id in interface.alias)
|
||||
net = interface.alias[id]
|
||||
net.linked_devices.Remove(hardware_id)
|
||||
|
||||
// Now check if there are more than meets the eye
|
||||
if(interface.network == src || remove_all_alias)
|
||||
// Ok, so we got to remove this network, but if we have an alias we are still "on" the network
|
||||
// so we need to shift down to one of the other networks on the alias list. If the alias list
|
||||
// is empty, fuck it and remove it from the network.
|
||||
if(interface.alias.len > 0)
|
||||
interface.network = interface.alias[1] // ... whatever is there.
|
||||
else
|
||||
// ok, hard remove from everything then
|
||||
root_devices.Remove(interface.hardware_id)
|
||||
if(interface.id_tag != null) // could be a type, never know
|
||||
root_devices.Remove(interface.id_tag)
|
||||
interface.network = null
|
||||
|
||||
/*
|
||||
* Move interface to another branch of the network
|
||||
*
|
||||
* This function is a lightweight way of moving an interface from one branch to another like a gps
|
||||
* device going from one area to another. Target network MUST be this network or it will fail
|
||||
*
|
||||
* Arguments:
|
||||
* * interface - ntnet component of the device to move
|
||||
* * target_network - qualified network id to move to
|
||||
* * original_network - qualified network id from the original network if not this one
|
||||
*/
|
||||
/datum/ntnet/proc/move_interface(datum/component/ntnet_interface/interface, target_network, original_network = null)
|
||||
var/datum/ntnet/net = original_network == null ? src : networks[original_network]
|
||||
var/datum/ntnet/target = networks[target_network]
|
||||
if(!target || !net)
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to move to a network ([target_network]) that is not on ([network_id])")
|
||||
return
|
||||
if(target.linked_devices[interface.hardware_id])
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to move to a network ([target_network]) it is already on.")
|
||||
return
|
||||
if(!net.linked_devices[interface.hardware_id])
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to move to a network ([target_network]) but its not on ([net.network_id]) ")
|
||||
return
|
||||
net.linked_devices.Remove(interface.hardware_id)
|
||||
target.linked_devices[interface.hardware_id] = interface
|
||||
interface.alias.Remove(net.network_id)
|
||||
interface.alias[target.network_id] = target
|
||||
|
||||
|
||||
|
||||
/datum/ntnet/station_root
|
||||
var/list/services_by_path = list() //type = datum/ntnet_service
|
||||
var/list/services_by_id = list() //id = datum/ntnet_service
|
||||
|
||||
var/list/autoinit_service_paths = list() //typepaths
|
||||
|
||||
|
||||
var/list/relays = list()
|
||||
var/list/logs = list()
|
||||
var/list/available_station_software = list()
|
||||
var/list/available_antag_software = list()
|
||||
var/list/chat_channels = list()
|
||||
var/list/fileservers = list()
|
||||
// Amount of logs the system tries to keep in memory. Keep below 999 to prevent byond from acting weirdly.
|
||||
// High values make displaying logs much laggier.
|
||||
var/setting_maxlogcount = 100
|
||||
|
||||
// These only affect wireless. LAN (consoles) are unaffected since it would be possible to create scenario where someone turns off NTNet, and is unable to turn it back on since it refuses connections
|
||||
var/setting_softwaredownload = TRUE
|
||||
@@ -28,44 +254,28 @@
|
||||
var/intrusion_detection_alarm = FALSE // Set when there is an IDS warning due to malicious (antag) software.
|
||||
|
||||
// If new NTNet datum is spawned, it replaces the old one.
|
||||
/datum/ntnet/New(_netid)
|
||||
build_software_lists()
|
||||
add_log("NTNet logging system activated.")
|
||||
if(_netid)
|
||||
network_id = _netid
|
||||
if(!SSnetworks.register_network(src))
|
||||
stack_trace("Network [type] with ID [network_id] failed to register and has been deleted.")
|
||||
qdel(src)
|
||||
/datum/ntnet/station_root/New(root_name)
|
||||
. = ..()
|
||||
SSnetworks.add_log("NTNet logging system activated for [root_name]")
|
||||
|
||||
/datum/ntnet/Destroy()
|
||||
for(var/i in connected_interfaces_by_id)
|
||||
var/datum/component/ntnet_interface/I = i
|
||||
I.unregister_connection(src)
|
||||
|
||||
|
||||
|
||||
#ifdef NTNET_SERVICE
|
||||
/datum/ntnet/station_root/Destroy()
|
||||
for(var/i in services_by_id)
|
||||
var/datum/ntnet_service/S = i
|
||||
var/S = i
|
||||
S.disconnect(src, TRUE)
|
||||
return ..()
|
||||
|
||||
/datum/ntnet/proc/interface_connect(datum/component/ntnet_interface/I)
|
||||
if(connected_interfaces_by_id[I.hardware_id])
|
||||
return FALSE
|
||||
connected_interfaces_by_id[I.hardware_id] = I
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet/proc/interface_disconnect(datum/component/ntnet_interface/I)
|
||||
connected_interfaces_by_id -= I.hardware_id
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet/proc/find_interface_id(id)
|
||||
return connected_interfaces_by_id[id]
|
||||
|
||||
/datum/ntnet/proc/find_service_id(id)
|
||||
/datum/ntnet/station_root/proc/find_service_id(id)
|
||||
return services_by_id[id]
|
||||
|
||||
/datum/ntnet/proc/find_service_path(path)
|
||||
/datum/ntnet/station_root/proc/find_service_path(path)
|
||||
return services_by_path[path]
|
||||
|
||||
/datum/ntnet/proc/register_service(datum/ntnet_service/S)
|
||||
/datum/ntnet/station_root/proc/register_service(datum/ntnet_service/S)
|
||||
if(!istype(S))
|
||||
return FALSE
|
||||
if(services_by_path[S.type] || services_by_id[S.id])
|
||||
@@ -74,14 +284,14 @@
|
||||
services_by_id[S.id] = S
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet/proc/unregister_service(datum/ntnet_service/S)
|
||||
/datum/ntnet/station_root/proc/unregister_service(datum/ntnet_service/S)
|
||||
if(!istype(S))
|
||||
return FALSE
|
||||
services_by_path -= S.type
|
||||
services_by_id -= S.id
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet/proc/create_service(type)
|
||||
/datum/ntnet/station_root/proc/create_service(type)
|
||||
var/datum/ntnet_service/S = new type
|
||||
if(!istype(S))
|
||||
return FALSE
|
||||
@@ -89,7 +299,7 @@
|
||||
if(!.)
|
||||
qdel(S)
|
||||
|
||||
/datum/ntnet/proc/destroy_service(type)
|
||||
/datum/ntnet/station_root/proc/destroy_service(type)
|
||||
var/datum/ntnet_service/S = find_service_path(type)
|
||||
if(!istype(S))
|
||||
return FALSE
|
||||
@@ -97,69 +307,21 @@
|
||||
if(.)
|
||||
qdel(src)
|
||||
|
||||
/datum/ntnet/proc/process_data_transmit(datum/component/ntnet_interface/sender, datum/netdata/data)
|
||||
if(!check_relay_operation())
|
||||
return FALSE
|
||||
data.network_id = src
|
||||
log_data_transfer(data)
|
||||
var/list/datum/component/ntnet_interface/receiving = list()
|
||||
if((length(data.recipient_ids == 1) && data.recipient_ids[1] == NETWORK_BROADCAST_ID) || data.recipient_ids == NETWORK_BROADCAST_ID)
|
||||
data.broadcast = TRUE
|
||||
for(var/i in connected_interfaces_by_id)
|
||||
receiving |= connected_interfaces_by_id[i]
|
||||
else
|
||||
for(var/i in data.recipient_ids)
|
||||
var/datum/component/ntnet_interface/receiver = find_interface_id(i)
|
||||
receiving |= receiver
|
||||
|
||||
for(var/i in receiving)
|
||||
var/datum/component/ntnet_interface/receiver = i
|
||||
if(receiver)
|
||||
receiver.__network_receive(data)
|
||||
|
||||
for(var/i in services_by_id)
|
||||
var/datum/ntnet_service/serv = services_by_id[i]
|
||||
serv.ntnet_intercept(data, src, sender)
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet/proc/check_relay_operation(zlevel) //can be expanded later but right now it's true/false.
|
||||
for(var/i in relays)
|
||||
var/obj/machinery/ntnet_relay/n = i
|
||||
if(zlevel && n.z != zlevel)
|
||||
continue
|
||||
if(n.is_operational)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/datum/ntnet/proc/log_data_transfer(datum/netdata/data)
|
||||
logs += "[station_time_timestamp()] - [data.generate_netlog()]"
|
||||
if(logs.len > setting_maxlogcount)
|
||||
logs = logs.Copy(logs.len - setting_maxlogcount, 0)
|
||||
return
|
||||
|
||||
// Simplified logging: Adds a log. log_string is mandatory parameter, source is optional.
|
||||
/datum/ntnet/proc/add_log(log_string, obj/item/computer_hardware/network_card/source = null)
|
||||
var/log_text = "[station_time_timestamp()] - "
|
||||
if(source)
|
||||
log_text += "[source.get_network_tag()] - "
|
||||
else
|
||||
log_text += "*SYSTEM* - "
|
||||
log_text += log_string
|
||||
logs.Add(log_text)
|
||||
|
||||
// We have too many logs, remove the oldest entries until we get into the limit
|
||||
if(logs.len > setting_maxlogcount)
|
||||
logs = logs.Copy(logs.len-setting_maxlogcount,0)
|
||||
|
||||
/datum/ntnet/station_root/proc/process_data_transmit(datum/component/ntnet_interface/sender, datum/netdata/data)
|
||||
if(..())
|
||||
for(var/i in services_by_id)
|
||||
var/datum/ntnet_service/serv = services_by_id[i]
|
||||
serv.ntnet_intercept(data, src, sender)
|
||||
return TRUE
|
||||
#endif
|
||||
|
||||
// Checks whether NTNet operates. If parameter is passed checks whether specific function is enabled.
|
||||
/datum/ntnet/proc/check_function(specific_action = 0)
|
||||
if(!relays || !relays.len) // No relays found. NTNet is down
|
||||
/datum/ntnet/station_root/proc/check_function(specific_action = 0)
|
||||
if(!SSnetworks.relays || !SSnetworks.relays.len) // No relays found. NTNet is down
|
||||
return FALSE
|
||||
|
||||
// Check all relays. If we have at least one working relay, network is up.
|
||||
if(!check_relay_operation())
|
||||
if(!SSnetworks.check_relay_operation())
|
||||
return FALSE
|
||||
|
||||
if(setting_disabled)
|
||||
@@ -177,7 +339,7 @@
|
||||
return TRUE
|
||||
|
||||
// Builds lists that contain downloadable software.
|
||||
/datum/ntnet/proc/build_software_lists()
|
||||
/datum/ntnet/station_root/proc/build_software_lists()
|
||||
available_station_software = list()
|
||||
available_antag_software = list()
|
||||
for(var/F in typesof(/datum/computer_file/program))
|
||||
@@ -192,7 +354,7 @@
|
||||
available_antag_software.Add(prog)
|
||||
|
||||
// Attempts to find a downloadable file according to filename var
|
||||
/datum/ntnet/proc/find_ntnet_file_by_name(filename)
|
||||
/datum/ntnet/station_root/proc/find_ntnet_file_by_name(filename)
|
||||
for(var/N in available_station_software)
|
||||
var/datum/computer_file/program/P = N
|
||||
if(filename == P.filename)
|
||||
@@ -202,55 +364,41 @@
|
||||
if(filename == P.filename)
|
||||
return P
|
||||
|
||||
/datum/ntnet/proc/get_chat_channel_by_id(id)
|
||||
/datum/ntnet/station_root/proc/get_chat_channel_by_id(id)
|
||||
for(var/datum/ntnet_conversation/chan in chat_channels)
|
||||
if(chan.id == id)
|
||||
return chan
|
||||
|
||||
// Resets the IDS alarm
|
||||
/datum/ntnet/proc/resetIDS()
|
||||
/datum/ntnet/station_root/proc/resetIDS()
|
||||
intrusion_detection_alarm = FALSE
|
||||
|
||||
/datum/ntnet/proc/toggleIDS()
|
||||
/datum/ntnet/station_root/proc/toggleIDS()
|
||||
resetIDS()
|
||||
intrusion_detection_enabled = !intrusion_detection_enabled
|
||||
|
||||
// Removes all logs
|
||||
/datum/ntnet/proc/purge_logs()
|
||||
logs = list()
|
||||
add_log("-!- LOGS DELETED BY SYSTEM OPERATOR -!-")
|
||||
|
||||
// Updates maximal amount of stored logs. Use this instead of setting the number, it performs required checks.
|
||||
/datum/ntnet/proc/update_max_log_count(lognumber)
|
||||
if(!lognumber)
|
||||
return FALSE
|
||||
// Trim the value if necessary
|
||||
lognumber = max(MIN_NTNET_LOGS, min(lognumber, MAX_NTNET_LOGS))
|
||||
setting_maxlogcount = lognumber
|
||||
add_log("Configuration Updated. Now keeping [setting_maxlogcount] logs in system memory.")
|
||||
|
||||
/datum/ntnet/proc/toggle_function(function)
|
||||
/datum/ntnet/station_root/proc/toggle_function(function)
|
||||
if(!function)
|
||||
return
|
||||
function = text2num(function)
|
||||
switch(function)
|
||||
if(NTNET_SOFTWAREDOWNLOAD)
|
||||
setting_softwaredownload = !setting_softwaredownload
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_softwaredownload ? "allows" : "disallows"] connection to software repositories.")
|
||||
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_softwaredownload ? "allows" : "disallows"] connection to software repositories.")
|
||||
if(NTNET_PEERTOPEER)
|
||||
setting_peertopeer = !setting_peertopeer
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_peertopeer ? "allows" : "disallows"] peer to peer network traffic.")
|
||||
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_peertopeer ? "allows" : "disallows"] peer to peer network traffic.")
|
||||
if(NTNET_COMMUNICATION)
|
||||
setting_communication = !setting_communication
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_communication ? "allows" : "disallows"] instant messaging and similar communication services.")
|
||||
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_communication ? "allows" : "disallows"] instant messaging and similar communication services.")
|
||||
if(NTNET_SYSTEMCONTROL)
|
||||
setting_systemcontrol = !setting_systemcontrol
|
||||
add_log("Configuration Updated. Wireless network firewall now [setting_systemcontrol ? "allows" : "disallows"] remote control of station's systems.")
|
||||
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_systemcontrol ? "allows" : "disallows"] remote control of station's systems.")
|
||||
|
||||
/datum/ntnet/station
|
||||
network_id = "SS13-NTNET"
|
||||
|
||||
/datum/ntnet/station/proc/register_map_supremecy() //called at map init to make this what station networks use.
|
||||
|
||||
/datum/ntnet/station_root/proc/register_map_supremecy() //called at map init to make this what station networks use.
|
||||
for(var/obj/machinery/ntnet_relay/R in GLOB.machines)
|
||||
relays.Add(R)
|
||||
SSnetworks.relays.Add(R)
|
||||
R.NTNet = src
|
||||
|
||||
@@ -79,12 +79,12 @@
|
||||
if((dos_overload > dos_capacity) && !dos_failure)
|
||||
set_dos_failure(TRUE)
|
||||
update_icon()
|
||||
SSnetworks.station_network.add_log("Quantum relay switched from normal operation mode to overload recovery mode.")
|
||||
SSnetworks.add_log("Quantum relay switched from normal operation mode to overload recovery mode.")
|
||||
// If the DoS buffer reaches 0 again, restart.
|
||||
if((dos_overload == 0) && dos_failure)
|
||||
set_dos_failure(FALSE)
|
||||
update_icon()
|
||||
SSnetworks.station_network.add_log("Quantum relay switched from overload recovery mode to normal operation mode.")
|
||||
SSnetworks.add_log("Quantum relay switched from overload recovery mode to normal operation mode.")
|
||||
..()
|
||||
|
||||
/obj/machinery/ntnet_relay/ui_interact(mob/user, datum/tgui/ui)
|
||||
@@ -110,11 +110,11 @@
|
||||
dos_overload = 0
|
||||
set_dos_failure(FALSE)
|
||||
update_icon()
|
||||
SSnetworks.station_network.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
|
||||
SSnetworks.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
|
||||
return TRUE
|
||||
if("toggle")
|
||||
set_relay_enabled(!relay_enabled)
|
||||
SSnetworks.station_network.add_log("Quantum relay manually [relay_enabled ? "enabled" : "disabled"].")
|
||||
SSnetworks.add_log("Quantum relay manually [relay_enabled ? "enabled" : "disabled"].")
|
||||
update_icon()
|
||||
return TRUE
|
||||
|
||||
@@ -123,15 +123,15 @@
|
||||
component_parts = list()
|
||||
|
||||
if(SSnetworks.station_network)
|
||||
SSnetworks.station_network.relays.Add(src)
|
||||
SSnetworks.relays.Add(src)
|
||||
NTNet = SSnetworks.station_network
|
||||
SSnetworks.station_network.add_log("New quantum relay activated. Current amount of linked relays: [NTNet.relays.len]")
|
||||
SSnetworks.add_log("New quantum relay activated. Current amount of linked relays: [SSnetworks.relays.len]")
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/ntnet_relay/Destroy()
|
||||
if(SSnetworks.station_network)
|
||||
SSnetworks.station_network.relays.Remove(src)
|
||||
SSnetworks.station_network.add_log("Quantum relay connection severed. Current amount of linked relays: [NTNet.relays.len]")
|
||||
SSnetworks.relays.Remove(src)
|
||||
SSnetworks.add_log("Quantum relay connection severed. Current amount of linked relays: [SSnetworks.relays.len]")
|
||||
NTNet = null
|
||||
|
||||
for(var/datum/computer_file/program/ntnet_dos/D in dos_sources)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/datum/ntnet_service
|
||||
var/name = "Unidentified Network Service"
|
||||
var/id
|
||||
var/list/networks_by_id = list() //Yes we support multinetwork services!
|
||||
|
||||
/datum/ntnet_service/New()
|
||||
var/datum/component/ntnet_interface/N = AddComponent(/datum/component/ntnet_interface, id, name, FALSE)
|
||||
id = N.hardware_id
|
||||
|
||||
/datum/ntnet_service/Destroy()
|
||||
for(var/i in networks_by_id)
|
||||
var/datum/ntnet/N = i
|
||||
disconnect(N, TRUE)
|
||||
networks_by_id = null
|
||||
return ..()
|
||||
|
||||
/datum/ntnet_service/proc/connect(datum/ntnet/net)
|
||||
if(!istype(net))
|
||||
return FALSE
|
||||
var/datum/component/ntnet_interface/interface = GetComponent(/datum/component/ntnet_interface)
|
||||
if(!interface.register_connection(net))
|
||||
return FALSE
|
||||
if(!net.register_service(src))
|
||||
interface.unregister_connection(net)
|
||||
return FALSE
|
||||
networks_by_id[net.network_id] = net
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet_service/proc/disconnect(datum/ntnet/net, force = FALSE)
|
||||
if(!istype(net) || (!net.unregister_service(src) && !force))
|
||||
return FALSE
|
||||
var/datum/component/ntnet_interface/interface = GetComponent(/datum/component/ntnet_interface)
|
||||
interface.unregister_connection(net)
|
||||
networks_by_id -= net.network_id
|
||||
return TRUE
|
||||
|
||||
/datum/ntnet_service/proc/ntnet_intercept(datum/netdata/data, datum/ntnet/net, datum/component/ntnet_interface/sender)
|
||||
return
|
||||
Reference in New Issue
Block a user