blob: 02c3bb65c7e72d875f8c01d9dfd942969d26dc09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
module(..., package.seeall)
local function status(self)
self.handle:write("status\n")
self.handle:flush()
local t = {}
local line = self.handle:read("*line")
while line ~= "" do
local host, status = string.match(line, "^(.*): (.*)$")
t[host] = status
line = self.handle:read("*line")
end
return t
end
local function close(self)
return self.handle:close()
end
function connect(socket_path)
local socket = require("pingu.client")
local fh, err
if socket ~= nil then
fh, err = socket.open(socket_path)
end
if fh == nil then
return fh, err
end
return {
["handle"] = fh,
["status"] = status,
["close"] = close
}
end
|