mirror of
https://github.com/danbulant/node-x11
synced 2026-07-05 11:10:58 +00:00
Collecting the cookies information in a loop
This commit is contained in:
parent
d7bfb91ca3
commit
4407b398a4
1 changed files with 15 additions and 20 deletions
35
lib/auth.js
35
lib/auth.js
|
|
@ -22,29 +22,24 @@ function parseXauth( buf )
|
||||||
0: 'Internet',
|
0: 'Internet',
|
||||||
1: 'DECnet',
|
1: 'DECnet',
|
||||||
2: 'Chaos',
|
2: 'Chaos',
|
||||||
5: 'ServerInterpreted',
|
5: 'ServerInterpreted',
|
||||||
6: 'InternetV6'
|
6: 'InternetV6'
|
||||||
};
|
};
|
||||||
|
var cookieFields = [
|
||||||
|
'address',
|
||||||
|
'display',
|
||||||
|
'authName',
|
||||||
|
'authData'
|
||||||
|
];
|
||||||
cookie.type = buf.unpack('n')[0];
|
cookie.type = buf.unpack('n')[0];
|
||||||
offset += 2;
|
offset += 2;
|
||||||
// TODO: rewrite following using loop (16bits length + string data)
|
for (var i = 0; i < 4; i += 1) {
|
||||||
var addressLen = buf.unpack('n', offset)[0];
|
var length = buf.unpack('n', offset)[0];
|
||||||
offset += 2;
|
offset += 2;
|
||||||
cookie.address = buf.unpackString(addressLen, offset);
|
cookie[cookieFields[i]] = buf.unpackString(length, offset);
|
||||||
offset += addressLen;
|
offset += length;
|
||||||
var displayNumLen = buf.unpack('n', offset)[0];
|
}
|
||||||
offset += 2;
|
auth.push(cookie);
|
||||||
cookie.display = buf.unpackString(displayNumLen, offset);
|
|
||||||
offset += displayNumLen;
|
|
||||||
var authNameLen = buf.unpack('n', offset)[0];
|
|
||||||
offset += 2;
|
|
||||||
cookie.authName = buf.unpackString(authNameLen, offset);
|
|
||||||
offset += authNameLen;
|
|
||||||
var authDataLen = buf.unpack('n', offset)[0];
|
|
||||||
offset += 2;
|
|
||||||
cookie.authData = buf.unpackString(authDataLen, offset);
|
|
||||||
offset += authDataLen;
|
|
||||||
auth.push(cookie);
|
|
||||||
}
|
}
|
||||||
return auth;
|
return auth;
|
||||||
}
|
}
|
||||||
|
|
@ -92,4 +87,4 @@ module.exports = function( display, host, cb )
|
||||||
// throw 'No auth cookie matching display=' + display + ' and host=' + host;
|
// throw 'No auth cookie matching display=' + display + ' and host=' + host;
|
||||||
cb( '', '' );
|
cb( '', '' );
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue