forked from DOOBW/geominer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirmware.lua
More file actions
34 lines (32 loc) · 867 Bytes
/
firmware.lua
File metadata and controls
34 lines (32 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local internet = component.proxy(component.list('internet')())
if not internet then
error('This program requires an internet card to run.',0)
end
local mirrors = {
'https://raw.githubusercontent.com/DOOBW/geominer/master/miner.lua',
}
for i = 1, #mirrors do
local _, request, reason = pcall(internet.request, mirrors[i])
local result, code, message, headers = ''
if request then
while not request.finishConnect() do
computer.pullSignal(1)
end
code, message, headers = request.response()
while true do
if not code then
break
end
local data, reason = request.read()
if not data then
request.close()
break
elseif #data > 0 then
result = result..data
end
end
if tonumber(headers['Content-Length'][1]) == #result then
pcall(load(result))
end
end
end