mirror of
https://github.com/zenith391/OCEmu.git
synced 2025-09-29 07:53:29 -04:00
I really need to push this, so do so
This commit is contained in:
parent
fd4c8b80dd
commit
2ea268de54
46
src/component/internet.lua
Normal file
46
src/component/internet.lua
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
-- internet component
|
||||||
|
local obj = {}
|
||||||
|
|
||||||
|
function obj.isTcpEnabled() -- Returns whether TCP connections can be made (config setting).
|
||||||
|
cprint("internet.isTcpEnabled")
|
||||||
|
return config.get("internet.enableTcp",true)
|
||||||
|
end
|
||||||
|
function obj.isHttpEnabled() -- Returns whether HTTP requests can be made (config setting).
|
||||||
|
cprint("internet.isHttpEnabled")
|
||||||
|
return config.get("internet.enableHttp",true)
|
||||||
|
end
|
||||||
|
function obj.connect(address, port) -- Opens a new TCP connection. Returns the handle of the connection.
|
||||||
|
--STUB
|
||||||
|
cprint("internet.connect",address, port)
|
||||||
|
if port == nil then port = -1 end
|
||||||
|
compCheckArg(1,address,"string")
|
||||||
|
compCheckArg(2,port,"number")
|
||||||
|
if not config.get("internet.enableTcp",true) then
|
||||||
|
return nil, "tcp connections are unavailable"
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
function obj.request(url, postData) -- Starts an HTTP request. If this returns true, further results will be pushed using `http_response` signals.
|
||||||
|
--STUB
|
||||||
|
cprint("internet.request",url, postData)
|
||||||
|
compCheckArg(1,url,"string")
|
||||||
|
if not config.get("internet.enableHttp",true) then
|
||||||
|
return nil, "http requests are unavailable"
|
||||||
|
end
|
||||||
|
local post
|
||||||
|
if type(postData) == "string" then
|
||||||
|
post = postData
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local cec = {}
|
||||||
|
|
||||||
|
local doc = {
|
||||||
|
["isTcpEnabled"]="function():boolean -- Returns whether TCP connections can be made (config setting).",
|
||||||
|
["isHttpEnabled"]="function():boolean -- Returns whether HTTP requests can be made (config setting).",
|
||||||
|
["connect"]="function(address:string[, port:number]):userdata -- Opens a new TCP connection. Returns the handle of the connection.",
|
||||||
|
["request"]="function(url:string[, postData:string]):userdata -- Starts an HTTP request. If this returns true, further results will be pushed using `http_response` signals.",
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj,cec,doc
|
@ -6,6 +6,8 @@ local comments = {
|
|||||||
["computer.lua"]="Settings specific to the Lua architecture.",
|
["computer.lua"]="Settings specific to the Lua architecture.",
|
||||||
["computer.lua.allowBytecode"]="Whether to allow loading precompiled bytecode via Lua's `load` function, or related functions (`loadfile`, `dofile`). Enable this only if you absolutely trust all users on your server and all Lua code you run. This can be a MASSIVE SECURITY RISK, since precompiled code can easily be used for exploits, running arbitrary code on the real server! I cannot stress this enough: only enable this is you know what you're doing.",
|
["computer.lua.allowBytecode"]="Whether to allow loading precompiled bytecode via Lua's `load` function, or related functions (`loadfile`, `dofile`). Enable this only if you absolutely trust all users on your server and all Lua code you run. This can be a MASSIVE SECURITY RISK, since precompiled code can easily be used for exploits, running arbitrary code on the real server! I cannot stress this enough: only enable this is you know what you're doing.",
|
||||||
["computer.timeout"]="The time in seconds a program may run without yielding before it is forcibly aborted. This is used to avoid stupidly written or malicious programs blocking other computers by locking down the executor threads. Note that changing this won't have any effect on computers that are already running - they'll have to be rebooted for this to take effect.",
|
["computer.timeout"]="The time in seconds a program may run without yielding before it is forcibly aborted. This is used to avoid stupidly written or malicious programs blocking other computers by locking down the executor threads. Note that changing this won't have any effect on computers that are already running - they'll have to be rebooted for this to take effect.",
|
||||||
|
["internet.enableHttp"]="Whether to allow HTTP requests via internet cards. When enabled, the `request` method on internet card components becomes available.",
|
||||||
|
["internet.enableTcp"]="Whether to allow TCP connections via internet cards. When enabled, the `connect` method on internet card components becomes available.",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function writeComment(text,file,size)
|
local function writeComment(text,file,size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user