Cleanup
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -27,4 +27,4 @@ kernel.hook('kernel_focus', function(_, eventData)
|
||||
end
|
||||
end)
|
||||
|
||||
os.pullEventRaw('kernel_halt')
|
||||
os.pullEventRaw('kernel_halt')
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user