forked from Tank/braga
tests in firmware
This commit is contained in:
parent
bdbf6f900e
commit
ce0babc72f
@ -1,67 +0,0 @@
|
|||||||
local _M = {}
|
|
||||||
local db = require('db.mysql')
|
|
||||||
_M['date'] = os.date('%Y-%m-%d %H:%M:%S')
|
|
||||||
|
|
||||||
function _M.get(limit,offset)
|
|
||||||
local cur
|
|
||||||
if limit == nil then
|
|
||||||
cur = db.cursor("SELECT * FROM logs ORDER BY started DESC")
|
|
||||||
else
|
|
||||||
if offset == nil then offset = 0 end
|
|
||||||
cur = db.cursor("SELECT * FROM logs ORDER BY started DESC LIMIT "..limit.." OFFSET "..offset)
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.period(start,ends,user)
|
|
||||||
local cur
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT user,url,client_ip,host_ip,DATE_ADD(logs.started, INTERVAL 4 HOUR) as day, ROUND(bytesin/1000,2) as bin, ROUND(bytesout/1000,2) as bout FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' ORDER BY started DESC")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT user,url,client_ip,host_ip,DATE_ADD(logs.started, INTERVAL 4 HOUR) as day, ROUND(bytesin/1000,2) as bin, ROUND(bytesout/1000,2) as bout FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."' ORDER BY started DESC")
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.connects(start,ends,user)
|
|
||||||
local cur
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT user, ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, COUNT(*) as connects FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' GROUP BY user ORDER BY connects DESC")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT user, ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, COUNT(*) as connects FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."' GROUP BY user ORDER BY connects DESC")
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.traffic(start,ends,user)
|
|
||||||
local cur
|
|
||||||
local results = {}
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."'")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."'")
|
|
||||||
end
|
|
||||||
results = db.results(cur)
|
|
||||||
if results[1] then results = results[1] end
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.daystats(start,ends,user)
|
|
||||||
local cur
|
|
||||||
local results = {}
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT DATE_FORMAT(started,'%d.%m') as day, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' GROUP BY day ORDER BY day ASC")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT DATE_FORMAT(started,'%d.%m') as day, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM logs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."' GROUP BY day ORDER BY day ASC")
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.users()
|
|
||||||
local cur
|
|
||||||
local results = {}
|
|
||||||
cur = db.cursor("SELECT user FROM logs WHERE bytesin>0 GROUP BY user ORDER BY user DESC")
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
return _M
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
local _M = {}
|
|
||||||
local luasql = require "luasql.mysql"
|
|
||||||
local json = require "cjson";
|
|
||||||
_M['date'] = os.date('%Y-%m-%d %H:%M:%S')
|
|
||||||
local db = "log"
|
|
||||||
local db_user = "3proxy"
|
|
||||||
local db_password = "645zzz"
|
|
||||||
local env = assert(luasql.mysql())
|
|
||||||
local con = assert(env:connect(db,db_user,db_password))
|
|
||||||
|
|
||||||
function _M.cursor(data)
|
|
||||||
return assert(con:execute(data))
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.results(cur)
|
|
||||||
local results = {}
|
|
||||||
if not cur then return results end
|
|
||||||
local i = 1
|
|
||||||
row = cur:fetch({},"a")
|
|
||||||
while row do
|
|
||||||
results[i] = {}
|
|
||||||
for key,val in pairs(row) do
|
|
||||||
results[i][key] = val
|
|
||||||
end
|
|
||||||
row = cur:fetch (row, "a")
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
cur:close()
|
|
||||||
--con:close()
|
|
||||||
--env:close()
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
|
|
||||||
return _M
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
local _M = {}
|
|
||||||
local db = require('db.mysql')
|
|
||||||
_M['date'] = os.date('%Y-%m-%d %H:%M:%S')
|
|
||||||
|
|
||||||
function _M.get(limit,offset)
|
|
||||||
local cur
|
|
||||||
if limit == nil then
|
|
||||||
cur = db.cursor("SELECT * FROM vpnlogs ORDER BY started DESC")
|
|
||||||
else
|
|
||||||
if offset == nil then offset = 0 end
|
|
||||||
cur = db.cursor("SELECT * FROM vpnlogs ORDER BY started DESC LIMIT "..limit.." OFFSET "..offset)
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.period(start,ends,user)
|
|
||||||
local cur
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT user,client_ip,DATE_ADD(logs.started, INTERVAL 4 HOUR) as day, ROUND(bytesin/1000,2) as bin, ROUND(bytesout/1000,2) as bout FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' ORDER BY started DESC")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT user,client_ip,DATE_ADD(logs.started, INTERVAL 4 HOUR) as day, ROUND(bytesin/1000,2) as bin, ROUND(bytesout/1000,2) as bout FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."' ORDER BY started DESC")
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.connects(start,ends,user)
|
|
||||||
local cur
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT user, ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, COUNT(*) as connects FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' GROUP BY user ORDER BY connects DESC")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT user, ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, COUNT(*) as connects FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."' GROUP BY user ORDER BY connects DESC")
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.traffic(start,ends,user)
|
|
||||||
local cur
|
|
||||||
local results = {}
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."'")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT ROUND(SUM(bytesin)/1000000) as bin, ROUND(SUM(bytesout)/1000000) as bout, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."'")
|
|
||||||
end
|
|
||||||
results = db.results(cur)
|
|
||||||
if results[1] then results = results[1] end
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.daystats(start,ends,user)
|
|
||||||
local cur
|
|
||||||
local results = {}
|
|
||||||
if user == nil then
|
|
||||||
cur = db.cursor("SELECT DATE_FORMAT(started,'%d.%m') as day, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' GROUP BY day ORDER BY day ASC")
|
|
||||||
else
|
|
||||||
cur = db.cursor("SELECT DATE_FORMAT(started,'%d.%m') as day, ROUND(SUM(bytesin)/1000000) + ROUND(SUM(bytesout)/1000000) as summ FROM vpnlogs WHERE started BETWEEN '"..start.."' AND '"..ends.."' AND user = '"..user.."' GROUP BY day ORDER BY day ASC")
|
|
||||||
end
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
function _M.users()
|
|
||||||
local cur
|
|
||||||
local results = {}
|
|
||||||
cur = db.cursor("SELECT user FROM vpnlogs WHERE bytesin>0 GROUP BY user ORDER BY user DESC")
|
|
||||||
return db.results(cur)
|
|
||||||
end
|
|
||||||
|
|
||||||
return _M
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
local sqlite3 = require("lsqlite3")
|
|
||||||
local json = require("cjson")
|
|
||||||
|
|
||||||
local db = sqlite3.open(ngx.var.document_root..'/sqlite3/tanks.db')
|
|
||||||
|
|
||||||
local _M = {}
|
|
||||||
|
|
||||||
function _M.oktmo(oktmo)
|
|
||||||
local results = {}
|
|
||||||
for row in db:nrows("SELECT * FROM points WHERE oktmo = '"..tostring(oktmo).."'") do table.insert(results,row) end
|
|
||||||
db:close()
|
|
||||||
if not results[1] then return nil end
|
|
||||||
return results[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
return _M
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
local host, port = "ulgrad.ru", 4999
|
|
||||||
local json = require('cjson.safe')
|
|
||||||
local base64 = require('base64')
|
|
||||||
local socket = require("socket")
|
|
||||||
local tcp = assert(socket.tcp())
|
|
||||||
|
|
||||||
tcp:connect(host, port);
|
|
||||||
|
|
||||||
local pack = {}
|
|
||||||
pack['id'] = 'test'
|
|
||||||
pack['bme'] = {['temp'] = 10,['press'] = 100,['alt'] = 300}
|
|
||||||
pack['dht'] = {['temp'] = 12,['humi'] = 67}
|
|
||||||
pack['uf'] = 5
|
|
||||||
|
|
||||||
|
|
||||||
-- eyJibWUiOnsiYWx0IjozMDAsInRlbXAiOjEwLCJwcmVzcyI6MTAwfSwiZGh0Ijp7Imh1bWkiOjY3LCJ0ZW1wIjoxMn0sInVmIjo1LCJpZCI6InRlc3QifQ==
|
|
||||||
|
|
||||||
|
|
||||||
tcp:send(base64.encode(json.encode(pack)))
|
|
||||||
print(base64.encode(json.encode(pack)))
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local s, status, partial = tcp:receive()
|
|
||||||
print(s or partial)
|
|
||||||
print(status)
|
|
||||||
if status == "closed" then break end
|
|
||||||
end
|
|
||||||
tcp:close()
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
nc meteo.ulgrad.ru 4999
|
|
||||||
nc 5.187.7.142 4999
|
|
||||||
11
wget-log
11
wget-log
@ -1,11 +0,0 @@
|
|||||||
--2026-03-08 15:27:42-- https://docs.google.com/spreadsheets/d/e/2PACX-1vQrEP1eukYo2fnNs5zsQgmZTcS1PzIDYL46Lw7un1_v70jP6mgBFqpjOJno9ic-W03PrlxsC3s3YiWA/pub?gid=0
|
|
||||||
Распознаётся docs.google.com (docs.google.com)… 142.251.1.194, 2a00:1450:4010:c1e::c2
|
|
||||||
Подключение к docs.google.com (docs.google.com)|142.251.1.194|:443... соединение установлено.
|
|
||||||
HTTP-запрос отправлен. Ожидание ответа… 200 OK
|
|
||||||
Длина: нет данных [text/html]
|
|
||||||
Сохранение в: ‘pub?gid=0’
|
|
||||||
|
|
||||||
pub?gid=0 [<=> ] 0 --.-KB/s
pub?gid=0 [ <=> ] 34,94K 232KB/s за 0,2s
|
|
||||||
|
|
||||||
2026-03-08 15:27:44 (232 KB/s) - ‘pub?gid=0’ сохранён [35774]
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user