()
| 2297 | } |
| 2298 | |
| 2299 | _negotiateServerInit() { |
| 2300 | if (this._sock.rQwait("server initialization", 24)) { return false; } |
| 2301 | |
| 2302 | /* Screen size */ |
| 2303 | const width = this._sock.rQshift16(); |
| 2304 | const height = this._sock.rQshift16(); |
| 2305 | |
| 2306 | /* PIXEL_FORMAT */ |
| 2307 | const bpp = this._sock.rQshift8(); |
| 2308 | const depth = this._sock.rQshift8(); |
| 2309 | const bigEndian = this._sock.rQshift8(); |
| 2310 | const trueColor = this._sock.rQshift8(); |
| 2311 | |
| 2312 | const redMax = this._sock.rQshift16(); |
| 2313 | const greenMax = this._sock.rQshift16(); |
| 2314 | const blueMax = this._sock.rQshift16(); |
| 2315 | const redShift = this._sock.rQshift8(); |
| 2316 | const greenShift = this._sock.rQshift8(); |
| 2317 | const blueShift = this._sock.rQshift8(); |
| 2318 | this._sock.rQskipBytes(3); // padding |
| 2319 | |
| 2320 | // NB(directxman12): we don't want to call any callbacks or print messages until |
| 2321 | // *after* we're past the point where we could backtrack |
| 2322 | |
| 2323 | /* Connection name/title */ |
| 2324 | const nameLength = this._sock.rQshift32(); |
| 2325 | if (this._sock.rQwait('server init name', nameLength, 24)) { return false; } |
| 2326 | let name = this._sock.rQshiftStr(nameLength); |
| 2327 | name = decodeUTF8(name, true); |
| 2328 | |
| 2329 | if (this._rfbTightVNC) { |
| 2330 | if (this._sock.rQwait('TightVNC extended server init header', 8, 24 + nameLength)) { return false; } |
| 2331 | // In TightVNC mode, ServerInit message is extended |
| 2332 | const numServerMessages = this._sock.rQshift16(); |
| 2333 | const numClientMessages = this._sock.rQshift16(); |
| 2334 | const numEncodings = this._sock.rQshift16(); |
| 2335 | this._sock.rQskipBytes(2); // padding |
| 2336 | |
| 2337 | const totalMessagesLength = (numServerMessages + numClientMessages + numEncodings) * 16; |
| 2338 | if (this._sock.rQwait('TightVNC extended server init header', totalMessagesLength, 32 + nameLength)) { return false; } |
| 2339 | |
| 2340 | // we don't actually do anything with the capability information that TIGHT sends, |
| 2341 | // so we just skip the all of this. |
| 2342 | |
| 2343 | // TIGHT server message capabilities |
| 2344 | this._sock.rQskipBytes(16 * numServerMessages); |
| 2345 | |
| 2346 | // TIGHT client message capabilities |
| 2347 | this._sock.rQskipBytes(16 * numClientMessages); |
| 2348 | |
| 2349 | // TIGHT encoding capabilities |
| 2350 | this._sock.rQskipBytes(16 * numEncodings); |
| 2351 | } |
| 2352 | |
| 2353 | // NB(directxman12): these are down here so that we don't run them multiple times |
| 2354 | // if we backtrack |
| 2355 | Log.Info("Screen: " + width + "x" + height + |
| 2356 | ", bpp: " + bpp + ", depth: " + depth + |
no test coverage detected