diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 03f49658c8..35f7d9c3df 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -1259,6 +1259,13 @@ opencomputers { # string from the clipboard (Shift+Ins on a screen with a keyboard). maxClipboard: 1024 + # The TTL (Time-To-Live) upon creation of a network packet. When a packet + # passes through a Relay, its TTL is decremented. If a Relay receives a + # packet with a TTL of 0, the packet is dropped. Minimum value is 5. + # Note: increasing this value to large numbers may have an significant + # impact on performances. + initialNetworkPacketTTL: 5 + # The maximum size of network packets to allow sending via network cards. # This has *nothing to do* with real network traffic, it's just a limit # for the network cards, mostly to reduce the chance of computer with a diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index d44e4643e0..ec841efdaf 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -346,6 +346,7 @@ class Settings(val config: Config) { val maxScreenWidth = config.getInt("misc.maxScreenWidth") max 1 val maxScreenHeight = config.getInt("misc.maxScreenHeight") max 1 val inputUsername = config.getBoolean("misc.inputUsername") + val initialNetworkPacketTTL = config.getInt("misc.initialNetworkPacketTTL") max 5 val maxNetworkPacketSize = config.getInt("misc.maxNetworkPacketSize") max 0 // Need at least 4 for nanomachine protocol. Because I can! val maxNetworkPacketParts = config.getInt("misc.maxNetworkPacketParts") max 4 diff --git a/src/main/scala/li/cil/oc/server/network/Network.scala b/src/main/scala/li/cil/oc/server/network/Network.scala index 62f065fb06..616dae497e 100644 --- a/src/main/scala/li/cil/oc/server/network/Network.scala +++ b/src/main/scala/li/cil/oc/server/network/Network.scala @@ -702,7 +702,7 @@ object Network extends api.detail.NetworkAPI { // ----------------------------------------------------------------------- // - class Packet(var source: String, var destination: String, var port: Int, var data: Array[AnyRef], var ttl: Int = 5) extends api.network.Packet { + class Packet(var source: String, var destination: String, var port: Int, var data: Array[AnyRef], var ttl: Int = Settings.get.initialNetworkPacketTTL) extends api.network.Packet { val size = Option(data).fold(0)(values => { if (values.length > Settings.get.maxNetworkPacketParts) { throw new IllegalArgumentException("packet has too many parts")