Complètement refactorisé encore une fois mon socat et rtelnet, j'ai toujours la fuite mémoire à la déconnection
This commit is contained in:
@@ -7,7 +7,7 @@ cron1:alarm(10*1000, tmr.ALARM_AUTO, function()
|
||||
-- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
|
||||
|
||||
|
||||
rt_launch()
|
||||
-- rt_launch()
|
||||
|
||||
|
||||
-- http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1")
|
||||
|
||||
@@ -1,38 +1,11 @@
|
||||
--[[
|
||||
tests connection reverse telnet commande à faire tourner sur le GATEWAY !
|
||||
-- script telnet pour le socat
|
||||
|
||||
1ere console
|
||||
pour une liaison directe:
|
||||
socat TCP-LISTEN:23064,fork,reuseaddr STDIO
|
||||
pour une console sur un port:
|
||||
socat TCP-LISTEN:23043,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1
|
||||
|
||||
2e console
|
||||
telnet -r localhost 23000
|
||||
]]
|
||||
|
||||
--[[
|
||||
tests connection reverse telnet commande à faire tourner sur le GATEWAY ET sur sa MACHINE !
|
||||
|
||||
1ere console sur le GATEWAY
|
||||
socat TCP-LISTEN:23043,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1
|
||||
|
||||
2e console sur sa MACHINE
|
||||
ssh -L 23000:localhost:23000 user@GATEWAY
|
||||
|
||||
3e console sur sa MACHINE (~.return pour sortir !)
|
||||
telnet -r localhost 23000
|
||||
ou sur MAC
|
||||
telnet -rN localhost 23000
|
||||
]]
|
||||
|
||||
|
||||
print("\n 0_tst4_socat.lua zf200621.1352 \n")
|
||||
|
||||
local node, table, tmr, uwrite, tostring =
|
||||
node, table, tmr, uart.write, tostring
|
||||
|
||||
local function telnet_listener(socket)
|
||||
function telnet_listener(socket)
|
||||
print("\n 0_rtelnet1.lua zf200621.1603 \n")
|
||||
|
||||
local node, table, tmr, uwrite, tostring =
|
||||
node, table, tmr, uart.write, tostring
|
||||
|
||||
print("................telnet_listener")
|
||||
local insert, remove, concat, heap, gc =
|
||||
table.insert, table.remove, table.concat, node.heap, collectgarbage
|
||||
@@ -94,6 +67,7 @@ local function telnet_listener(socket)
|
||||
|
||||
local function disconnect(_,zerr)
|
||||
node.output(nil)
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
print("................disconnect")
|
||||
|
||||
if socket~=nil then
|
||||
@@ -101,14 +75,14 @@ local function telnet_listener(socket)
|
||||
print("................disconnect 2e", socket, socket:getpeer())
|
||||
end
|
||||
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil
|
||||
collectgarbage()
|
||||
-- fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil
|
||||
print("disconnected... "..zerr..", "..node.heap())
|
||||
-- if debug_rec~=nil then debug_rec("disconnect, disconnected, "..zerr..", "..node.heap()) end
|
||||
rt_connect()
|
||||
end
|
||||
|
||||
-- telnet_listener=nil
|
||||
collectgarbage()
|
||||
-- rt_connect()
|
||||
end
|
||||
|
||||
--zzz
|
||||
local function zconnection(s)
|
||||
print("socket: ",socket)
|
||||
@@ -131,76 +105,3 @@ local function telnet_listener(socket)
|
||||
-- print(queueLine, 0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function rt_connect()
|
||||
print("................rt_connect")
|
||||
collectgarbage()
|
||||
local zlaps=tmr.now()/1000000-ztime_connect
|
||||
print("durée de retry connect... "..zlaps)
|
||||
-- if debug_rec~=nil then debug_rec("durée de retry connect... "..zlaps..", "..node.heap()) end
|
||||
if zlaps>1.5 then
|
||||
local zstr="trying connect to "..console_host..":"..console_port..", "..node.heap()
|
||||
-- if debug_rec~=nil then debug_rec(zstr) end
|
||||
if verbose==verbose then
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||
print(zstr)
|
||||
end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_try_con_"..yellow_id.." ram="..node.heap()) end
|
||||
ztime_connect=tmr.now()/1000000
|
||||
|
||||
srv_rt=nil
|
||||
srv_rt = net.createConnection(net.TCP, 0)
|
||||
|
||||
srv_rt:on("connection", function(sck)
|
||||
print("................connection")
|
||||
if debug_rec~=nil then debug_rec("rt_connect, srv_rt:on, connected on, "..node.heap()) end
|
||||
collectgarbage()
|
||||
-- if verbose then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
print("connected on "..console_host..":"..console_port)
|
||||
print(node.heap())
|
||||
-- end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_connected_"..yellow_id.." ram="..node.heap()) end
|
||||
telnet_listener(sck)
|
||||
print("Welcome to NodeMCU world.")
|
||||
end)
|
||||
|
||||
srv_rt:connect(console_port,console_host)
|
||||
else
|
||||
print("on ne se reconnecte pas vite 1x...")
|
||||
end
|
||||
collectgarbage()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function rt_launch()
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=tmr_socat1_"..yellow_id.." ram="..node.heap()) end
|
||||
if srv_rt~=nil then
|
||||
-- if http_post~=nil then http_post(influxdb_url,"energy,memory=srv_rt_no_nil_"..yellow_id.." ram="..node.heap()) end
|
||||
if console_port ~= srv_rt:getpeer() then
|
||||
rt_connect()
|
||||
end
|
||||
else
|
||||
rt_connect()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- tmr_socat1=tmr.create()
|
||||
-- tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , rt_launch)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ztime_connect=tmr.now()/1000000
|
||||
|
||||
-- rt_launch()
|
||||
|
||||
print("Revers telnet server running...\n")
|
||||
99
Mesures/energy/transfo_courant_clip_1p_1/0_tst5_socat.lua
Normal file
99
Mesures/energy/transfo_courant_clip_1p_1/0_tst5_socat.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
--[[
|
||||
tests connection reverse telnet commande à faire tourner sur le GATEWAY !
|
||||
|
||||
1ere console
|
||||
pour une liaison directe:
|
||||
socat TCP-LISTEN:23064,fork,reuseaddr STDIO
|
||||
pour une console sur un port:
|
||||
socat TCP-LISTEN:23043,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1
|
||||
|
||||
2e console
|
||||
telnet -r localhost 23000
|
||||
]]
|
||||
|
||||
--[[
|
||||
tests connection reverse telnet commande à faire tourner sur le GATEWAY ET sur sa MACHINE !
|
||||
|
||||
1ere console sur le GATEWAY
|
||||
socat TCP-LISTEN:23043,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1
|
||||
|
||||
2e console sur sa MACHINE
|
||||
ssh -L 23000:localhost:23000 user@GATEWAY
|
||||
|
||||
3e console sur sa MACHINE (~.return pour sortir !)
|
||||
telnet -r localhost 23000
|
||||
ou sur MAC
|
||||
telnet -rN localhost 23000
|
||||
]]
|
||||
|
||||
print("\n 0_tst5_socat.lua zf200621.1603 \n")
|
||||
|
||||
function rt_connect()
|
||||
print("................rt_connect")
|
||||
collectgarbage()
|
||||
local zlaps=tmr.now()/1000000-ztime_connect
|
||||
print("durée de retry connect... "..zlaps)
|
||||
-- if debug_rec~=nil then debug_rec("durée de retry connect... "..zlaps..", "..node.heap()) end
|
||||
if zlaps>1.5 then
|
||||
local zstr="trying connect to "..console_host..":"..console_port..", "..node.heap()
|
||||
-- if debug_rec~=nil then debug_rec(zstr) end
|
||||
if verbose==verbose then
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||
print(zstr)
|
||||
end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_try_con_"..yellow_id.." ram="..node.heap()) end
|
||||
ztime_connect=tmr.now()/1000000
|
||||
|
||||
srv_rt=nil
|
||||
srv_rt = net.createConnection(net.TCP, 0)
|
||||
|
||||
srv_rt:on("connection", function(sck)
|
||||
print("................connection")
|
||||
if debug_rec~=nil then debug_rec("rt_connect, srv_rt:on, connected on, "..node.heap()) end
|
||||
collectgarbage()
|
||||
-- if verbose then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
print("connected on "..console_host..":"..console_port)
|
||||
print(node.heap())
|
||||
-- end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_connected_"..yellow_id.." ram="..node.heap()) end
|
||||
dofile("0_rtelnet1.lua")
|
||||
telnet_listener(sck)
|
||||
print("Welcome to NodeMCU world.")
|
||||
end)
|
||||
|
||||
srv_rt:connect(console_port,console_host)
|
||||
else
|
||||
print("on ne se reconnecte pas vite 1x...")
|
||||
end
|
||||
collectgarbage()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function rt_launch()
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=tmr_socat1_"..yellow_id.." ram="..node.heap()) end
|
||||
if srv_rt~=nil then
|
||||
-- if http_post~=nil then http_post(influxdb_url,"energy,memory=srv_rt_no_nil_"..yellow_id.." ram="..node.heap()) end
|
||||
if console_port ~= srv_rt:getpeer() then
|
||||
rt_connect()
|
||||
end
|
||||
else
|
||||
rt_connect()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- tmr_socat1=tmr.create()
|
||||
-- tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , rt_launch)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ztime_connect=tmr.now()/1000000
|
||||
|
||||
-- rt_launch()
|
||||
|
||||
print("Revers telnet server running...\n")
|
||||
@@ -3,7 +3,7 @@ zf200621.1125
|
||||
verbose=true
|
||||
rt_connect()
|
||||
|
||||
|
||||
telnet_listener=nil
|
||||
|
||||
|
||||
for k,v in ipairs(debug.getregistry()) do print(k,v) end
|
||||
@@ -15,6 +15,12 @@ node.compile('0_tst4_socat.lua')
|
||||
|
||||
print(srv_rt)
|
||||
print(srv_rt:getpeer())
|
||||
srv_rt:close()
|
||||
|
||||
print(socket)
|
||||
print(socket:getpeer())
|
||||
socket:close()
|
||||
|
||||
|
||||
node.output(nil)
|
||||
|
||||
|
||||
@@ -41,9 +41,7 @@ for k,v in pairs(_G) do print(k,v) end
|
||||
ssh ubuntu@www.zuzu-test.ml
|
||||
socat TCP-LISTEN:23064,fork,reuseaddr STDIO
|
||||
|
||||
|
||||
|
||||
|
||||
# pour les tests en remote
|
||||
killall -9 ssh
|
||||
ssh ubuntu@www.zuzu-test.ml killall -9 socat
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- Petit script pour initaliser la couche WIFI
|
||||
|
||||
function wifi_init()
|
||||
print("\n wifi_init.lua zf200612.1602 \n")
|
||||
print("\n wifi_init.lua zf200621.1608 \n")
|
||||
|
||||
f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_project.lua" if file.exists(f) then dofile(f) end
|
||||
@@ -14,7 +14,7 @@ function wifi_init()
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
-- f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
f="0_tst4_socat.lua" if file.exists(f) then dofile(f) end
|
||||
f="0_tst5_socat.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
-- f= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
|
||||
Reference in New Issue
Block a user