network group wip + virtual dirs + better trust

This commit is contained in:
kepler155c@gmail.com
2019-04-08 09:30:47 -04:00
parent 9413785248
commit 70733ab4f2
8 changed files with 92 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
local Ansi = require('ansi')
local Config = require('config')
local Security = require('security')
local SHA1 = require('sha1')
local UI = require('ui')
@@ -53,7 +54,7 @@ local page = UI.Page {
},
password = UI.WizardPage {
index = 3,
labelText = UI.Text {
passwordLabel = UI.Text {
x = 3, y = 2,
value = 'Password'
},
@@ -62,14 +63,22 @@ local page = UI.Page {
limit = 32,
mask = true,
shadowText = 'password',
accelerators = {
enter = 'new_password',
},
},
--[[
groupLabel = UI.Text {
x = 3, y = 3,
value = 'Group'
},
group = UI.TextEntry {
x = 12, ex = -3, y = 3,
limit = 32,
shadowText = 'network group',
},
]]
intro = UI.TextArea {
textColor = colors.yellow,
inactive = true,
x = 3, ex = -3, y = 4, ey = -3,
x = 3, ex = -3, y = 5, ey = -3,
value = string.format(passwordIntro, Ansi.white),
},
},
@@ -101,6 +110,11 @@ function page.wizard.pages.password:validate()
if #self.newPass.value > 0 then
Security.updatePassword(SHA1.sha1(self.newPass.value))
end
if #self.group.value > 0 then
local config = Config.load('os')
config.group = self.group.value
Config.update('os', config)
end
return true
end

View File

@@ -141,6 +141,7 @@ local function sendInfo()
infoTimer = os.clock()
info.label = os.getComputerLabel()
info.uptime = math.floor(os.clock())
info.group = network.getGroup()
if turtle then
info.fuel = turtle.getFuelLevel()
info.status = turtle.getStatus()

View File

@@ -24,10 +24,21 @@ if multishell then
multishell.setTitle(multishell.getCurrent(), 'Telnet ' .. remoteId)
end
local socket, msg = Socket.connect(remoteId, 23)
local socket, msg, reason
if not socket then
error(msg)
while true do
socket, msg, reason = Socket.connect(remoteId, 23)
if socket then
break
elseif reason ~= 'NOTRUST' then
error(msg)
end
local s, m = shell.run('trust ' .. remoteId)
if not s then
error(m)
end
end
local ct = Util.shallowCopy(term.current())

View File

@@ -6,6 +6,7 @@ local Util = require('util')
local colors = _G.colors
local multishell = _ENV.multishell
local os = _G.os
local shell = _ENV.shell
local term = _G.term
local remoteId
@@ -26,7 +27,15 @@ if multishell then
end
local function connect()
local socket, msg = Socket.connect(remoteId, 5900)
local socket, msg, reason = Socket.connect(remoteId, 5900)
if reason == 'NOTRUST' then
local s, m = shell.run('trust ' .. remoteId)
if not s then
return s, m
end
socket, msg = Socket.connect(remoteId, 5900)
end
if not socket then
return false, msg