This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
OmegaPaladin's profile picture

Selectively enabling the HTTP API

Started by OmegaPaladin, 25 June 2013 - 07:31 PM
OmegaPaladin #1
Posted 25 June 2013 - 09:31 PM
I am on a server using MC 1.47 and a modified tekkit lite pack. We have computercraft, but the http api is kept disabled. This means that computer programs have to be entered manually, and we can not take advantage of the expertise on the CC forums. The reason http api is disabled is to keep people from breaking the server with laggy code or other forms of being a jerk. Is there anyway to restrict the HTTP API to a specific computer or to specific users?
Lyqyd #2
Posted 26 June 2013 - 01:39 AM
Split into new topic.

Specific computers, yes, specific players, no. It may be somewhat complex to set up, though.
Bomb Bloke #3
Posted 26 June 2013 - 09:35 AM
The reason http api is disabled is to keep people from breaking the server with laggy code or other forms of being a jerk. Is there anyway to restrict the HTTP API to a specific computer or to specific users?
Dunno if it's up to you, but the server owner would ideally be made aware that "laggy" code is not the same thing as "complex" or "long" code. It's simple enough to tie up loads of CC run-time with a single line.
1lann #4
Posted 26 June 2013 - 11:44 AM
Also to stop spamming code you can do HTTP limiting. And just saying, idk why this "lagginess" from computercraft and all of these "explotations" keep on happening on Tekkit, yet not on the servers posted on CC Forums. I'm pretty sure CC doesn't really cause all of these problems. Anywho, you can add http limiting by doing something like


local requests = 0
local clock = os.clock()
local oldRequest = http.request
function http.request(...)
  if requests > 10 and ((os.clock() - clock) < 60) then
	-- Ignore
  end
  if (os.clock() - clock) > 60 then
	clock = os.clock()
    requests = 0
  end
  requests = requests+1
  return oldRequest(...)
end
MudkipTheEpic #5
Posted 26 June 2013 - 11:47 AM
You forgot to reset the count to 0 if it has been that many seconds. Also, put the requests=requests+1 inside an else block in the end.
trakos #6
Posted 26 June 2013 - 11:50 AM
Or just use something like cc-copy to automatically "copy-paste" the script :)/>
OmegaPaladin #7
Posted 04 July 2013 - 03:46 PM
Well, my problem is that I am not the server owner. I'm not even an admin or mod. However, I am interested in using computercraft, and I have a good reputation on the server. I am still getting the hang of LUA right now.

What kind of code should be avoided if you want to minimize server lag? (Most of our lag is from BC pipes, especially logistics pipes. I just want to try and add the http functionality without adding lag at the same time)

Lastly, I know you can use os.pullEvent to set up a shutdown command in response to redstone. Can you setup a computer to start on a redstone signal? I wonding about setting up player detectors from Immibis TubeStuff to turn computers off and on when I log in and out.