From 48cf9ffee11747835bd2d26a7756ed621edefc63 Mon Sep 17 00:00:00 2001 From: Izaya Date: Sun, 15 Apr 2018 23:19:48 +1000 Subject: [PATCH] made vtunnel clean up after itself better, hopefully --- vTunnel/OpenOS/etc/rc.d/vtunnel.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vTunnel/OpenOS/etc/rc.d/vtunnel.lua b/vTunnel/OpenOS/etc/rc.d/vtunnel.lua index 848219e..afa817a 100644 --- a/vTunnel/OpenOS/etc/rc.d/vtunnel.lua +++ b/vTunnel/OpenOS/etc/rc.d/vtunnel.lua @@ -8,6 +8,7 @@ local internet = component.internet local addr, raddr = vcomp.uuid(),vcomp.uuid() local poll = 0.5 local listener, timer +local socket -- dumb keepalive stuff local keepalive = 30 @@ -16,7 +17,7 @@ local katimer function start(iaddr,port) if listener then return end iaddr,port = iaddr or "shadowkat.net", tonumber(port) or 4096 - local socket = internet.connect(iaddr,port) + socket = internet.connect(iaddr,port) print("Connecting to "..iaddr..":"..tostring(port).."...") repeat os.sleep(0.5) @@ -73,7 +74,12 @@ function stop() event.cancel(timer) timer = nil end - if component.type(addr) then - vcomp.unregister(addr) + if katimer then + event.cancel(katimer) + katimer = nil end + if component.type(addr) then + vcomp.unregister(addr) + end + socket.close() end