Refactorisé un peu le script reverse telnet

This commit is contained in:
Christian Zufferey
2020-02-17 04:29:27 +01:00
parent 0d3dac544d
commit 57461f4e48
3 changed files with 20 additions and 25 deletions

View File

@@ -10,7 +10,7 @@ socat TCP-LISTEN:23047,reuseaddr,fork TCP-LISTEN:24047,reuseaddr,bind=127.0.0.1
telnet -r localhost 24047
]]
print("\n 0_tst3_socat.lua zf200216.1653 \n")
print("\n 0_tst3_socat.lua zf200217.0423 \n")
local node, table, tmr, wifi, uwrite, tostring =
node, table, tmr, wifi, uart.write, tostring
@@ -100,22 +100,21 @@ local function telnet_listener(socket)
node.output(queueLine, 0)
end
--net.createServer(net.TCP, 180):listen(23, telnet_listener)
--print("Telnet server running...\nUsage: telnet -rN ip\n")
srv_rt = net.createConnection(net.TCP, 0)
srv_rt:on("connection", function(sck)
print("connected...")
telnet_listener(sck)
end)
srv_rt:connect(console_port,console_host)
print("Telnet server running...\nUsage: telnet -rN ip\n")
function rt_connect()
srv_rt = net.createConnection(net.TCP, 0)
srv_rt:on("connection", function(sck)
if verbose then print("connected on "..console_host..":"..console_port) end
telnet_listener(sck)
print("Welcome to NodeMCU world.")
end)
srv_rt:connect(console_port,console_host)
end
tmr_socat1=tmr.create()
tmr_socat1:alarm(3*1000, tmr.ALARM_AUTO , function()
if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
@@ -124,18 +123,13 @@ tmr_socat1:alarm(3*1000, tmr.ALARM_AUTO , function()
else
if verbose then
gpio.write(zLED, gpio.HIGH)
print("trying connect "..console_host..":"..console_port)
print("trying connect to "..console_host..":"..console_port)
end
srv_rt = net.createConnection(net.TCP, 0)
srv_rt:on("connection", function(sck)
if verbose then print("connected on "..console_host..":"..console_port) end
telnet_listener(sck)
end)
srv_rt:connect(console_port,console_host)
rt_connect()
end
end)
rt_connect()

View File

@@ -1,9 +1,10 @@
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
# zf200216.1702
# zf200217.0429
Todo à faire pour ce projet !
- ajouter la variable yellow_tag avec le numéro de l'étiquette jaune du NodeMCU
- regarder pour mettre "Welcome to NodeMCU world." quand connected, en fait quand on arrive dans le telnet_listener après la redirection du port série !
- ajouter l'adresse du zdyndns dans les secrets projets
- se connecter sur le zdyndns avec le numéro du port du telnet reverse utilisé

View File

@@ -1,6 +1,6 @@
-- Scripts à charger après le boot pour démarrer son projet
print("\n boot.lua zf200216.1757 \n")
print("\n boot.lua zf200217.0423 \n")
function boot()
verbose = true
@@ -13,7 +13,7 @@ function boot()
--f="0_cron.lua" if file.exists(f) then dofile(f) end
f="0_btn_flipflop.lua" if file.exists(f) then dofile(f) end
--f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end
f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end
--f = "web_ide2.lua" if file.exists(f) then dofile(f) end
print("verbose:",verbose)