From 76de8ca3029cd21b362df6c27f6ada65df9e6717 Mon Sep 17 00:00:00 2001 From: Sam Roxanne Date: Wed, 3 Jun 2020 15:06:58 -0500 Subject: [PATCH] find, filter, skeletons --- cfg/rc.cfg | 2 +- lib/doc.lua | 128 ------------------------------- lib/foxfs.lua | 0 lib/interminitel.lua | 63 ---------------- lib/osdi.lua | 0 lib/shutil.lua | 39 +++++++++- lib/tsar.lua | 13 ++++ lib/tsuki.lua | 14 ++++ lib/velx.lua | 7 ++ psychos.tsar | Bin 28506 -> 22720 bytes service/fserv.lua | 95 ----------------------- service/screenblank.lua | 25 ------- service/tape-devfs.lua | 28 ------- service/termsrv.lua | 63 ---------------- service/vtunnel.lua | 162 ---------------------------------------- service/wolbeacon.lua | 18 ----- 16 files changed, 73 insertions(+), 584 deletions(-) delete mode 100644 lib/doc.lua create mode 100644 lib/foxfs.lua delete mode 100644 lib/interminitel.lua create mode 100644 lib/osdi.lua create mode 100644 lib/tsar.lua create mode 100644 lib/tsuki.lua create mode 100644 lib/velx.lua delete mode 100644 service/fserv.lua delete mode 100644 service/screenblank.lua delete mode 100644 service/tape-devfs.lua delete mode 100644 service/termsrv.lua delete mode 100644 service/vtunnel.lua delete mode 100644 service/wolbeacon.lua diff --git a/cfg/rc.cfg b/cfg/rc.cfg index 32b46b0..d11c209 100644 --- a/cfg/rc.cfg +++ b/cfg/rc.cfg @@ -1 +1 @@ -{enabled={"getty","minitel"}} +{enabled={"getty","minitel","clipboard","fsmanager"}} diff --git a/lib/doc.lua b/lib/doc.lua deleted file mode 100644 index 34faa46..0000000 --- a/lib/doc.lua +++ /dev/null @@ -1,128 +0,0 @@ -local _,serial = pcall(require,"serialization") -local doc = {} -doc.searchers = {} -doc.tctab = { - ["string"] = 31, - ["table"] = 32, - ["number"] = 33, - ["boolean"] = 35, - ["function"] = 36 -} - -function doc.parsefile(path) -- string -- table -- parses file from *path* to return a documentation table - local fdoc = {} - local f = io.open(path) - local lines = {} - for l in f:read("*a"):gmatch("[^\n]+") do - if l:find("function") and not l:find("local") then - lines[#lines+1] = l - end - end - for k,v in pairs(lines) do - local name, args, desc = v:match("function%s+(.+)%s*%((.*)%)%s*%-%-%s*(.+)") - if name and args and desc then - local fd = {["description"]=desc or desc,["args"]={},["atypes"]={}} - for word in args:gmatch("[^%s,]+") do - fd.args[#fd.args+1] = {word} - fd.atypes[word] = "unknown" - end - local argtypes, outtypes, description = desc:match("(.-)%-%-(.-)%-%-%s*(.+)") - if argtypes and outtypes and description then - local wc = 1 - for word in argtypes:gmatch("%S+") do - fd.args[wc][2] = word - fd.atypes[fd.args[wc][1]] = word - wc = wc + 1 - end - local wc = 1 - for word in outtypes:gmatch("%S+") do - fd.outtypes = fd.outtypes or {} - fd.outtypes[#fd.outtypes+1] = word - end - fd.description = description - end - fdoc[name] = fd - end - end - return fdoc -end - -function doc.format(fdoc) -- table -- string -- returns VT100 formatted documentation from documentation table *fdoc* - local rs = "" -- string to return - for fname,finfo in pairs(fdoc) do - if rs:len() > 0 then rs = rs .. "\n\n" end - local as = "" -- string containing arguments for a given function, with colours for type - for k,v in ipairs(finfo.args) do - local c = doc.tctab[v[2]] or 0 - if k > 1 then - as = as .. ", " - end - if v[2] then - as = string.format("%s%s: \27[%im%s\27[0m",as,v[2],c,v[1]) - else - as = string.format("%s\27[%im%s\27[0m",as,c,v[1]) - end - end - local rv = "" - if finfo.outtypes then - rv = ": " - for k,v in ipairs(finfo.outtypes) do - if k > 1 then - rv = rv .. ", " - end - local c = doc.tctab[v] or 0 - rv = string.format("%s\27[%im%s\27[0m",rv,c,v) - end - end - local nd = finfo.description - for k,v in pairs(finfo.atypes) do - local c = doc.tctab[v] or 7 - nd=nd:gsub("%*"..k.."%*","\27["..tostring(c).."m"..k.."\27[0m") - end - rs = string.format("%s\27[36m%s\27[0m(%s)%s\n%s",rs,fname,as,rv,nd) - end - return rs -end - -function doc.searchers.lib(name) -- string -- string string -- Tries to find a documentation from a library with *name*. Returns either a string of documentation, or false and a reason. - local lib = os.getenv("LIB") or "/boot/lib" - local dt - for d in lib:gmatch("[^\n]+") do - if fs.exists(d.."/"..name) then - dt = doc.parsefile(d.."/"..name) - elseif fs.exists(d.."/"..name..".lua") then - dt = doc.parsefile(d.."/"..name..".lua") - end - end - if not dt then return false, "unable to find documentation for "..tostring(name) end - return doc.format(dt) -end -function doc.searchers.cdoc(topic) -- string -- string string -- Searches for documentation labelled as *topic* in .dict files under /boot/doc/ - if not serial then return end - for k,v in ipairs(fs.list("/boot/doc")) do - if v:sub(-5) == ".dict" then - local f=io.open("/boot/doc/"..v,"rb") - for line in f:lines() do - local mname, docs = line:match("^(.-)\t(.+)$") - if mname == topic or mname == topic..".lua" then - return doc.format(serial.unserialize(docs)) - end - end - end - end -end - -function doc.docs(topic) -- string -- boolean -- Displays the documentation for *topic*, returning true, or errors. Also callable as just doc(). - local lib = os.getenv("LIB") or "/boot/lib" - local dt - for k,v in pairs(doc.searchers) do - dt=v(topic) - if dt then - print(dt) - return true - end - end - error("unable to find documentation for "..tostring(name)) -end - -return setmetatable(doc,{__call=function(_,topic) return doc.docs(topic) end}) diff --git a/lib/foxfs.lua b/lib/foxfs.lua new file mode 100644 index 0000000..e69de29 diff --git a/lib/interminitel.lua b/lib/interminitel.lua deleted file mode 100644 index 7cc4f04..0000000 --- a/lib/interminitel.lua +++ /dev/null @@ -1,63 +0,0 @@ -local imt = {} - -imt.ttypes = {} -imt.ttypes.string=1 -imt.ttypes.number=2 - -imt.ftypes = {tostring,tonumber} - -function imt.to16bn(n) - return string.char(math.floor(n/256))..string.char(math.floor(n%256)) -end -function imt.from16bn(s) - return (string.byte(s,1,1)*256)+string.byte(s,2,2) -end - -function imt.encodePacket(...) - local tArgs = {...} - local packet = string.char(#tArgs%256) - for _,segment in ipairs(tArgs) do - local segtype = type(segment) - segment = tostring(segment) - packet = packet .. imt.to16bn(segment:len()) .. string.char(imt.ttypes[segtype]) .. tostring(segment) - end - packet = imt.to16bn(packet:len()) .. packet - return packet -end - -function imt.decodePacket(s) - local function getfirst(n) - local ns = s:sub(1,n) - s=s:sub(n+1) - return ns - end - if s:len() < 2 then return false end - local plen = imt.from16bn(getfirst(2)) - local segments = {} - if s:len() < plen then return false end - local nsegments = string.byte(getfirst(1)) - --print(tostring(plen).." bytes, "..tostring(nsegments).." segments") - for i = 1, nsegments do - local seglen = imt.from16bn(getfirst(2)) - local segtype = imt.ftypes[string.byte(getfirst(1))] - local segment = segtype(getfirst(seglen)) - --print(seglen,segtype,segment,type(segment)) - segments[#segments+1] = segment - end - return table.unpack(segments) -end -function imt.getRemainder(s) - local function getfirst(n) - local ns = s:sub(1,n) - s=s:sub(n+1) - return ns - end - local plen = imt.from16bn(getfirst(2)) - if s:len() > plen then - getfirst(plen) - return s - end - return nil -end - -return imt diff --git a/lib/osdi.lua b/lib/osdi.lua new file mode 100644 index 0000000..e69de29 diff --git a/lib/shutil.lua b/lib/shutil.lua index 1ee2a6c..ffdc97c 100644 --- a/lib/shutil.lua +++ b/lib/shutil.lua @@ -2,7 +2,6 @@ local component = require "component" local fs = require "fs" local shell = require "shell" local ed = require "ed" -local doc = require "doc" local shutil = {} shutil.ed = ed.interactive shutil.vi = ed.visual @@ -124,4 +123,42 @@ shutil.mkdir = fs.makeDirectory shutil.cp = fs.copy shutil.rm = fs.remove +local function find_dir(t, dir) + local f = fs.list(dir) + for i=1, #f do + if (f[i]:sub(#f[i]) == "/") then + find_dir(t, dir..f[i]) + end + t[#t+1] = dir..f[i] + end +end + +function shutil.find(...) + local paths = {...} + if not paths[1] then paths = {"."} end + for i=1, #paths do + if (paths[i]:sub(#paths[i]) ~= "/") then + paths[i] = paths[i] .. "/" + end + end + local t = {} + for i=1, #paths do + if fs.isDirectory(paths[i]) then + find_dir(t, paths[i]) + end + t[#t+1] = paths[i] + end + return t +end + +function shutil.filter(t, func) + local t2 = {} + for i=1, #t do + if (func(t[i])) then + t2[#t2+1] = t[i] + end + end + return t2 +end + return shutil diff --git a/lib/tsar.lua b/lib/tsar.lua new file mode 100644 index 0000000..cad7ef7 --- /dev/null +++ b/lib/tsar.lua @@ -0,0 +1,13 @@ +local tsar = package.loaded.tsar or {} + +function tsar.extract(fd, path, ...) + +end + +function tsar.create(paths, fd) + +end + +function tsar.list(fd) + +end \ No newline at end of file diff --git a/lib/tsuki.lua b/lib/tsuki.lua new file mode 100644 index 0000000..391e50e --- /dev/null +++ b/lib/tsuki.lua @@ -0,0 +1,14 @@ +local foxfs = require "foxfs" +local tsuki = {} + +function tsuki.reset_security_node(path) + +end + +function tsuki.reset_dev_permissions(path) + +end + +function tsuki.make_security_node(path) + +end \ No newline at end of file diff --git a/lib/velx.lua b/lib/velx.lua new file mode 100644 index 0000000..5584bd6 --- /dev/null +++ b/lib/velx.lua @@ -0,0 +1,7 @@ +local velx = package.loaded.velx or {} + +function velx.parse(fd) + +end + +return velx \ No newline at end of file diff --git a/psychos.tsar b/psychos.tsar index da8a4fe3b2349165635b7edf10b409edeb45c685..86d1e1363b122968dbe07a24f8527830752fb269 100644 GIT binary patch delta 1975 zcmZWqYfK#16`o~zd0k+KmjOHR&A`$bGt9DE{9--W3#>7Qz~X|edgJWQ;|`3OoteEe zyDX4p;|F%ysuY(*k)l*hT&Gojq=h(Ye>74^V^wM^)pksa)JTS+R!vkTHu+(@YWLGrzM9t)1!5MJxeD+slxhuu_nLA}cbMteOyUf@#SK=z~l`p3Fa%kc~K} z6o51zmn4Xce7{?Yt3sj6huI7NVwtk00*M@2r!f04J3(|4r)lEZoim*~X9jl8JPHyi z%r3J{K5KMXRv;K^wOCJ+w>b?&ZKDX28$3Q)0+y{l6*pUtpl!kzi9|;ReT!cHWD|xrqrCpIItpZuKfX>Ot zAV=1z;wB|jt2B5no@L8#|Lomx+`3j zu70)n!%6nsc~F9CT5#{4@KfpXlghF|G7RHLFKTRjg1Vh5zNv*gCBh#X`dNZ;@>O?q z`j4?{zg&G$s}pLqf3$jBWqN6oNyhpZhG;3zrQb!3Rbie{WW(*Gs@Eo&y96K@29@Kl z*XNfH3!F*)n*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+@0JL_<&G)Q zPdjRU>AFfqT9UPmU$`EwDN|hIMhT`9vYIJ6uJM%(a6dp)J>BCb-u`1;7ag4Cm{Eh30dw#q*e50$2 zqEd~WFlm1Zw&7h}rSoA*O6p3qhmQzMd>F?P+v*biiOt9&69HKDHL{L;qmJy>ce#kJ zZjH)*;TMf6Yv((VKAl+L3*Xazwl@Dm{Pw1Yb?j)}QSZ?@Y-x|=KV3h%x9%_u zd#1g+Kc}u0{k~!Up?g}HBfMX#uzxlX0r9l`lX?bW?=iG!Hq4H%IYM+m+*dbW=qx$Qb#JP9cuQu^r_EJsS` zomb`R-M0iT9?Y=%p8!9Hu+iNExsMP#iewp$@$tBFwdeZZ)*nydk}6892PgQ_d458G zH}xzGPhG8@&$|Sx>U|(yJH7F=Jsl38SQar7p z>_bQAB0!-q^7~17>ltF*Sn887h(8uOe2h5uc+N5BTgNK$MxN{}nnErpD1$y;pG6i; zN$w?+#QkDCc-s8cGmXsCO9Bc%WPOlKm?YG*HW{GRA6A~+5rp{&8#{aO*!Ve<@i-@^ zQ$Khs(h#^5xg3aAr*6Q)Es+qH4*}HLHm{u8W!Urz(5xJ@4kN-+IqvO);HX0 z@F5pj8apiNd)hNsW4b}OhU+#Wn-TJ$xycxBBa$azm!80gTVc_%9dec!gGh$9TLG$m zn9*WjFJwR6fF{Wj;9Vh%Tm-Zwkc91>yc#j!^{Y8yW;Hcir}&$k#b^6Y3#et#jhXJ- zJY!j~>N*yZMJCKL8;$ZJlvA9unB#+qWz~3UcT=SEl*zE{ImU 299 then - socket:write(string.format("f%d\n%s",code,message)) - else - local data = "" - repeat - coroutine.yield() - data = request.read() - if data then - socket:write(data) - end - until not data - end -end - -local function socketHandler(socket) - return function() - local line = nil - repeat - coroutine.yield() - line = socket:read() - until line - local rtype, path = line:match("(.)(.+)") - if fs.segments(path)[1] == "http" or fs.segments(path)[1] == "https" then - httpHandler(socket,rtype,path) - else - path = (cfg.path .. "/" .. path:gsub("../","")):gsub("/+","/") - fileHandler(socket,rtype,path) - end - socket:close() - end -end - -while true do - os.spawn(socketHandler(minitel.listen(70)),"fserv worker process") -end diff --git a/service/screenblank.lua b/service/screenblank.lua deleted file mode 100644 index af9f867..0000000 --- a/service/screenblank.lua +++ /dev/null @@ -1,25 +0,0 @@ -local lastkey = computer.uptime() -local state = true -local delay = 60 -function start() - return os.spawn(function() - while true do - tEv = {coroutine.yield()} - if tEv[1] == "key_down" then - lastkey = computer.uptime() - if not state then - for addr in component.list("screen") do - component.invoke(addr,"turnOn") - end - state = true - end - end - if computer.uptime() > lastkey + delay and state then - for addr in component.list("screen") do - component.invoke(addr,"turnOff") - end - state = false - end - end - end,"screenblank") -end diff --git a/service/tape-devfs.lua b/service/tape-devfs.lua deleted file mode 100644 index 3a24678..0000000 --- a/service/tape-devfs.lua +++ /dev/null @@ -1,28 +0,0 @@ -local counter = 0 -local td = {} -local function addNode(addr) - devfs.register("tape"..tonumber(counter),function() - local tape = component.proxy(addr) - tape.seek(-math.huge) - return tape.read, tape.write, function() end, tape.seek - end) - devfs.register("tapen"..tonumber(counter),function() - local tape = component.proxy(addr) - return tape.read, tape.write, function() end, tape.seek - end) - td[addr] = counter - counter = counter + 1 -end -for addr in component.list("tape_drive") do - addNode(addr) -end -while true do - local tE = {coroutine.yield()} - if tE[1] == "component_added" and tE[3] == "tape_drive" then - addNode(tE[2]) - elseif tE[1] == "component_removed" and tE[3] == "tape_drive" then - if td[tE[2]] then - fs.remove("/dev/tape"..tostring(td[tE[2]])) - end - end -end diff --git a/service/termsrv.lua b/service/termsrv.lua deleted file mode 100644 index 2799c27..0000000 --- a/service/termsrv.lua +++ /dev/null @@ -1,63 +0,0 @@ -local minitel = require "minitel" -local shell = require "shell" -local port = 22 - -local function sread(self, len) - while true do - local d=self.sock:read(len) - if d then - return d - end - coroutine.yield() - end -end -local function swrite(self, data) - while self.flushing do - coroutine.yield() - end - if data and data:len() > 0 then - self.wb = self.wb .. (data or "") - end -end -local function sclose(self) - self.sock:close() -end -local function sflush(self) - self.flushing = true - self.sock:write(self.wb) - self.wb = "" - self.flushing = false -end - -function start() - return os.spawn(function() - local oout = io.output() - local pname = os.taskInfo(os.pid()).name - while true do - local sock = minitel.listen(port) - print(string.format("Connection from %s:%d",sock.addr,sock.port)) - os.spawn(function() _G.worked = {pcall(function() - local fh = {} - fh.sock = sock - fh.read = sread - fh.write = swrite - fh.close = sclose - fh.flush = sflush - fh.wb = "" - io.input(fh) - io.output(fh) - print(_OSVERSION.." - "..tostring(math.floor(computer.totalMemory()/1024)).."K RAM") - local pid = os.spawn(shell.interactive,string.format(pname.." shell [%s:%d]",sock.addr,sock.port)) - repeat - coroutine.yield() - if fh.wb:len() > 0 then - fh:flush() - end - until sock.state ~= "open" or not os.taskInfo(pid) - sock:close() - os.kill(pid) - oout:write(string.format("Session %s:%d ended",sock.addr,sock.port)) - end)} end,string.format(pname.." [%s:%d]",sock.addr,sock.port)) - end - end,"termsrv") -end diff --git a/service/vtunnel.lua b/service/vtunnel.lua deleted file mode 100644 index f34c0ef..0000000 --- a/service/vtunnel.lua +++ /dev/null @@ -1,162 +0,0 @@ -local vcomponent = require "vcomponent" -local serial = require "serialization" -local component = require "component" -local computer = require "computer" -local event = require "event" -local imt = require "interminitel" - -local cfg = {} -cfg.peers = {} -cfg.rtimer = 5 -cfg.katimer = 30 -local listeners = {} -local proxies = {} - -local function loadcfg() - local f = io.open("/boot/cfg/vtunnel.cfg","rb") - if not f then return false end - for k,v in pairs(serial.unserialize(f:read("*a")) or {}) do - cfg[k] = v - end - f:close() -end -local function savecfg() - local f = io.open("/boot/cfg/vtunnel.cfg","wb") - if not f then - print("Warning: unable to save configuration.") - return false - end - f:write(serial.serialize(cfg)) - f:close() -end - -local function createTunnel(host,port,addr,raddr) - local proxy = {address=addr,buffer=""} - function proxy.connect() - if proxy.socket then - proxy.socket.close() - end - proxy.socket = component.invoke(component.list("internet")(),"connect",host,port) - local st = computer.uptime() - repeat - coroutine.yield() - until proxy.socket.finishConnect() or computer.uptime() > st+5 - end - function proxy.send(...) - rt = 0 - while not proxy.socket.write(imt.encodePacket(...)) and rt < 10 do - proxy.connect() - rt = rt + 1 - end - proxy.last = computer.uptime() - end - function proxy.read() - local rb, r - local rt = 0 - while true do - rb,r = proxy.socket.read(4096) - if rb or rt > 10 then break end - if type(rb) == "nil" then - proxy.connect() - end - rt = rt + 1 - end - proxy.buffer = proxy.buffer .. rb - while imt.decodePacket(proxy.buffer) do - computer.pushSignal("modem_message",addr,raddr,0,0,imt.decodePacket(proxy.buffer)) - proxy.buffer = imt.getRemainder(proxy.buffer) or "" - end - if computer.uptime() > proxy.last + cfg.katimer then - proxy.socket.write("\0\1\0") - proxy.last = computer.uptime() - end - end - function proxy.getWakeMessage() - return false - end - proxy.setWakeMessage = proxy.getWakeMessage - function proxy.maxPacketSize() - return 8192 - end - function proxy.getChannel() - return host..":"..tostring(port) - end - proxy.connect() - proxy.last = computer.uptime() - return proxy -end - -vt = {} -function start() - loadcfg() - for k,v in pairs(cfg.peers) do - print(string.format("Connecting to %s:%d",v.host,v.port)) - v.addr = v.addr or vcomponent.uuid() - v.raddr = v.raddr or vcomponent.uuid() - local px = createTunnel(v.host, v.port, v.addr, v.raddr) - vcomponent.register(v.addr, "tunnel", px) - proxies[v.addr] = px - end - for k,v in pairs(os.tasks()) do - if os.taskInfo(v).name:match("minitel") then - os.kill(v) - end - end -end -function vt.stop() - for k,v in pairs(proxies) do - vcomponent.unregister(k) - end -end - -function vt.listpeers() - for k,v in pairs(cfg.peers) do - print(string.format("#%d (%s:%d)\n Local address: %s\n Remote address: %s",k,v.host,v.port,v.addr,v.raddr)) - end -end -function vt.addpeer(host,port) - port = tonumber(port) or 4096 - local t = {} - t.host = host - t.port = port - t.addr = vcomponent.uuid() - t.raddr = vcomponent.uuid() - cfg.peers[#cfg.peers+1] = t - print(string.format("Added peer #%d (%s:%d) to the configuration.\nRestart to apply changes.",#cfg.peers,host,port)) - savecfg() -end -function vt.delpeer(n) - n=tonumber(n) - if not n then - print("delpeer requires a number, representing the peer number, as an argument.") - return false - end - local dp = table.remove(cfg.peers, n) - savecfg() - print(string.format("Removed peer %s:%d",dp.host, dp.port)) -end - -function vt.settimer(time) - time = tonumber(time) - if not time then - print("Timer must be a number.") - return false - end - cfg.rtime = time - savecfg() -end - -vt.start = start -_G.libs.vtunnel = vt - -start() -local last = computer.uptime() -while true do - local tE = {coroutine.yield()} - if computer.uptime() > last + cfg.rtimer then - for k,v in pairs(proxies) do - v.read() - end - last = computer.uptime() - end -end diff --git a/service/wolbeacon.lua b/service/wolbeacon.lua deleted file mode 100644 index 41f6006..0000000 --- a/service/wolbeacon.lua +++ /dev/null @@ -1,18 +0,0 @@ -local delay = 60 -local port = 3442 -local message = "WoLBeacon" - -for modem in component.list("modem") do - component.invoke(modem,"setWakeMessage",message) -end - -local ltime = computer.uptime() -while true do - if computer.uptime() > ltime+delay then - for modem in component.list("modem") do - component.invoke(modem,"broadcast",port,message) - end - ltime=computer.uptime() - end - coroutine.yield() -end