mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-26 03:48:06 +11:00
Compare commits
6 Commits
3b0d652e3a
...
f8903ad587
Author | SHA1 | Date | |
---|---|---|---|
|
f8903ad587 | ||
|
98fbf0e7d5 | ||
|
23915e4737 | ||
|
a78a3758f8 | ||
|
074a980d81 | ||
|
4f0efd256c |
@ -3,7 +3,7 @@ local serial = require "serialization"
|
|||||||
local computer = require "computer"
|
local computer = require "computer"
|
||||||
local havenet, net = pcall(require,"minitel")
|
local havenet, net = pcall(require,"minitel")
|
||||||
|
|
||||||
local hostname = os.getenv("HOSTNAME") or computer.address:sub(1,8)
|
local hostname = os.getenv("HOSTNAME") or computer.address():sub(1,8)
|
||||||
local cfg = {}
|
local cfg = {}
|
||||||
cfg.port = 514
|
cfg.port = 514
|
||||||
cfg.relay = false
|
cfg.relay = false
|
||||||
@ -41,7 +41,7 @@ function reload()
|
|||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
hostname = os.getenv("HOSTNAME") or computer.address:sub(1,8)
|
hostname = os.getenv("HOSTNAME") or computer.address():sub(1,8)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function wentry(_,msg,level,service,host)
|
local function wentry(_,msg,level,service,host)
|
||||||
@ -69,15 +69,15 @@ local function wentry(_,msg,level,service,host)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function remote_listener(_,from,port,data)
|
local function remote_listener(_,from,port,data)
|
||||||
if port ~= cfg.port then return false end
|
if port ~= cfg.port then return end
|
||||||
local service, level, msg = data:match("(.-)\t(%d)\t(.+)")
|
local service, level, msg = data:match("(.-)\t(%d)\t(.+)")
|
||||||
if not service or not level or not msg then return false end
|
if not service or not level or not msg then return end
|
||||||
msg, level, service = tostring(msg),tonumber(level),tostring(service)
|
msg, level, service = tostring(msg),tonumber(level),tostring(service)
|
||||||
wentry(nil,msg,level,service,from)
|
wentry(nil,msg,level,service,from)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function local_listener(_,msg,level,service)
|
local function local_listener(_,msg,level,service)
|
||||||
if not service or not level or not msg then return false end
|
if not service or not level or not msg then return end
|
||||||
msg, level, service = tostring(msg),tonumber(level),tostring(service)
|
msg, level, service = tostring(msg),tonumber(level),tostring(service)
|
||||||
wentry(nil,msg,level,service,hostname)
|
wentry(nil,msg,level,service,hostname)
|
||||||
end
|
end
|
||||||
@ -85,7 +85,7 @@ end
|
|||||||
function start()
|
function start()
|
||||||
reload()
|
reload()
|
||||||
if #listeners > 0 then return end
|
if #listeners > 0 then return end
|
||||||
event.listen("syslog",wentry)
|
event.listen("syslog",local_listener)
|
||||||
listeners[#listeners+1] = {"syslog",local_listener}
|
listeners[#listeners+1] = {"syslog",local_listener}
|
||||||
if havenet and cfg.receive then
|
if havenet and cfg.receive then
|
||||||
event.listen("net_msg",remote_listener)
|
event.listen("net_msg",remote_listener)
|
||||||
|
Loading…
Reference in New Issue
Block a user