update TLS servername for frame stream
This commit is contained in:
parent
7f2f14ec4d
commit
a14c260bb4
2 changed files with 4 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ const { bblCA } = require('./certificates');
|
||||||
class FrameStream extends EventEmitter {
|
class FrameStream extends EventEmitter {
|
||||||
#remoteSocket;
|
#remoteSocket;
|
||||||
|
|
||||||
constructor(host, code) {
|
constructor(host, code, serial) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const abuf = new ArrayBuffer(80);
|
const abuf = new ArrayBuffer(80);
|
||||||
|
|
@ -25,12 +25,11 @@ class FrameStream extends EventEmitter {
|
||||||
new Uint8Array(abuf, 0x30, codeBytes.length).set(codeBytes);
|
new Uint8Array(abuf, 0x30, codeBytes.length).set(codeBytes);
|
||||||
|
|
||||||
let frame;
|
let frame;
|
||||||
|
|
||||||
const remoteSocket = this.#remoteSocket = tls.connect({
|
const remoteSocket = this.#remoteSocket = tls.connect({
|
||||||
host,
|
host,
|
||||||
port: 6000,
|
port: 6000,
|
||||||
ca: bblCA,
|
ca: bblCA,
|
||||||
checkServerIdentity: () => {} // TODO: use `servername: serial` instead
|
servername: serial
|
||||||
}, () => {
|
}, () => {
|
||||||
// send authentication to start jpeg frame stream
|
// send authentication to start jpeg frame stream
|
||||||
remoteSocket.write(Buffer.from(abuf));
|
remoteSocket.write(Buffer.from(abuf));
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,8 @@ module.exports = async (server) => {
|
||||||
this.#frames.end();
|
this.#frames.end();
|
||||||
this.#frames = undefined;
|
this.#frames = undefined;
|
||||||
} else if (!this.#frames && bool) {
|
} else if (!this.#frames && bool) {
|
||||||
this.#frames = new FrameStream(this.#options.host, this.#options.password)
|
let { host, password } = this.#options;
|
||||||
|
this.#frames = new FrameStream(host, password, this.#serial)
|
||||||
.on("frame", jpg => {
|
.on("frame", jpg => {
|
||||||
wsend({ serial: this.#serial, frame: jpg.toString('base64') });
|
wsend({ serial: this.#serial, frame: jpg.toString('base64') });
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue