Skip to content

Commit

Permalink
doc: update example
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Jan 25, 2024
1 parent 4aad8e7 commit 2efdd9e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ruleset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,25 @@ local function ping(target)
return false, lasterr
end

if _G.ruleset then
-- stop old ruleset routines when reloading
_G.ruleset.running = false
end
ruleset.running = true
ruleset.server_rtt = {}
local function keepalive(target, tag)
while ruleset.running do
local ok, result = ping(target)
logf("ping %q: %s", tag, result)
ruleset.server_rtt[tag] = result
await.sleep(ok and 3600 or 60)
local interval = 60
if not is_disabled() then
local ok, result = ping(target)
logf("ping %q: %s", tag, result)
ruleset.server_rtt[tag] = result
if ok then interval = 3600 end
end
await.sleep(interval)
end
end

if _G.ruleset then
-- stop old ruleset routines when reloading
_G.ruleset.running = false
end
ruleset.server_rtt = {}
for k, v in pairs(route_list) do
local route, tag = v[1], v[2]
local target = table.pack(route("api.neosocksd.lan:80"))
Expand Down

0 comments on commit 2efdd9e

Please sign in to comment.