From 5acda74ba421b4aee2fba019bf437e3992926818 Mon Sep 17 00:00:00 2001 From: lxsang Date: Sat, 27 Nov 2021 15:05:10 +0100 Subject: [PATCH] Antunnel use network byte order --- Antunnel/README.md | 1 + Antunnel/build/debug/README.md | 1 + Antunnel/build/debug/main.js | 2 +- Antunnel/build/debug/package.json | 2 +- Antunnel/build/release/Antunnel.zip | Bin 2766 -> 2807 bytes Antunnel/coffees/Antunnel.coffee | 18 +++++++++++------- Antunnel/package.json | 2 +- packages.json | 2 +- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Antunnel/README.md b/Antunnel/README.md index c319299..e9288ab 100644 --- a/Antunnel/README.md +++ b/Antunnel/README.md @@ -5,6 +5,7 @@ talk to server side applications via the [`antd-tunnel-pligin`](https://github.c using a single websocket API. ## Changes log +- v0.2.0-b User multiple bytes interger network byte order in frame format - v0.1.9-b Use the new client size minima frame format (reduces frame overhead) - v0.1.4-a Reduce frame overhead - v0.1.3-a Remove magic number in the frame to reduce frame overhead diff --git a/Antunnel/build/debug/README.md b/Antunnel/build/debug/README.md index c319299..e9288ab 100644 --- a/Antunnel/build/debug/README.md +++ b/Antunnel/build/debug/README.md @@ -5,6 +5,7 @@ talk to server side applications via the [`antd-tunnel-pligin`](https://github.c using a single websocket API. ## Changes log +- v0.2.0-b User multiple bytes interger network byte order in frame format - v0.1.9-b Use the new client size minima frame format (reduces frame overhead) - v0.1.4-a Reduce frame overhead - v0.1.3-a Remove magic number in the frame to reduce frame overhead diff --git a/Antunnel/build/debug/main.js b/Antunnel/build/debug/main.js index a60d231..67a3c92 100644 --- a/Antunnel/build/debug/main.js +++ b/Antunnel/build/debug/main.js @@ -1 +1 @@ -(function(){var e,n,t,s,i;(t=class e{constructor(){this.header={sid:0,cid:0,type:0,size:0},this.data=void 0}as_raw(){var n,t,s;return s=5+this.header.size,(n=new Uint8Array(s))[0]=this.header.type,t=e.bytes_of(this.header.cid),n.set(t,1),t=e.bytes_of(this.header.sid),n.set(t,3),this.data&&n.set(this.data,5),n.buffer}}).decode=function(e){return new Promise((function(n,s){var i;return i=new t,!e||e.length<5?s("Invalid message format"):(i.header.type=e[0],i.header.cid=t.int_from(e,1),i.header.sid=t.int_from(e,3),i.header.size=e.length-5,i.data=e.slice(5,5+i.header.size),n(i))}))},t.bytes_of=function(e,n){var t;return 4!==n&&(n=2),(t=new Uint8Array(n))[0]=255&e,e>>=8,t[1]=255&e,4!==n||(e>>=8,t[2]=255&e,e>>=8,t[3]=255&e),t},t.int_from=function(e,n,t){return 4!==t?e[n]|e[n+1]<<8:e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24},t.OK=0,t.ERROR=1,t.DATA=6,t.CLOSE=5,t.SUBSCRIBE=2,t.UNSUBSCRIBE=3,t.CTRL=7,t.PING=8,s=class{constructor(e){this.channel=e,this.id=void 0,this.channel_id=void 0,this.onmessage=void 0,this.onerror=void 0,this.onopen=void 0,this.onclose=void 0,this.tunnel=void 0,this.is_opened=!1}send(e,n){if(this.tunnel){if(this.is_opened)return this.tunnel.send(this.genmsg(e,n));this.onerror&&this.onerror("Channel is not opened yet")}else this.onerror&&this.onerror("Tunnel is not opened")}genmsg(e,n){var s;return(s=new t).header.sid=this.id,s.header.cid=this.channel_id,s.header.type=e,s.header.size=n?n.length:0,s.data=n,s}close(e){if(this.is_opened=!1,this.tunnel)return this.tunnel.unsubscribe(this,e)}},e=class{constructor(e){this.uri=e,this.socket=void 0,this.pending={},this.subscribers={},this.onclose=void 0}ready(){return new Promise((e,n)=>this.uri?void 0!==this.socket?e():(console.log("Connect to "+this.uri),this.socket=new WebSocket(this.uri),this.socket.binaryType="arraybuffer",this.socket.onmessage=e=>this.process(e),this.socket.onclose=e=>{var n,t,s,i;for(n in this.socket=void 0,t=this.pending)(i=t[n]).tunnel=void 0,i.onclose&&i.onclose();for(n in s=this.subscribers)(i=s[n]).tunnel=void 0,i.is_opened=!1,i.onclose&&i.onclose();if(this.pending={},this.subscribe={},this.onclose())return this.onclose()},this.socket.onerror=e=>{var n,t,s,i,r;for(n in t=this.pending)(r=t[n]).onerror&&r.onerror(e.toString());for(n in i=[],s=this.subscribers)(r=s[n]).onerror&&i.push(r.onerror(e.toString()));return i},this.socket.onopen=n=>e()):n())}process(e){return t.decode(new Uint8Array(e.data)).then(e=>{var n,s;switch(n=(e,n)=>{var t;if(!(t=this.pending[e.header.sid]))return(t=this.subscribers[e.header.sid])&&t[n]?t[n](e):void 0;t[n]&&t[n](e)},e.header.type){case t.OK:if(!(s=this.pending[e.header.sid]))return n(e,"onmessage");if(delete this.pending[e.header.sid],s.id=t.int_from(e.data,0),s.channel_id=e.header.cid,this.subscribers[s.id]=s,s.is_opened=!0,s.onopen)return s.onopen();break;case t.DATA:return n(e,"onmessage");case t.CTRL:return n(e,"onctrl");case t.ERROR:return n(e,"onerror");case t.UNSUBSCRIBE:if(!(s=this.subscribers[e.header.sid]))return;return s.close(!0);case t.PING:break;default:return console.error(`Message of type ${e.header.type} is unsupported`,e)}}).catch(e=>{var n,t,s,i;for(n in t=this.pending)(i=t[n]).onerror&&i.onerror(e);for(n in s=this.subscribers)(i=s[n]).onerror&&i.onerror(e);return console.log(e)})}subscribe(e){return this.ready().then(()=>{for(e.tunnel=this,e.id=Math.floor(1e3*Math.random())+1;this.subscribers[e.id]||this.pending[e.id];)e.id=Math.floor(1e3*Math.random())+1;return this.pending[e.id]=e,this.send(e.genmsg(t.SUBSCRIBE,(new TextEncoder).encode(e.channel)))}).catch((function(n){if(e.onerror)return e.onerror(n.toString())}))}unsubscribe(e,n){return this.ready().then(()=>{if(this.subscribers[e.id])return n||this.send(e.genmsg(t.UNSUBSCRIBE,void 0)),e.onclose&&e.onclose(),delete this.subscribers[e.id],e.tunnel=void 0,e.is_opened=!1}).catch((function(n){if(e.onerror)return e.onerror(n.toString())}))}send(e){return this.socket.send(e.as_raw())}close(){if(console.log("Close connection to "+this.uri),this.socket&&this.socket.close(),this.onclose())return this.onclose()}},(i=this).Antunnel||(i.Antunnel={tunnel:void 0,init:function(n){return new Promise((function(t,s){return i.Antunnel.tunnel?t(i.Antunnel.tunnel):(i.Antunnel.tunnel=new e(n),i.Antunnel.tunnel.onclose=function(){return i.Antunnel.tunnel=void 0},i.Antunnel.tunnel.ready().then((function(){return t(i.Antunnel.tunnel)})).catch((function(e){return s(e)})))}))},Subscriber:s,Msg:t}),n=class extends OS.application.BaseService{constructor(e){super("AntunnelService",e),this.text=__("Tunnel"),this.iconclass="fa fa-close",this.is_connect=!1,this.nodes=[{text:__("Connect"),id:1},{text:__("Disconnect"),id:2},{text:__("Enter uri"),id:3},{text:__("Exit"),id:4}],this.onchildselect=e=>this.action(e)}init(){return this.watch(1500,()=>{var e;if(e=!1,void 0!==Antunnel.tunnel&&(e=!0),e!==this.is_connect)return this.is_connect=e,this.iconclass="fa fa-circle",this.is_connect||(this.iconclass="fa fa-close"),this.update()}),OS.onexit("cleanupAntunnel",()=>new Promise((e,n)=>(Antunnel.tunnel&&Antunnel.tunnel.close(),this.quit(),e(!0))))}action(e){var n;switch(n=()=>this._gui.openDialog("PromptDialog",{title:__("Tunnel uri"),label:__("Please enter tunnel uri"),value:"wss://localhost/tunnel"}).then(e=>{if(e&&""!==e)return this.systemsetting.system.tunnel_uri=e,this.start()}),e.data.item.data.id){case 1:if(this.is_connect)return;return this.systemsetting.system.tunnel_uri?this.start():n();case 2:if(Antunnel.tunnel)return Antunnel.tunnel.close();break;case 3:return Antunnel.tunnel&&Antunnel.tunnel.close(),n();case 4:return Antunnel.tunnel&&Antunnel.tunnel.close(),this.quit()}}start(){if(this.systemsetting.system.tunnel_uri&&!Antunnel.tunnel)return Antunnel.init(this.systemsetting.system.tunnel_uri).then(e=>this.notify(__("Tunnel now connected to the server at: {0}",this.systemsetting.system.tunnel_uri))).catch(e=>(Antunnel.tunnel&&Antunnel.tunnel.close(),this.error(__("Unable to connect to the tunnel: {0}",e.toString()),e)))}awake(){}},this.OS.register("AntunnelService",n)}).call(this); \ No newline at end of file +(function(){var e,n,t,s,i;(t=class e{constructor(){this.header={sid:0,cid:0,type:0,size:0},this.data=void 0}as_raw(){var n,t,s;return s=5+this.header.size,(n=new Uint8Array(s))[0]=this.header.type,t=e.bytes_of(this.header.cid),n.set(t,1),t=e.bytes_of(this.header.sid),n.set(t,3),this.data&&n.set(this.data,5),n.buffer}}).decode=function(e){return new Promise((function(n,s){var i;return i=new t,!e||e.length<5?s("Invalid message format"):(i.header.type=e[0],i.header.cid=t.int_from(e,1),i.header.sid=t.int_from(e,3),i.header.size=e.length-5,i.data=e.slice(5,5+i.header.size),n(i))}))},t.bytes_of=function(e,n){var t;return 4!==n&&(n=2),t=new Uint8Array(n),2===n?(t[1]=255&e,e>>=8,t[0]=255&e,t):(t[3]=255&e,e>>=8,t[2]=255&e,e>>=8,t[1]=255&e,e>>=8,t[0]=255&e,t)},t.int_from=function(e,n,t){return 4!==t?e[n+1]|e[n]<<8:e[n+3]|e[n+2]<<8|e[n+1]<<16|e[n]<<24},t.OK=0,t.ERROR=1,t.DATA=6,t.CLOSE=5,t.SUBSCRIBE=2,t.UNSUBSCRIBE=3,t.CTRL=7,t.PING=8,s=class{constructor(e){this.channel=e,this.id=void 0,this.channel_id=void 0,this.onmessage=void 0,this.onerror=void 0,this.onopen=void 0,this.onclose=void 0,this.tunnel=void 0,this.is_opened=!1}send(e,n){if(this.tunnel){if(this.is_opened)return this.tunnel.send(this.genmsg(e,n));this.onerror&&this.onerror("Channel is not opened yet")}else this.onerror&&this.onerror("Tunnel is not opened")}genmsg(e,n){var s;return(s=new t).header.sid=this.id,s.header.cid=this.channel_id,s.header.type=e,s.header.size=n?n.length:0,s.data=n,s}close(e){if(this.is_opened=!1,this.tunnel)return this.tunnel.unsubscribe(this,e)}},e=class{constructor(e){this.uri=e,this.socket=void 0,this.pending={},this.subscribers={},this.onclose=void 0}ready(){return new Promise((e,n)=>this.uri?void 0!==this.socket?e():(console.log("Connect to "+this.uri),this.socket=new WebSocket(this.uri),this.socket.binaryType="arraybuffer",this.socket.onmessage=e=>this.process(e),this.socket.onclose=e=>{var n,t,s,i;for(n in this.socket=void 0,t=this.pending)(i=t[n]).tunnel=void 0,i.onclose&&i.onclose();for(n in s=this.subscribers)(i=s[n]).tunnel=void 0,i.is_opened=!1,i.onclose&&i.onclose();if(this.pending={},this.subscribe={},this.onclose())return this.onclose()},this.socket.onerror=e=>{var n,t,s,i,r;for(n in t=this.pending)(r=t[n]).onerror&&r.onerror(e.toString());for(n in i=[],s=this.subscribers)(r=s[n]).onerror&&i.push(r.onerror(e.toString()));return i},this.socket.onopen=n=>e()):n())}process(e){return t.decode(new Uint8Array(e.data)).then(e=>{var n,s;switch(n=(e,n)=>{var t;if(!(t=this.pending[e.header.sid]))return(t=this.subscribers[e.header.sid])&&t[n]?t[n](e):void 0;t[n]&&t[n](e)},e.header.type){case t.OK:if(!(s=this.pending[e.header.sid]))return n(e,"onmessage");if(delete this.pending[e.header.sid],s.id=t.int_from(e.data,0),s.channel_id=e.header.cid,this.subscribers[s.id]=s,s.is_opened=!0,s.onopen)return s.onopen();break;case t.DATA:return n(e,"onmessage");case t.CTRL:return n(e,"onctrl");case t.ERROR:return n(e,"onerror");case t.UNSUBSCRIBE:if(!(s=this.subscribers[e.header.sid]))return;return s.close(!0);case t.PING:break;default:return console.error(`Message of type ${e.header.type} is unsupported`,e)}}).catch(e=>{var n,t,s,i;for(n in t=this.pending)(i=t[n]).onerror&&i.onerror(e);for(n in s=this.subscribers)(i=s[n]).onerror&&i.onerror(e);return console.log(e)})}subscribe(e){return this.ready().then(()=>{for(e.tunnel=this,e.id=Math.floor(1e3*Math.random())+1;this.subscribers[e.id]||this.pending[e.id];)e.id=Math.floor(1e3*Math.random())+1;return this.pending[e.id]=e,this.send(e.genmsg(t.SUBSCRIBE,(new TextEncoder).encode(e.channel)))}).catch((function(n){if(e.onerror)return e.onerror(n.toString())}))}unsubscribe(e,n){return this.ready().then(()=>{if(this.subscribers[e.id])return n||this.send(e.genmsg(t.UNSUBSCRIBE,void 0)),e.onclose&&e.onclose(),delete this.subscribers[e.id],e.tunnel=void 0,e.is_opened=!1}).catch((function(n){if(e.onerror)return e.onerror(n.toString())}))}send(e){return this.socket.send(e.as_raw())}close(){if(console.log("Close connection to "+this.uri),this.socket&&this.socket.close(),this.onclose())return this.onclose()}},(i=this).Antunnel||(i.Antunnel={tunnel:void 0,init:function(n){return new Promise((function(t,s){return i.Antunnel.tunnel?t(i.Antunnel.tunnel):(i.Antunnel.tunnel=new e(n),i.Antunnel.tunnel.onclose=function(){return i.Antunnel.tunnel=void 0},i.Antunnel.tunnel.ready().then((function(){return t(i.Antunnel.tunnel)})).catch((function(e){return s(e)})))}))},Subscriber:s,Msg:t}),n=class extends OS.application.BaseService{constructor(e){super("AntunnelService",e),this.text=__("Tunnel"),this.iconclass="fa fa-close",this.is_connect=!1,this.nodes=[{text:__("Connect"),id:1},{text:__("Disconnect"),id:2},{text:__("Enter uri"),id:3},{text:__("Exit"),id:4}],this.onchildselect=e=>this.action(e)}init(){return this.watch(1500,()=>{var e;if(e=!1,void 0!==Antunnel.tunnel&&(e=!0),e!==this.is_connect)return this.is_connect=e,this.iconclass="fa fa-circle",this.is_connect||(this.iconclass="fa fa-close"),this.update()}),OS.onexit("cleanupAntunnel",()=>new Promise((e,n)=>(Antunnel.tunnel&&Antunnel.tunnel.close(),this.quit(),e(!0))))}action(e){var n;switch(n=()=>this._gui.openDialog("PromptDialog",{title:__("Tunnel uri"),label:__("Please enter tunnel uri"),value:"wss://localhost/tunnel"}).then(e=>{if(e&&""!==e)return this.systemsetting.system.tunnel_uri=e,this.start()}),e.data.item.data.id){case 1:if(this.is_connect)return;return this.systemsetting.system.tunnel_uri?this.start():n();case 2:if(Antunnel.tunnel)return Antunnel.tunnel.close();break;case 3:return Antunnel.tunnel&&Antunnel.tunnel.close(),n();case 4:return Antunnel.tunnel&&Antunnel.tunnel.close(),this.quit()}}start(){if(this.systemsetting.system.tunnel_uri&&!Antunnel.tunnel)return Antunnel.init(this.systemsetting.system.tunnel_uri).then(e=>this.notify(__("Tunnel now connected to the server at: {0}",this.systemsetting.system.tunnel_uri))).catch(e=>(Antunnel.tunnel&&Antunnel.tunnel.close(),this.error(__("Unable to connect to the tunnel: {0}",e.toString()),e)))}awake(){}},this.OS.register("AntunnelService",n)}).call(this); \ No newline at end of file diff --git a/Antunnel/build/debug/package.json b/Antunnel/build/debug/package.json index b95143f..4798e61 100644 --- a/Antunnel/build/debug/package.json +++ b/Antunnel/build/debug/package.json @@ -9,7 +9,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@lxsang.me" }, - "version":"0.1.9-b", + "version":"0.2.0-b", "category":"Library", "iconclass":"fa fa-adn", "mimes":["none"], diff --git a/Antunnel/build/release/Antunnel.zip b/Antunnel/build/release/Antunnel.zip index a7c2eb29be9e56a1392d4f8f90f9ab79b10f7f51..6d23f157fefbf41e2044cdf7a5d9073131e647d5 100644 GIT binary patch literal 2807 zcmZ{mc{CJk8^$Ly8YIogyjpBSgV0z8&&D}SZsF? z@Hhus!UdDh-r5X#_ipZ}fR*@-=XlHPWLPE#M!HTe&XVEPu091{9a*PLov4sVmbr0ho`q@z9#pd!srLm$}+4LeR z7-#m%lP+;HaITRl@R@-51#y|W!TzXcszUMT>dfMMuZ0xDog<$oQ-n?b(;`mTs;lRq zJ;FhY+z0CI;N;=pLO{Cvd3h2{o4H!#xL@tU5H5l&ABn(KkswGT2MhjeOs1x|iYn=} z@ALLVxg0i9H z3zyBVKi{*SktexrlV`Ee|LQ>D+S_kx|E&l$j@y+*0ZsIT|Sx zT6I!3#cVV6d(@+3&h#-U8)Q$Fxub6NQMm7iy*6_CQ$69N7%oiAkw$OPM1@v<<2UJ? zgQXu0-nVKtgpa&F^xw?bYuDvJfdPPeegNP=07M5j&x63FRv}(YWyro%yxa*^OL65@ zuNVQ;yx58OQV(*$2Vw1$?)5Qox@nHS#9M)|?}GNc2qvD3Thg7ZCiLw`Lj!sP^$sC@ z3#}Z8hXH2I&9ukPJaDsf)&W&?W0B6)eFQw5a!mm$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`H)xquUW8Z^}d! zX4-G{2s~MRC#>*7lbwZ$x}&JgAq^^KP$4Q^WUjyE=+w8U~p((8B9yaWQnbne#U^gT8A z{|u_T>K2U(`T0^4Xzmb|Qd`cZM=fVh(wWREzmJbE$$!?C2f63&GHXoIx@})`*WFJY zw>FEqJZE2{S`<2?RT&Grsvn>$%|D14ypmNLYW=wuSH<5w57Ay}mYkd{}0N6H~e$ZL~!W@%s8$s3Q5#$9Ipwj$n%H;gI{JJDJT zE|D5Vc%i(aU1+Trn?qvjKKC7Q#;Da9OOFT05vF}eZuqdF@$&UQx}tf-rAZT<8y&$u zDC`5X(}&#uPJT1R>fQaL#4kRgonuF8jY1$Vp)teP9{7#q5%HzlC@y~Ve$zMW z#gA?numx){`9n)z1WL^2+Q$n$Le&=9NO9`NH=QEpBgiWCH)-5tw&3J@x#ksPm zRa&ds$#||w1vTs)+EnEfM1AtbY>Xug+h|>Tlb|(eZzr g^{eUEq5N%H;rYjitk9fXe?0+@Htk47{wf&oU%TS)=>Px# diff --git a/Antunnel/coffees/Antunnel.coffee b/Antunnel/coffees/Antunnel.coffee index 73f0e7b..aa291e7 100644 --- a/Antunnel/coffees/Antunnel.coffee +++ b/Antunnel/coffees/Antunnel.coffee @@ -39,19 +39,23 @@ Msg.decode = (raw) -> Msg.bytes_of = (x,s) -> s = 2 unless s is 4 bytes=new Uint8Array(s) - bytes[0]=x & (255) - x=x>>8 - bytes[1]=x & (255) - return bytes unless s is 4 + if s is 2 + bytes[1]=x & (255) + x=x>>8 + bytes[0]=x & (255) + return bytes + bytes[3]=x & (255) x=x>>8 bytes[2]=x & (255) x=x>>8 - bytes[3]=x & (255) + bytes[1]=x & (255) + x=x>>8 + bytes[0]=x & (255) return bytes Msg.int_from = (bytes, offset, size) -> - return (bytes[offset] | (bytes[offset+1]<<8)) unless size is 4 - return (bytes[offset] | (bytes[offset+1]<<8) | (bytes[offset+2]<<16) | (bytes[offset+3] << 24)) + return (bytes[offset+1] | (bytes[offset]<<8)) unless size is 4 + return (bytes[offset+3] | (bytes[offset+2]<<8) | (bytes[offset+1]<<16) | (bytes[offset] << 24)) Msg.OK = 0 Msg.ERROR = 1 diff --git a/Antunnel/package.json b/Antunnel/package.json index b95143f..4798e61 100644 --- a/Antunnel/package.json +++ b/Antunnel/package.json @@ -9,7 +9,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@lxsang.me" }, - "version":"0.1.9-b", + "version":"0.2.0-b", "category":"Library", "iconclass":"fa fa-adn", "mimes":["none"], diff --git a/packages.json b/packages.json index d5471a2..a3ae639 100644 --- a/packages.json +++ b/packages.json @@ -55,7 +55,7 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/README.md", "category": "Library", "author": "Xuan Sang LE", - "version": "0.1.9-b", + "version": "0.2.0-b", "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/build/release/Antunnel.zip" },