implemented settings for tcp part of internet cards, renamed the http section to internet and renamed to contained settings to make it cleared they belong to the http part of the card; added missing require to pastebin program

This commit is contained in:
Florian Nücke 2014-01-20 23:25:15 +01:00
parent 47396a24c8
commit 3607da2433
3 changed files with 33 additions and 28 deletions

View File

@ -1,4 +1,5 @@
local fs = require("filesystem")
local internet = require("internet")
local shell = require("shell")
local args, options = shell.parse(...)

View File

@ -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

View File

@ -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.