Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable network packet TTL #3745

Open
wants to merge 1 commit into
base: master-MC1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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