Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local allChars = {}
- local id = os.getComputerID()
- local version = 1
- if tonumber(http.get("https://pastebin.com/raw/wEHXZmdN").readAll()) ~= version then
- fs.delete(shell.getRunningProgram())
- shell.run("pastebin get epFS33Px startup.lua")
- print("rebooting, update successful")
- shell.run("reboot")
- end
- local temp
- if not fs.exists("./storage.json") then
- temp = fs.open("./storage.json", "w")
- temp.write(textutils.serialiseJSON({
- raws = {},
- keys = {}
- }))
- temp.close()
- end
- local storageJson = fs.open("./storage.json", "r")
- local storage = textutils.unserialiseJSON(storageJson.readAll())
- local function saveStorage()
- temp = fs.open("storage.json", "w")
- temp.write(textutils.serialiseJSON(storage))
- temp.close()
- end
- require("stringtools")()
- for i = 0, 255 do
- allChars[i] = string.char(i)
- end
- local function encrypt(message)
- message = string.fracture(textutils.serialise(message))
- local new = ""
- for _, char in pairs(message) do
- for _idx, _char in ipairs(allChars) do
- if char == _char then
- new = new..allChars[(_idx+id)%#allChars]
- end
- end
- end
- return new.."_"..id
- end
- local function decrypt(message)
- message = string.fracture(message)
- local unlockId = ""
- for i = #message, 1, -1 do
- if message[i] ~= "_" then
- unlockId = unlockId..message[i]
- else
- for j = i, #message do
- message[j] = nil
- end
- break
- end
- end
- ---@diagnostic disable-next-line: cast-local-type
- unlockId = tonumber(string.reverse(unlockId))
- local new = ""
- for _, char in pairs(message) do
- for _idx, _char in ipairs(allChars) do
- if char == _char then
- new = new..allChars[(_idx-unlockId)%#allChars]
- end
- end
- end
- return textutils.unserialise(new)
- end
- local function awaitMessage(channel, timeOut, condition)
- local toReturn = {}
- parallel.waitForAny(function()
- repeat
- os.sleep(1)
- timeOut = timeOut - 1
- until timeOut <= 0
- toReturn = {false}
- end, function()
- while next(toReturn) == nil do
- local received = table.pack(os.pullEvent("modem_message"))
- if received[3] == channel then
- received[5] = decrypt(received[5])
- if condition(received[5]) then
- toReturn = {true, received}
- else
- toReturn = {false}
- end
- end
- end
- end)
- return table.unpack(toReturn)
- end
- local modem = peripheral.find("modem")
- modem.open(48184)
- while true do
- local _, _, channel, replyChannel, message, _ = os.pullEvent("modem_message")
- message = decrypt(message)
- if message.lookingFor == "home" and message.operation == "connect" and message.connector == "phone" then
- modem.transmit(48084, 48184, encrypt({
- name = "home",
- operation = "connect",
- status = true
- }))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement