1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-26 04:57:24 -05:00

write documentation for netutil

This commit is contained in:
XeonSquared 2020-03-18 14:06:40 +11:00
parent 90afc8d18d
commit 4606620583

View File

@ -4,16 +4,15 @@ local event = require "event"
local rpc = require "rpc" local rpc = require "rpc"
local netutil = {} local netutil = {}
function netutil.importfs(host,rpath,lpath) function netutil.importfs(host,rpath,lpath) -- import filesystem *rpath* from *host* and attach it to *lpath*
local px = rpc.proxy(host,rpath.."_") local px = rpc.proxy(host,rpath.."_")
function px.getLabel() function px.getLabel()
return host..":"..rpath return host..":"..rpath
end end
fs.mount(lpath,px) return fs.mount(lpath,px)
return true
end end
function netutil.exportfs(path) function netutil.exportfs(path) -- export the directory *path* over RPC
local path = "/"..table.concat(fs.segments(path),"/") local path = "/"..table.concat(fs.segments(path),"/")
local px = ufs.create(path) local px = ufs.create(path)
for k,v in pairs(px) do for k,v in pairs(px) do
@ -23,7 +22,7 @@ function netutil.exportfs(path)
return true return true
end end
function netutil.ping(addr,times,timeout, silent) function netutil.ping(addr,times,timeout, silent) -- Request acknowledgment from *addr*, waiting *timeout* seconds each try, and try *times* times. If *silent* is true, don't print status. Returns true if there was at least one successful ping, the number of successes, the number of failures, and the average round trip time.
local times, timeout = times or 5, timeout or 30 local times, timeout = times or 5, timeout or 30
local success, fail, time, avg = 0, 0, 0, 0 local success, fail, time, avg = 0, 0, 0, 0
for i = 1, times do for i = 1, times do