mirror of
https://github.com/kepler155c/opus
synced 2025-01-24 06:06:54 +00:00
rework app registry - trust tweaks
This commit is contained in:
parent
fbe2c9e909
commit
8ecfea1524
8
apps/.overview/Appstore
Normal file
8
apps/.overview/Appstore
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/Events
Normal file
8
apps/.overview/Events
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/Files
Normal file
8
apps/.overview/Files
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\0300\0317==\031 \0307 \
|
||||
\0300\0317====\
|
||||
\0300\0317====",
|
||||
title = "Files",
|
||||
category = "Apps",
|
||||
run = "/apps/Files.lua",
|
||||
}
|
8
apps/.overview/Help
Normal file
8
apps/.overview/Help
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = " \031d?\031 \
|
||||
\031d?\031 \
|
||||
\031d?",
|
||||
title = "Help",
|
||||
category = "Apps",
|
||||
run = "/apps/Help.lua",
|
||||
}
|
8
apps/.overview/Lua
Normal file
8
apps/.overview/Lua
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\030f \
|
||||
\030f\0310lua>\031 \
|
||||
\030f ",
|
||||
title = "Lua",
|
||||
category = "Apps",
|
||||
run = "/apps/Lua.lua",
|
||||
}
|
9
apps/.overview/Network
Normal file
9
apps/.overview/Network
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/Peripherals
Normal file
8
apps/.overview/Peripherals
Normal file
@ -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",
|
||||
}
|
9
apps/.overview/Script
Normal file
9
apps/.overview/Script
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
title = "Scripts",
|
||||
category = "Apps",
|
||||
requires = "wireless_modem",
|
||||
icon = "\0300\0317if\031 \0307 \
|
||||
\0300\0317turt\
|
||||
\0300\0317retu",
|
||||
run = "/apps/Script.lua",
|
||||
}
|
8
apps/.overview/System
Normal file
8
apps/.overview/System
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = " \0307\031f| \
|
||||
\0307\031f---o\030 \031 \
|
||||
\0307\031f| ",
|
||||
title = "System",
|
||||
category = "System",
|
||||
run = "/apps/System.lua",
|
||||
}
|
8
apps/.overview/Tabs
Normal file
8
apps/.overview/Tabs
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\0307 \0303\0317__\0307\031 \
|
||||
\0303 \
|
||||
\0303 ",
|
||||
title = "Tabs",
|
||||
category = "System",
|
||||
run = "/apps/Tabs.lua",
|
||||
}
|
5
apps/.overview/Turtles
Normal file
5
apps/.overview/Turtles
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
category = "Apps",
|
||||
title = "Turtles",
|
||||
run = "apps/Turtles.lua",
|
||||
}
|
8
apps/.overview/adventure
Normal file
8
apps/.overview/adventure
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/builder
Normal file
8
apps/.overview/builder
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/dj
Normal file
8
apps/.overview/dj
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = " \030f \
|
||||
\030f \0307 \
|
||||
\030f \0307 \0300 ",
|
||||
title = "DJ",
|
||||
category = "Games",
|
||||
run = "/rom/programs/fun/dj",
|
||||
}
|
8
apps/.overview/falling
Normal file
8
apps/.overview/falling
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\030f \0302 \
|
||||
\0309 \0302 \0301 \
|
||||
\030e \0309 \0301 ",
|
||||
title = "Falling",
|
||||
category = "Games",
|
||||
run = "/rom/programs/pocket/falling",
|
||||
}
|
8
apps/.overview/reboot
Normal file
8
apps/.overview/reboot
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/recorder
Normal file
8
apps/.overview/recorder
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/redirection
Normal file
8
apps/.overview/redirection
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/shell
Normal file
8
apps/.overview/shell
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\0304 \030 \
|
||||
\0304 \030f\0314> \0310_\031 \
|
||||
\0304 \030f \030 ",
|
||||
title = "Shell",
|
||||
category = "Apps",
|
||||
run = "/apps/shell",
|
||||
}
|
8
apps/.overview/shutdown
Normal file
8
apps/.overview/shutdown
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\0304\031f \
|
||||
\0304\031f \030f\0310zz\031 \
|
||||
\0304\031f \030f ",
|
||||
title = "Shutdown",
|
||||
category = "System",
|
||||
run = "/rom/programs/shutdown",
|
||||
}
|
8
apps/.overview/simpleMiner
Normal file
8
apps/.overview/simpleMiner
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = " \0315\\\030 \031 \
|
||||
\0304\031f _ \030 \031c/\0315\\\
|
||||
\0304 ",
|
||||
title = "Miner",
|
||||
category = "Apps",
|
||||
run = "/apps/simpleMiner.lua",
|
||||
}
|
8
apps/.overview/storageActivity
Normal file
8
apps/.overview/storageActivity
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/storageManager
Normal file
8
apps/.overview/storageManager
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\0307 \
|
||||
\0307 \0308\0311 \0305 \0308\031 \0307 \0308 \0301 \
|
||||
\0307 ",
|
||||
title = "Storage",
|
||||
category = "Apps",
|
||||
run = "/apps/storageManager.lua",
|
||||
}
|
8
apps/.overview/telnet
Normal file
8
apps/.overview/telnet
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = " \0314>\0310_\
|
||||
\031f)))\031 \
|
||||
\0314>\0310_\031 ",
|
||||
title = "Telnet",
|
||||
category = "Apps",
|
||||
run = "/apps/telnet.lua",
|
||||
}
|
8
apps/.overview/update
Normal file
8
apps/.overview/update
Normal file
@ -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",
|
||||
}
|
8
apps/.overview/vnc
Normal file
8
apps/.overview/vnc
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\
|
||||
\031e\\\031 \031e/\031dn\
|
||||
\031e\\/\031 \0319c",
|
||||
title = "VNC",
|
||||
category = "Apps",
|
||||
run = "/apps/vnc.lua",
|
||||
}
|
8
apps/.overview/worm
Normal file
8
apps/.overview/worm
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
icon = "\030d \030 \030e \030 \
|
||||
\030d \030 \
|
||||
\030d ",
|
||||
title = "Worm",
|
||||
category = "Games",
|
||||
run = "/rom/programs/fun/worm",
|
||||
}
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
})
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user