From d59cc53340b9558be3c7af7378f339e6e8ccbf50 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 11 May 2020 01:00:13 +1000 Subject: [PATCH] updated netutil to use the documentation library's type signature system --- lib/netutil.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/netutil.lua b/lib/netutil.lua index 7d623fd..373c9c3 100644 --- a/lib/netutil.lua +++ b/lib/netutil.lua @@ -5,7 +5,7 @@ local ufs = require "unionfs" local rpc = require "rpc" local netutil = {} -function netutil.importfs(host,rpath,lpath) -- import filesystem *rpath* from *host* and attach it to *lpath* +function netutil.importfs(host,rpath,lpath) -- string string string -- boolean -- Import filesystem *rpath* from *host* and attach it to *lpath*. local px = rpc.proxy(host,rpath.."_") function px.getLabel() return host..":"..rpath @@ -14,7 +14,7 @@ function netutil.importfs(host,rpath,lpath) -- import filesystem *rpath* from *h return fs.mount(lpath,px) end -function netutil.exportfs(path) -- export the directory *path* over RPC +function netutil.exportfs(path) -- string -- boolean -- Export the directory *path* over RPC. local path = "/"..table.concat(fs.segments(path),"/") local px = ufs.create(path) for k,v in pairs(px) do @@ -24,7 +24,7 @@ function netutil.exportfs(path) -- export the directory *path* over RPC return true end -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. +function netutil.ping(addr,times,timeout,silent) -- string number number boolean -- boolean number number number -- 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 success, fail, time, avg = 0, 0, 0, 0 for i = 1, times do @@ -46,7 +46,7 @@ function netutil.ping(addr,times,timeout, silent) -- Request acknowledgment from return success > 0, success, fail, avg end -function netutil.nc(host,port) +function netutil.nc(host,port) -- string number -- boolean -- Starts an interactive Minitel socket connection to *host* on *port*, primarily for remote login. Returns whether the attempt was successful. port = port or 22 local socket = minitel.open(host,port) if not socket then return false end @@ -66,6 +66,7 @@ function netutil.nc(host,port) socket:write(b.."\n") end until socket.state ~= "open" + return true end return netutil