Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-MC1.7.10' into master-MC1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Jan 4, 2025
2 parents 7ccc11a + fad5ad2 commit fa1ccb4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/li/cil/oc/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package li.cil.oc.server.machine.luac

import java.io.BufferedInputStream
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
Expand Down Expand Up @@ -242,8 +243,8 @@ abstract class LuaStateFactory {
if (tmpLibFile.exists()) {
var matching = true
try {
val inCurrent = libraryUrl.openStream()
val inExisting = new FileInputStream(tmpLibFile)
val inCurrent = new BufferedInputStream(libraryUrl.openStream())
val inExisting = new BufferedInputStream(new FileInputStream(tmpLibFile))
var inCurrentByte = 0
var inExistingByte = 0
do {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/li/cil/oc/server/network/Network.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit fa1ccb4

Please sign in to comment.