50 lines
No EOL
1.2 KiB
Text
50 lines
No EOL
1.2 KiB
Text
--Initializing IP address generator
|
|
|
|
local tArgs = {...}
|
|
if #tArgs < 4 then
|
|
kerneldraw.printAppInfo("nmap", "No IP address specified")
|
|
else
|
|
kerneldraw.printAppSuccess("nmap", "Scanning for specified IP")
|
|
end
|
|
|
|
if #tArgs == 5 then
|
|
kerneldraw.printAppSuccess("nmap", "Specified DNS record")
|
|
end
|
|
|
|
local ip, node
|
|
|
|
if #tArgs < 4 then
|
|
local x = tostring(math.random(0, 255))
|
|
local y = tostring(math.random(0, 255))
|
|
local z = tostring(math.random(0, 255))
|
|
local r = tostring(math.random(0, 255))
|
|
ip = x.."."..y.."."..z.."."..r
|
|
elseif #tArgs >= 4 then
|
|
ip = tArgs[1].."."..tArgs[2].."."..tArgs[3].."."..tArgs[4]
|
|
end
|
|
|
|
if not fs.exists("/network") or not fs.isDir("/network") then
|
|
fs.makeDir("/network")
|
|
end
|
|
|
|
--node = "/network/"..ip
|
|
|
|
kerneldraw.printAppInfo("nmap", "Found "..ip)
|
|
|
|
if #tArgs == 5 then
|
|
kerneldraw.printAppSuccess("nmap", "Assigned DNS record "..tArgs[5])
|
|
node = "/network/"..tArgs[5]
|
|
else
|
|
kerneldraw.printAppWarning("nmap", "No DNS record found, defaulting to IP")
|
|
node = "/network/"..ip
|
|
end
|
|
|
|
if fs.exists(node) and fs.isDir(node) then
|
|
kerneldraw.printAppInfo("nmap", ip.." already known")
|
|
else
|
|
fs.makeDir(node)
|
|
fs.makeDir(node.."/sys")
|
|
fs.makeDir(node.."/home")
|
|
fs.makeDir(node.."/bin")
|
|
kerneldraw.printAppSuccess("nmap", ip.." added to network")
|
|
end |