diff --git a/assets/opencomputers/lua/rom/bin/pastebin.lua b/assets/opencomputers/lua/rom/bin/pastebin.lua index 8083059d8..37f8340f2 100644 --- a/assets/opencomputers/lua/rom/bin/pastebin.lua +++ b/assets/opencomputers/lua/rom/bin/pastebin.lua @@ -1,4 +1,5 @@ local fs = require("filesystem") +local internet = require("internet") local shell = require("shell") local args, options = shell.parse(...) diff --git a/li/cil/oc/Settings.scala b/li/cil/oc/Settings.scala index 27bb85832..6368cf210 100644 --- a/li/cil/oc/Settings.scala +++ b/li/cil/oc/Settings.scala @@ -142,15 +142,14 @@ class Settings(config: Config) { val maxReadBuffer = config.getInt("filesystem.maxReadBuffer") max 0 // ----------------------------------------------------------------------- // - // http - val httpEnabled = config.getBoolean("http.enable") - val httpThreads = config.getInt("http.threads") max 1 - val httpHostBlacklist = Array(config.getStringList("http.blacklist"): _*) - val httpHostWhitelist = Array(config.getStringList("http.whitelist"): _*) - val httpTimeout = (config.getInt("http.requestTimeout") max 0) * 1000 - - val tcpEnabled = true //config.getBoolean("internet.enableTcp") - val maxConnections = 4 // config.getInt("internet.maxConnections") max 0 + // internet + val httpEnabled = config.getBoolean("internet.enableHttp") + val tcpEnabled = config.getBoolean("internet.enableTcp") + val httpHostBlacklist = Array(config.getStringList("internet.blacklist"): _*) + val httpHostWhitelist = Array(config.getStringList("internet.whitelist"): _*) + val httpThreads = config.getInt("internet.requestThreads") max 1 + val httpTimeout = (config.getInt("internet.requestTimeout") max 0) * 1000 + val maxConnections = config.getInt("internet.maxTcpConnections") max 0 // ----------------------------------------------------------------------- // // misc diff --git a/reference.conf b/reference.conf index a8f2cb953..323bb917f 100644 --- a/reference.conf +++ b/reference.conf @@ -591,26 +591,15 @@ opencomputers { maxReadBuffer: 8192 } - # HTTP settings, security related. - http { - # Whether to allow HTTP requests via wireless network cards. When enabled, - # pass a URL to `send`, to perform an HTTP request. The second parameter - # becomes an optional string to send as POST data. When the request - # finishes, it will push a signal named `http_response`. If the request - # cannot be performed because the URL is not allowed or this is disabled - # the card will fall back to the normal send logic. - enable: true + # Internet settings, security related. + internet { + # Whether to allow HTTP requests via internet cards. When enabled, + # the `request` method on internet card components becomes available. + enableHttp: true - # The number of threads used for processing HTTP requests in the - # background. The more there are, the more concurrent connections can - # potentially be opened by computers, and the less likely they are to - # delay each other. - threads: 4 - - # The time in seconds to wait for a response to a request before timing - # out and returning an error message. If this is zero (the default) the - # request will never time out. - requestTimeout: 0 + # Whether to allow TCP connections via internet cards. When enabled, + # the `connect` method on internet card components becomes available. + enableTcp: true # This is a list of blacklisted domain names. If an HTTP request is made # and the host name (domain) of the target URL matches any of the patterns @@ -621,6 +610,7 @@ opencomputers { "^127\\.0\\.0\\.1$" "^10\\.\\d+\\.\\d+\\.\\d+$" "^192\\.\\d+\\.\\d+\\.\\d+$" + "^localhost$" ] # This is a list of whitelisted domain names. Requests may only be made to @@ -632,6 +622,21 @@ opencomputers { # applied to the host name (domain) of a given URL. Examples: # "^gist\\.github\\.com$", "^(:?www\\.)?pastebin\\.com$" whitelist: [] + + # The number of threads used for processing HTTP requests in the + # background. The more there are, the more concurrent connections can + # potentially be opened by computers, and the less likely they are to + # delay each other. + requestThreads: 4 + + # The time in seconds to wait for a response to a request before timing + # out and returning an error message. If this is zero (the default) the + # request will never time out. + requestTimeout: 0 + + # The maximum concurrent TCP connections *each* internet card can have + # open at a time. + maxTcpConnections: 4 } # Other settings that you might find useful to tweak.