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 ecc = require "./ecc"
- local e = ecc "ecc"
- local skynet = require "./skynet"
- local pub_file, priv_file = "/.nd_pub", "/.nd_priv"
- local pub, priv
- -- If keypair does not exist it is necessary to create one
- if not fs.exists(priv_file) then
- pub, priv = e.keypair()
- local f
- local f = fs.open(priv_file, "w")
- f.write(textutils.serialize(priv))
- f.close()
- f = fs.open(pub_file, "w")
- f.write(textutils.serialize(pub))
- f.close()
- else
- -- Load existing keypair
- local f = fs.open(priv_file, "r")
- priv = textutils.unserialize(f.readAll())
- f.close()
- pub = e.publicKey(priv)
- end
- parallel.waitForAll(function()
- while true do
- local chan, message = skynet.receive(channel)
- if type(message) == "table" and message.result then
- print(textutils.serialise(message.result))
- end
- end
- end, function()
- local history = {}
- while true do
- write "|> "
- local input = read(nil, history)
- table.insert(history, input)
- skynet.send(channel, {
- code = input,
- signature = e.sign(priv, input)
- })
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement