blob: 2434cf1ab85b4179ab971691da36ff3d00f4b411 (
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
|
local net = require 'service.net'
local timer = require 'timer'
local config = require 'config'
local client = require 'provider.client'
local nonil = require 'without-check-nil'
local util = require 'utility'
local tokenPath = (ROOT / 'log' / 'token'):string()
local token = util.loadFile(tokenPath)
if not token then
token = ('%016X'):format(math.random(0, math.maxinteger))
util.saveFile(token)
end
local function pushClient(link)
nonil.enable()
local clientName = client.info.clientInfo.name
local clientVersion = client.info.clientInfo.version
nonil.disable()
link:write(string.pack('zzz'
, 'pulse'
, token
, table.concat({clientName, clientVersion}, ' ')
))
end
timer.wait(5, function ()
timer.loop(60, function ()
if not config.config.telemetry.enable then
return
end
local link = net.connect('tcp', '119.45.194.183', 11577)
pushClient(link)
net.update()
end)()
end)
|