Few tweaks in installation, some missing files, etc.
This commit is contained in:
parent
a2b780bf7a
commit
d55a5826e8
26 changed files with 232 additions and 238 deletions
|
@ -16,7 +16,7 @@ function parse(body)
|
|||
return nil, code, message
|
||||
end
|
||||
local data = {}
|
||||
for l in lines do
|
||||
for l in lines do
|
||||
local c = string.sub(l, 1, 1)
|
||||
if c ~= '#' and c ~= '.' then
|
||||
local key, value = socket.skip(2, string.find(l, "(.-)=(.*)"))
|
||||
|
@ -26,7 +26,7 @@ function parse(body)
|
|||
data[key] = value
|
||||
end
|
||||
end
|
||||
return data, code, message
|
||||
return data, code, message
|
||||
end
|
||||
|
||||
local host = socket.dns.gethostname()
|
||||
|
@ -34,13 +34,13 @@ local query = "%s?cmd=cddb+read+%s+%s&hello=LuaSocket+%s+LuaSocket+2.0&proto=6"
|
|||
local url = string.format(query, server, arg[1], arg[2], host)
|
||||
local body, headers, code = http.get(url)
|
||||
|
||||
if code == 200 then
|
||||
if code == 200 then
|
||||
local data, code, error = parse(body)
|
||||
if not data then
|
||||
if not data then
|
||||
print(error or code)
|
||||
else
|
||||
for i,v in pairs(data) do
|
||||
io.write(i, ': ', v, '\n')
|
||||
for i,v in pairs(data) do
|
||||
io.write(i, ': ', v, '\n')
|
||||
end
|
||||
end
|
||||
else print(error) end
|
||||
|
|
|
@ -20,10 +20,10 @@ assert(ip, port)
|
|||
print("Waiting packets on " .. ip .. ":" .. port .. "...")
|
||||
while 1 do
|
||||
dgram, ip, port = udp:receivefrom()
|
||||
if dgram then
|
||||
if dgram then
|
||||
print("Echoing '" .. dgram .. "' to " .. ip .. ":" .. port)
|
||||
udp:sendto(dgram, ip, port)
|
||||
else
|
||||
print(ip)
|
||||
else
|
||||
print(ip)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,7 +36,8 @@ do
|
|||
return usage()
|
||||
end
|
||||
if arg[1] ~= "query" then
|
||||
r,e=lp.send(arg[1],opt)
|
||||
opt.file = arg[1]
|
||||
r,e=lp.send(opt)
|
||||
io.stdout:write(tostring(r or e),'\n')
|
||||
else
|
||||
r,e=lp.query(opt)
|
||||
|
|
|
@ -62,24 +62,24 @@ while 1 do
|
|||
if input == server1 or input == server2 then
|
||||
io.write("Waiting for clients\n")
|
||||
local new = input:accept()
|
||||
if new then
|
||||
if new then
|
||||
new:settimeout(1)
|
||||
io.write("Inserting client in set\n")
|
||||
set:insert(new)
|
||||
set:insert(new)
|
||||
end
|
||||
-- it is a client socket
|
||||
else
|
||||
local line, error = input:receive()
|
||||
if error then
|
||||
if error then
|
||||
input:close()
|
||||
io.write("Removing client from set\n")
|
||||
set:remove(input)
|
||||
set:remove(input)
|
||||
else
|
||||
io.write("Broadcasting line '", line, "'\n")
|
||||
writable, error = socket.skip(1, socket.select(nil, set, 1))
|
||||
if not error then
|
||||
for __, output in ipairs(writable) do
|
||||
if output ~= input then
|
||||
if output ~= input then
|
||||
output:send(line .. "\n")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue