mirror of
https://github.com/danbulant/node-x11
synced 2026-07-05 11:10:58 +00:00
reformat code
This commit is contained in:
parent
5645841b80
commit
7a3a1d43a2
1 changed files with 68 additions and 76 deletions
24
lib/auth.js
24
lib/auth.js
|
|
@ -5,8 +5,7 @@ var Buffer = require('buffer').Buffer;
|
||||||
// add 'unpack' method for buffer
|
// add 'unpack' method for buffer
|
||||||
require('./unpackbuffer').addUnpack(Buffer);
|
require('./unpackbuffer').addUnpack(Buffer);
|
||||||
|
|
||||||
function parseXauth( buf )
|
function parseXauth(buf) {
|
||||||
{
|
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
var auth = [];
|
var auth = [];
|
||||||
var cookieProperties = ['address', 'display', 'authName', 'authData'];
|
var cookieProperties = ['address', 'display', 'authName', 'authData'];
|
||||||
|
|
@ -18,8 +17,7 @@ function parseXauth( buf )
|
||||||
offset += length;
|
offset += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (offset < buf.length)
|
while (offset < buf.length) {
|
||||||
{
|
|
||||||
var cookie = {};
|
var cookie = {};
|
||||||
var typeToName = {
|
var typeToName = {
|
||||||
256 : 'Local',
|
256 : 'Local',
|
||||||
|
|
@ -45,11 +43,9 @@ function parseXauth( buf )
|
||||||
return auth;
|
return auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function( display, host, cb )
|
module.exports = function(display, host, cb) {
|
||||||
{
|
|
||||||
var XAuthorityFile = process.env.XAUTHORITY;
|
var XAuthorityFile = process.env.XAUTHORITY;
|
||||||
if (!XAuthorityFile)
|
if (!XAuthorityFile) {
|
||||||
{
|
|
||||||
if (process.platform.match(/^win/)) {
|
if (process.platform.match(/^win/)) {
|
||||||
// http://www.straightrunning.com/XmingNotes/trouble.php
|
// http://www.straightrunning.com/XmingNotes/trouble.php
|
||||||
//
|
//
|
||||||
|
|
@ -65,10 +61,8 @@ module.exports = function( display, host, cb )
|
||||||
|
|
||||||
fs.readFile(XAuthorityFile, function(err, data) {
|
fs.readFile(XAuthorityFile, function(err, data) {
|
||||||
|
|
||||||
if (err)
|
if (err) {
|
||||||
{
|
if (err.code == 'ENOENT') {
|
||||||
if (err.code == 'ENOENT')
|
|
||||||
{
|
|
||||||
cb('', '');
|
cb('', '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -76,11 +70,9 @@ module.exports = function( display, host, cb )
|
||||||
}
|
}
|
||||||
|
|
||||||
var auth = parseXauth(data);
|
var auth = parseXauth(data);
|
||||||
for (var cookieNum in auth)
|
for (var cookieNum in auth) {
|
||||||
{
|
|
||||||
var cookie = auth[cookieNum];
|
var cookie = auth[cookieNum];
|
||||||
if (cookie.display == display && cookie.address == host)
|
if (cookie.display == display && cookie.address == host) {
|
||||||
{
|
|
||||||
cb(cookie.authName, cookie.authData);
|
cb(cookie.authName, cookie.authData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue