diff --git a/apps/.overview/Appstore b/apps/.overview/Appstore new file mode 100644 index 0000000..1ecab3a --- /dev/null +++ b/apps/.overview/Appstore @@ -0,0 +1,8 @@ +{ + icon = "\030 \0310=\0300 \030 XX\0300\031f \030 \ +\030 \031f \0300 \030 \ +\030 \031f \0310o \031f \0310o\031f ", + category = "System", + title = "AppStore", + run = "/apps/Appstore.lua", +} \ No newline at end of file diff --git a/apps/.overview/Events b/apps/.overview/Events new file mode 100644 index 0000000..031b554 --- /dev/null +++ b/apps/.overview/Events @@ -0,0 +1,8 @@ +{ + icon = "\0304\031f \030 \0311e\ +\030f\031f \0304 \030 \0311ee\031f \ +\030f\031f \0304 \030 \0311e\031f ", + title = "Events", + category = "System", + run = "apps/Events.lua", +} \ No newline at end of file diff --git a/apps/.overview/Files b/apps/.overview/Files new file mode 100644 index 0000000..a1ee000 --- /dev/null +++ b/apps/.overview/Files @@ -0,0 +1,8 @@ +{ + icon = "\0300\0317==\031 \0307 \ +\0300\0317====\ +\0300\0317====", + title = "Files", + category = "Apps", + run = "/apps/Files.lua", +} \ No newline at end of file diff --git a/apps/.overview/Help b/apps/.overview/Help new file mode 100644 index 0000000..8a6379b --- /dev/null +++ b/apps/.overview/Help @@ -0,0 +1,8 @@ +{ + icon = " \031d?\031 \ +\031d?\031 \ + \031d?", + title = "Help", + category = "Apps", + run = "/apps/Help.lua", +} \ No newline at end of file diff --git a/apps/.overview/Lua b/apps/.overview/Lua new file mode 100644 index 0000000..e3cb689 --- /dev/null +++ b/apps/.overview/Lua @@ -0,0 +1,8 @@ +{ + icon = "\030f \ +\030f\0310lua>\031 \ +\030f ", + title = "Lua", + category = "Apps", + run = "/apps/Lua.lua", +} \ No newline at end of file diff --git a/apps/.overview/Network b/apps/.overview/Network new file mode 100644 index 0000000..38b5bf1 --- /dev/null +++ b/apps/.overview/Network @@ -0,0 +1,9 @@ +{ + title = "Network", + category = "Apps", + requires = "wireless_modem", + icon = "\0304 \030 \ +\030f \0304 \0307 \030 \031 \031f)\ +\030f \0304 \0307 \030 \031f)", + run = "/apps/Network.lua", +} \ No newline at end of file diff --git a/apps/.overview/Peripherals b/apps/.overview/Peripherals new file mode 100644 index 0000000..e8a0e20 --- /dev/null +++ b/apps/.overview/Peripherals @@ -0,0 +1,8 @@ +{ + icon = "\0304 \030 \ +\030f \0304 \0307 \030 \031 \031f_\ +\030f \0304 \0307 \030 \031f/", + title = "Devices", + category = "System", + run = "/apps/Peripherals.lua", +} \ No newline at end of file diff --git a/apps/.overview/Script b/apps/.overview/Script new file mode 100644 index 0000000..1d9f8e2 --- /dev/null +++ b/apps/.overview/Script @@ -0,0 +1,9 @@ +{ + title = "Scripts", + category = "Apps", + requires = "wireless_modem", + icon = "\0300\0317if\031 \0307 \ +\0300\0317turt\ +\0300\0317retu", + run = "/apps/Script.lua", +} \ No newline at end of file diff --git a/apps/.overview/System b/apps/.overview/System new file mode 100644 index 0000000..27ce0b1 --- /dev/null +++ b/apps/.overview/System @@ -0,0 +1,8 @@ +{ + icon = " \0307\031f| \ +\0307\031f---o\030 \031 \ + \0307\031f| ", + title = "System", + category = "System", + run = "/apps/System.lua", +} \ No newline at end of file diff --git a/apps/.overview/Tabs b/apps/.overview/Tabs new file mode 100644 index 0000000..964ccdf --- /dev/null +++ b/apps/.overview/Tabs @@ -0,0 +1,8 @@ +{ + icon = "\0307 \0303\0317__\0307\031 \ +\0303 \ +\0303 ", + title = "Tabs", + category = "System", + run = "/apps/Tabs.lua", +} \ No newline at end of file diff --git a/apps/.overview/Turtles b/apps/.overview/Turtles new file mode 100644 index 0000000..7316c99 --- /dev/null +++ b/apps/.overview/Turtles @@ -0,0 +1,5 @@ +{ + category = "Apps", + title = "Turtles", + run = "apps/Turtles.lua", +} \ No newline at end of file diff --git a/apps/.overview/adventure b/apps/.overview/adventure new file mode 100644 index 0000000..50df60a --- /dev/null +++ b/apps/.overview/adventure @@ -0,0 +1,8 @@ +{ + icon = "\030f\0310You \031 \ +\030f\0310Ther\030 \031 \ +\030f\0314?\031f \031 \030 ", + title = "Adventure", + category = "Games", + run = "/rom/programs/fun/adventure", +} \ No newline at end of file diff --git a/apps/.overview/builder b/apps/.overview/builder new file mode 100644 index 0000000..efa1704 --- /dev/null +++ b/apps/.overview/builder @@ -0,0 +1,8 @@ +{ + icon = "\0317_____\ +\030e\031c###\0308\0317=\030e\031c#\ +\030e\031c#\0307\031f.\030e\031c###", + title = "Builder", + category = "Apps", + run = "/apps/builder.lua", +} \ No newline at end of file diff --git a/apps/.overview/dj b/apps/.overview/dj new file mode 100644 index 0000000..5a4a7a8 --- /dev/null +++ b/apps/.overview/dj @@ -0,0 +1,8 @@ +{ + icon = " \030f \ +\030f \0307 \ +\030f \0307 \0300 ", + title = "DJ", + category = "Games", + run = "/rom/programs/fun/dj", +} \ No newline at end of file diff --git a/apps/.overview/falling b/apps/.overview/falling new file mode 100644 index 0000000..c7d4f4b --- /dev/null +++ b/apps/.overview/falling @@ -0,0 +1,8 @@ +{ + icon = "\030f \0302 \ +\0309 \0302 \0301 \ +\030e \0309 \0301 ", + title = "Falling", + category = "Games", + run = "/rom/programs/pocket/falling", +} \ No newline at end of file diff --git a/apps/.overview/reboot b/apps/.overview/reboot new file mode 100644 index 0000000..fe9213d --- /dev/null +++ b/apps/.overview/reboot @@ -0,0 +1,8 @@ +{ + icon = "\0304\031f \030f\0310o..\0304\031f \ +\0304\031f \030f\0310.o.\0304\031f \ +\0304\031f - ", + title = "Reboot", + category = "System", + run = "/rom/programs/reboot", +} \ No newline at end of file diff --git a/apps/.overview/recorder b/apps/.overview/recorder new file mode 100644 index 0000000..eeaf469 --- /dev/null +++ b/apps/.overview/recorder @@ -0,0 +1,8 @@ +{ + icon = "\030 \031f \031b \031foo \ +\030 \031f \030e\031b \030 \031f/\ +\030 \031b \030e \030 \031f\\", + category = "Apps", + title = "Recorder", + run = "/apps/recorder.lua", +} \ No newline at end of file diff --git a/apps/.overview/redirection b/apps/.overview/redirection new file mode 100644 index 0000000..f9b5722 --- /dev/null +++ b/apps/.overview/redirection @@ -0,0 +1,8 @@ +{ + icon = "\0307 \0308 \0307 \ +\0308\031b> \030b\0310>\0308\0318 \ +\0307 ", + title = "Redirection", + category = "Games", + run = "/rom/programs/fun/advanced/redirection", +} \ No newline at end of file diff --git a/apps/.overview/shell b/apps/.overview/shell new file mode 100644 index 0000000..c88cc2a --- /dev/null +++ b/apps/.overview/shell @@ -0,0 +1,8 @@ +{ + icon = "\0304 \030 \ +\0304 \030f\0314> \0310_\031 \ +\0304 \030f \030 ", + title = "Shell", + category = "Apps", + run = "/apps/shell", +} \ No newline at end of file diff --git a/apps/.overview/shutdown b/apps/.overview/shutdown new file mode 100644 index 0000000..9d873b3 --- /dev/null +++ b/apps/.overview/shutdown @@ -0,0 +1,8 @@ +{ + icon = "\0304\031f \ +\0304\031f \030f\0310zz\031 \ +\0304\031f \030f ", + title = "Shutdown", + category = "System", + run = "/rom/programs/shutdown", +} \ No newline at end of file diff --git a/apps/.overview/simpleMiner b/apps/.overview/simpleMiner new file mode 100644 index 0000000..f5404c6 --- /dev/null +++ b/apps/.overview/simpleMiner @@ -0,0 +1,8 @@ +{ + icon = " \0315\\\030 \031 \ + \0304\031f _ \030 \031c/\0315\\\ + \0304 ", + title = "Miner", + category = "Apps", + run = "/apps/simpleMiner.lua", +} \ No newline at end of file diff --git a/apps/.overview/storageActivity b/apps/.overview/storageActivity new file mode 100644 index 0000000..6500b56 --- /dev/null +++ b/apps/.overview/storageActivity @@ -0,0 +1,8 @@ +{ + icon = "\0318/\030f\031 \030 \0318\\\ +\030f \0308\0319o\030f\031 \ +\0318\\\030f\031 \030 \0318/", + title = "Activity", + category = "Apps", + run = "/apps/storageActivity.lua", +} \ No newline at end of file diff --git a/apps/.overview/storageManager b/apps/.overview/storageManager new file mode 100644 index 0000000..8eb79f4 --- /dev/null +++ b/apps/.overview/storageManager @@ -0,0 +1,8 @@ +{ + icon = "\0307 \ +\0307 \0308\0311 \0305 \0308\031 \0307 \0308 \0301 \ +\0307 ", + title = "Storage", + category = "Apps", + run = "/apps/storageManager.lua", +} \ No newline at end of file diff --git a/apps/.overview/telnet b/apps/.overview/telnet new file mode 100644 index 0000000..7db6138 --- /dev/null +++ b/apps/.overview/telnet @@ -0,0 +1,8 @@ +{ + icon = " \0314>\0310_\ + \031f)))\031 \ +\0314>\0310_\031 ", + title = "Telnet", + category = "Apps", + run = "/apps/telnet.lua", +} \ No newline at end of file diff --git a/apps/.overview/update b/apps/.overview/update new file mode 100644 index 0000000..f31a634 --- /dev/null +++ b/apps/.overview/update @@ -0,0 +1,8 @@ +{ + icon = "\0301\03171\03180\030 \031 \ +\0301\03181\030 \031 \ +\0301\03170\03180\03171\0307\031f>", + title = "Update", + category = "System", + run = "/apps/update.lua", +} \ No newline at end of file diff --git a/apps/.overview/vnc b/apps/.overview/vnc new file mode 100644 index 0000000..c1d74b8 --- /dev/null +++ b/apps/.overview/vnc @@ -0,0 +1,8 @@ +{ + icon = "\ +\031e\\\031 \031e/\031dn\ + \031e\\/\031 \0319c", + title = "VNC", + category = "Apps", + run = "/apps/vnc.lua", +} \ No newline at end of file diff --git a/apps/.overview/worm b/apps/.overview/worm new file mode 100644 index 0000000..408793e --- /dev/null +++ b/apps/.overview/worm @@ -0,0 +1,8 @@ +{ + icon = "\030d \030 \030e \030 \ +\030d \030 \ +\030d ", + title = "Worm", + category = "Games", + run = "/rom/programs/fun/worm", +} \ No newline at end of file diff --git a/apps/Network.lua b/apps/Network.lua index ee5940e..197f3cd 100644 --- a/apps/Network.lua +++ b/apps/Network.lua @@ -78,7 +78,7 @@ function page:eventHandler(event) title = t.label, }) elseif event.type == 'trust' then - shell.openTab('trust ' .. t.id) + shell.openForegroundTab('trust ' .. t.id) elseif event.type == 'reboot' then sendCommand(t.id, 'reboot') elseif event.type == 'shutdown' then diff --git a/apps/Overview.lua b/apps/Overview.lua index faf72ee..3b79481 100644 --- a/apps/Overview.lua +++ b/apps/Overview.lua @@ -18,7 +18,20 @@ local config = { local applications = { } Config.load('Overview', config) -Config.load('apps', applications) + +local function loadApplications() + Util.clear(applications) + local apps = fs.list('apps/.overview') + for _,app in pairs(apps) do + local data = Util.readTable('apps/.overview/' .. app) + if data then + data.filename = 'apps/.overview/' .. app + table.insert(applications, data) + end + end +end + +loadApplications() local defaultIcon = NFT.parse([[ 8071180 @@ -292,8 +305,7 @@ function page:eventHandler(event) end elseif event.type == 'refresh' then - applications = { } - Config.load('apps', applications) + loadApplications() self:refresh() self:draw() self.notification:success('Refreshed') @@ -301,14 +313,11 @@ function page:eventHandler(event) elseif event.type == 'delete' then local focused = page:getFocused() if focused.app then - local _,k = Util.find(applications, 'run', focused.app.run) - if k then - table.remove(applications, k) - Config.update('apps', applications) - page:refresh() - page:draw() - self.notification:success('Removed') - end + fs.delete(focused.app.filename) + loadApplications() + page:refresh() + page:draw() + self.notification:success('Removed') end elseif event.type == 'new' then @@ -386,14 +395,11 @@ function editor.form.image:draw() end function editor:updateApplications(app) - for k,v in pairs(applications) do - if v == app then - applications[k] = nil - break - end + if not app.filename then + app.filename = 'apps/.overview/' .. app.title end - table.insert(applications, app) - Config.update('apps', applications) + Util.writeTable(app.filename, app) + loadApplications() end function editor:eventHandler(event) @@ -458,8 +464,7 @@ UI:setPages({ }) Event.addHandler('os_register_app', function() - applications = { } - Config.load('apps', applications) + loadApplications() page:refresh() page:draw() page:sync() diff --git a/apps/trust.lua b/apps/trust.lua index 2db0310..cd631e2 100644 --- a/apps/trust.lua +++ b/apps/trust.lua @@ -6,10 +6,6 @@ local Crypto = require('crypto') local remoteId local args = { ... } -local exchange = { - base = 11, - primeMod = 625210769 -} if #args == 1 then remoteId = tonumber(args[1]) @@ -35,25 +31,18 @@ if not socket then error('Unable to connect to ' .. remoteId .. ' on port 19') end -local function modexp(base, exponent, modulo) - local remainder = base - - for i = 1, exponent-1 do - remainder = remainder * remainder - if remainder >= modulo then - remainder = remainder % modulo - end - end - - return remainder -end - -local secretKey = os.getSecretKey() -local publicKey = modexp(exchange.base, secretKey, exchange.primeMod) +local publicKey = os.getPublicKey() local password = SHA1.sha1(password) socket:write(Crypto.encrypt({ pk = publicKey, dh = os.getComputerID() }, password)) -print(socket:read(2) or 'No response') - +local data = socket:read(2) socket:close() + +if data and data.success then + print(data.msg) +elseif data then + error(data.msg) +else + error('No response') +end diff --git a/sys/apis/socket.lua b/sys/apis/socket.lua index 49a473f..e8c5238 100644 --- a/sys/apis/socket.lua +++ b/sys/apis/socket.lua @@ -3,27 +3,6 @@ local Crypto = require('crypto') local socketClass = { } -local exchange = { - base = 11, - primeMod = 625210769 -} - -local function modexp(base, exponent, modulo) - local remainder = base - - for i = 1, exponent-1 do - remainder = remainder * remainder - if remainder >= modulo then - remainder = remainder % modulo - end - end - - return remainder -end - -exchange.secretKey = os.getSecretKey() -exchange.publicKey = modexp(exchange.base, exchange.secretKey, exchange.primeMod) - function socketClass:read(timeout) local data, distance = transport.read(self) @@ -131,7 +110,7 @@ function Socket.connect(host, port) type = 'OPEN', shost = socket.shost, dhost = socket.dhost, - t = Crypto.encrypt({ ts = os.time(), seq = socket.seq }, exchange.publicKey), + t = Crypto.encrypt({ ts = os.time(), seq = socket.seq }, os.getPublicKey()), rseq = socket.wseq, wseq = socket.rseq, }) diff --git a/sys/extensions/os.lua b/sys/extensions/os.lua index fdfd01c..a8e8929 100644 --- a/sys/extensions/os.lua +++ b/sys/extensions/os.lua @@ -69,6 +69,30 @@ function os.getSecretKey() return config.secretKey end +function os.getPublicKey() + + local exchange = { + base = 11, + primeMod = 625210769 + } + + local function modexp(base, exponent, modulo) + local remainder = base + + for i = 1, exponent-1 do + remainder = remainder * remainder + if remainder >= modulo then + remainder = remainder % modulo + end + end + + return remainder + end + + local secretKey = os.getSecretKey() + return modexp(exchange.base, secretKey, exchange.primeMod) +end + function os.updatePassword(password) Config.load('os', config) config.password = password @@ -127,6 +151,8 @@ function os.getVersion() return version or 1.7 end +-- move completely into overview +-- just post event from appstore function os.registerApp(entry) local apps = { } Config.load('apps', apps) diff --git a/sys/network/trust.lua b/sys/network/trust.lua index c6fbca4..11eb765 100644 --- a/sys/network/trust.lua +++ b/sys/network/trust.lua @@ -14,17 +14,17 @@ process:newThread('trust_server', function() if data then local password = os.getPassword() if not password then - socket:write('No password has been set') + socket:write({ msg = 'No password has been set' }) else data = Crypto.decrypt(data, password) - if data and data.pk and data.dh then + if data and data.pk and data.dh == socket.dhost then local trustList = Util.readTable('.known_hosts') or { } trustList[data.dh] = data.pk Util.writeTable('.known_hosts', trustList) - socket:write('Trust accepted') + socket:write({ success = true, msg = 'Trust accepted' }) else - socket:write('Invalid password') + socket:write({ msg = 'Invalid password' }) end end end