This commit is contained in:
Anavrins
2020-03-30 02:07:20 -04:00
parent 369070e19c
commit 39522ee5b1
9 changed files with 78 additions and 71 deletions

View File

@@ -157,6 +157,7 @@ local page = UI.Page {
f = 'files',
s = 'shell',
l = 'lua',
n = 'network',
[ 'control-n' ] = 'new',
delete = 'delete',
},
@@ -435,6 +436,9 @@ function page:eventHandler(event)
elseif event.type == 'files' then
shell.switchTab(shell.openTab(Alt.get('files')))
elseif event.type == 'network' then
shell.switchTab(shell.openTab('network'))
elseif event.type == 'focus_change' then
if event.focused.parent.UIElement == 'Icon' then
event.focused.parent:scrollIntoView()

View File

@@ -27,4 +27,4 @@ kernel.hook('kernel_focus', function(_, eventData)
end
end)
os.pullEventRaw('kernel_halt')
os.pullEventRaw('kernel_halt')

View File

@@ -10,30 +10,30 @@ local keyPairs = { }
local function generateKeyPair()
local key = { }
for _ = 1, 32 do
table.insert(key, ("%02x"):format(math.random(0, 0xFF)))
table.insert(key, math.random(0, 0xFF))
end
local privateKey = Util.hexToByteArray(table.concat(key))
local privateKey = setmetatable(key, Util.byteArrayMT)
return privateKey, ECC.publicKey(privateKey)
end
getmetatable(network).__index.getKeyPair = function()
local keys = table.remove(keyPairs)
os.queueEvent('generate_keypair')
if not keys then
return generateKeyPair()
end
return table.unpack(keys)
local keys = table.remove(keyPairs)
os.queueEvent('generate_keypair')
if not keys then
return generateKeyPair()
end
return table.unpack(keys)
end
-- Generate key pairs in the background as this is a time-consuming process
Event.on('generate_keypair', function()
while true do
os.sleep(5)
local timer = Util.timer()
table.insert(keyPairs, { generateKeyPair() })
_G._syslog('Generated keypair in ' .. timer())
if #keyPairs >= 3 then
break
end
end
while true do
os.sleep(5)
local timer = Util.timer()
table.insert(keyPairs, { generateKeyPair() })
_G._syslog('Generated keypair in ' .. timer())
if #keyPairs >= 3 then
break
end
end
end)