From 09187043576d91cff10ee15a16aed59dced4da95 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 23 Sep 2017 14:26:37 +1000 Subject: [PATCH] made nbsrv log rather than print everything --- exec/nbsrv.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exec/nbsrv.lua b/exec/nbsrv.lua index c3120f3..3f4d9b7 100644 --- a/exec/nbsrv.lua +++ b/exec/nbsrv.lua @@ -2,26 +2,26 @@ local tA = {...} local nport = tonumber(tA[1]) local fpath = tostring(tA[2]) for m in component.list("modem") do - print("[nbsrv] opening port on "..m) + log("[nbsrv] opening port on "..m) component.invoke(m,"open",nport) end local f=io.open(fpath,"rb") local nbdata = f:read("*a") f:close() -spawn("nbsrv: "..tostring(nport)..","..fpath,function() print(xpcall(function() +spawn("nbsrv: "..tostring(nport)..","..fpath,function() log(xpcall(function() while true do local _, laddress, raddress, port, _, payload = event.pull("modem_message") if port == nport and type(payload) == "string" then if payload:len() == 36 then local sraddress,spayload = raddress:sub(1,8),payload:sub(1,8) - print("[nbsrv] request from "..sraddress.."/"..spayload.." on port "..tostring(port)) + log("[nbsrv] request from "..sraddress.."/"..spayload.." on port "..tostring(port)) for i = 1, nbdata:len(), 2048 do component.invoke(laddress,"send",raddress,port,nbdata:sub(i,i+2047)) end component.invoke(laddress,"send",raddress,port,".") - print("[nbsrv] served request from "..sraddress.."/"..spayload) + log("[nbsrv] served request from "..sraddress.."/"..spayload) end end end end)) end) -print("[nbsrv] nbsrv started.") +log("[nbsrv] nbsrv started.")