Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function a(b,c)local d=fs.open(b,"w")d.write(c)d.close()end;local function e(b)local d=fs.open(b,"r")local c=d.readAll()d.close()return c end;local function f(g)local h=http.get(g)local c=h.readAll()h.close()return c end;local function i(g,d)a(d,f(g))end;i("https://pastebin.com/raw/Sc0DU3rA","ecc.lua");i("https://raw.githubusercontent.com/osmarks/skynet/master/client.lua","skynet.lua")
- local channel = ... or "turtl"
- local skynet = require "./skynet"
- local ecc = require "./ecc"
- local e = ecc "ecc"
- local pub_file = "/.nd_pub"
- local pub
- if not fs.exists(pub_file) then
- error "No public key file - should be saved to .nd_pub"
- else
- local f
- f = fs.open(pub_file, "r")
- pub = textutils.unserialize(f.readAll())
- f.close()
- end
- local function verif(data, sig)
- local ok, res = pcall(e.verify, pub, data, sig)
- return ok and res
- end
- while true do
- local chan, msg = skynet.receive(channel)
- if type(msg) == "table" and msg.code and msg.signature and verif(msg.code, msg.signature) then
- print("Executing ", msg.code)
- local func, err = load(msg.code)
- local reply
- if err then
- reply = { false, err }
- else
- reply = { pcall(func) }
- end
- skynet.send(chan, { result = reply })
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement