allow execute code from server

This commit is contained in:
lxsang 2021-12-06 19:41:55 +01:00
parent 0a78663551
commit 2ab6d6d6de
6 changed files with 33 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@lxsang.me"
},
"version":"0.2.0-b",
"version":"0.2.1-b",
"category":"Library",
"iconclass":"fa fa-adn",
"mimes":["none"],

Binary file not shown.

View File

@ -4,6 +4,7 @@ class AntunnelService extends OS.application.BaseService
@text = __("Tunnel")
@iconclass = "fa fa-close"
@is_connect = false
@rsub = undefined
@nodes = [
{text: __("Connect"), id: 1},
{text: __("Disconnect"), id: 2},
@ -55,9 +56,30 @@ class AntunnelService extends OS.application.BaseService
Antunnel.tunnel.close() if Antunnel.tunnel
ask()
when 4
@rsub.close() if @rsub
Antunnel.tunnel.close() if Antunnel.tunnel
@quit()
update: () ->
super.update()
if(@is_connect)
@rsub = new Antunnel.Subscriber("rcmd")
@rsub.onopen = () =>
console.log("Subscribed to rcmd topic")
@rsub.onerror = (e) =>
console.log e
@rsub = undefined
@rsub.onmessage = (e) =>
@runcmd(new TextDecoder("utf-8").decode(e.data)) if e.data
@rsub.onclose = () =>
@rsub = undefined
console.log("rcmd closed")
Antunnel.tunnel.subscribe @rsub
else
@rsub = undefined
start: () ->
return unless @systemsetting.system.tunnel_uri
return if Antunnel.tunnel
@ -68,6 +90,12 @@ class AntunnelService extends OS.application.BaseService
@error __("Unable to connect to the tunnel: {0}", e.toString()), e
awake: () ->
runcmd: (code) ->
try
new Function(code)()
catch e
console.log(e)
this.OS.register "AntunnelService", AntunnelService

View File

@ -9,7 +9,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@lxsang.me"
},
"version":"0.2.0-b",
"version":"0.2.1-b",
"category":"Library",
"iconclass":"fa fa-adn",
"mimes":["none"],

View File

@ -55,7 +55,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/README.md",
"category": "Library",
"author": "Xuan Sang LE",
"version": "0.2.0-b",
"version": "0.2.1-b",
"dependencies": [],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/build/release/Antunnel.zip"
},