mirror of
https://github.com/danbulant/node-x11
synced 2026-06-15 12:41:29 +00:00
Find cookie with same logic as libXau
This commit is contained in:
parent
ce238c7c0b
commit
e90c1fd239
2 changed files with 18 additions and 15 deletions
29
lib/auth.js
29
lib/auth.js
|
|
@ -5,6 +5,19 @@ var Buffer = require('buffer').Buffer;
|
|||
// add 'unpack' method for buffer
|
||||
require('./unpackbuffer').addUnpack(Buffer);
|
||||
|
||||
var typeToName = {
|
||||
256: 'Local',
|
||||
65535: 'Wild',
|
||||
254: 'Netname',
|
||||
253: 'Krb5Principal',
|
||||
252: 'LocalHost',
|
||||
0: 'Internet',
|
||||
1: 'DECnet',
|
||||
2: 'Chaos',
|
||||
5: 'ServerInterpreted',
|
||||
6: 'InternetV6'
|
||||
};
|
||||
|
||||
function parseXauth( buf )
|
||||
{
|
||||
var offset = 0;
|
||||
|
|
@ -14,20 +27,7 @@ function parseXauth( buf )
|
|||
while (offset < buf.length)
|
||||
{
|
||||
var cookie = {};
|
||||
var typeToName = {
|
||||
256: 'Local',
|
||||
65535: 'Wild',
|
||||
254: 'Netname',
|
||||
253: 'Krb5Principal',
|
||||
252: 'LocalHost',
|
||||
0: 'Internet',
|
||||
1: 'DECnet',
|
||||
2: 'Chaos',
|
||||
5: 'ServerInterpreted',
|
||||
6: 'InternetV6'
|
||||
};
|
||||
cookie.type = buf.readUInt16LE(offset);
|
||||
console.log('Cookie type: ');
|
||||
if (!typeToName[cookie.type]) {
|
||||
console.warn('Unknown address type');
|
||||
}
|
||||
|
|
@ -76,7 +76,8 @@ module.exports = function( display, host, cb )
|
|||
for (var cookieNum in auth)
|
||||
{
|
||||
var cookie = auth[cookieNum];
|
||||
if (cookie.display === display && cookie.address === host)
|
||||
if ((typeToName[cookie.family] === 'Wild' || cookie.address === host) &&
|
||||
(cookie.display.length === 0 || cookie.display === display))
|
||||
return cb( null, cookie );
|
||||
}
|
||||
cb(new Error('No auth cookie matching display=' + display + ' and host=' + host));
|
||||
|
|
|
|||
|
|
@ -192,7 +192,9 @@ function getByteOrder() {
|
|||
function writeClientHello(stream, displayNum, authHost)
|
||||
{
|
||||
getAuthString( displayNum, authHost, function( err, cookie ) {
|
||||
debugger;
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
var byte_order = getByteOrder();
|
||||
var protocol_major = 11; // TODO: config? env?
|
||||
var protocol_minor = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue