diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index d6a77f4..a220d5f 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -16,6 +16,7 @@ Major dependencies includes: - [Roboto font](https://en.wikipedia.org/wiki/Roboto), Licensed under Apache license. Packaged by [Christian Hoffmeister](https://github.com/choffmeister/roboto-fontface-bower), Licensed under Apache 2.0 - [iconv-lite](https://github.com/ashtuchkin/iconv-lite), Licensed under MIT license +- [buffer](https://github.com/feross/buffer), Licensed under MIT license ## For back-end application diff --git a/package-lock.json b/package-lock.json index f2c377e..6d7e674 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3841,14 +3841,13 @@ } }, "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", + "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", "dev": true, "requires": { "base64-js": "^1.0.2", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" + "ieee754": "^1.1.4" } }, "buffer-alloc": { @@ -9615,6 +9614,17 @@ "vm-browserify": "^1.0.1" }, "dependencies": { + "buffer": { + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", diff --git a/package.json b/package.json index 5e3c2e9..5d670ae 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@babel/runtime": "^7.7.4", "babel-eslint": "^10.0.3", "babel-loader": "^8.0.6", + "buffer": "^5.4.3", "clean-webpack-plugin": "^3.0.0", "copy-webpack-plugin": "^5.0.5", "css-loader": "^2.1.1", diff --git a/ui/commands/common.js b/ui/commands/common.js index 627e0c2..26a7763 100644 --- a/ui/commands/common.js +++ b/ui/commands/common.js @@ -16,6 +16,7 @@ // along with this program. If not, see . import * as iconv from "iconv-lite"; +import * as buffer from "buffer/"; import Exception from "./exception.js"; @@ -330,6 +331,18 @@ export function strToUint8Array(d) { return r; } +/** + * Convert string into a binary {Uint8Array} + * + * @param {string} d Input + * + * @returns {Uint8Array} Output + * + */ +export function strToBinary(d) { + return new Uint8Array(buffer.Buffer.from(d, "binary").buffer); +} + /** * Parse IPv6 address. ::ffff: notation is NOT supported * diff --git a/ui/control/ssh.js b/ui/control/ssh.js index 5158123..0c18eb7 100644 --- a/ui/control/ssh.js +++ b/ui/control/ssh.js @@ -20,6 +20,7 @@ import * as iconv from "iconv-lite"; import * as subscribe from "../stream/subscribe.js"; import * as reader from "../stream/reader.js"; import * as color from "../commands/color.js"; +import * as common from "../commands/common.js"; class Control { constructor(data, color) { @@ -125,6 +126,14 @@ class Control { return this.sender(this.charsetEncoder(data)); } + sendBinary(data) { + if (this.closed) { + return; + } + + return this.sender(common.strToBinary(data)); + } + color() { return this.colors.dark; } diff --git a/ui/control/telnet.js b/ui/control/telnet.js index 56aa985..5fb2386 100644 --- a/ui/control/telnet.js +++ b/ui/control/telnet.js @@ -20,6 +20,7 @@ import * as iconv from "iconv-lite"; import * as subscribe from "../stream/subscribe.js"; import * as reader from "../stream/reader.js"; import * as color from "../commands/color.js"; +import * as common from "../commands/common.js"; import Exception from "../commands/exception.js"; // const maxReadBufSize = 1024; @@ -457,13 +458,8 @@ class Control { return -1; } - send(data) { - if (this.closed) { - return; - } - + sendSeg(enc) { let currentLen = 0; - const enc = this.charsetEncoder(data); while (currentLen < enc.length) { const iacPos = this.searchNextIAC(currentLen, enc); @@ -481,6 +477,22 @@ class Control { } } + send(data) { + if (this.closed) { + return; + } + + this.sendSeg(this.charsetEncoder(data)); + } + + sendBinary(data) { + if (this.closed) { + return; + } + + return this.sendSeg(common.strToBinary(data)); + } + color() { return this.colors.dark; } diff --git a/ui/widgets/screen_console.vue b/ui/widgets/screen_console.vue index e1083f1..c17afbd 100644 --- a/ui/widgets/screen_console.vue +++ b/ui/widgets/screen_console.vue @@ -104,7 +104,7 @@ class Term { return; } - control.send(data); + control.sendBinary(data); }); this.term.onKey(ev => {