Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
remove native usocket dependency (this broke the tests unfortunately)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Laux committed Mar 1, 2024
1 parent 6b8f447 commit 0599e61
Show file tree
Hide file tree
Showing 4 changed files with 13,403 additions and 714 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* remove native `usocket` dependency (this broke the tests)

## v0.10.2

This is a hotfix release for a bug in the system message bus.
Expand Down
24 changes: 5 additions & 19 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { getDbusAddressFromFs } = require('./address-x11');
const { Message } = require('./message-type');
const { messageToJsFmt, marshallMessage } = require('./marshall-compat');

function createStream (opts) {
function createStream(opts) {
let { busAddress, negotiateUnixFd } = opts;

if (negotiateUnixFd === undefined) {
Expand Down Expand Up @@ -44,25 +44,11 @@ function createStream (opts) {
if (params.socket) {
return net.createConnection(params.socket);
}
if (params.abstract) {
const usocket = require('usocket');
const sock = new usocket.USocket({ path: '\u0000' + params.abstract });
sock.supportsUnixFd = negotiateUnixFd;
return sock;
}
if (params.path) {
try {
const usocket = require('usocket');
const sock = new usocket.USocket({ path: params.path });
sock.supportsUnixFd = negotiateUnixFd;
return sock;
} catch (err) {
// TODO: maybe emit warning?
return net.createConnection(params.path);
}
return net.createConnection(params.path);
}
throw new Error(
"not enough parameters for 'unix' connection - you need to specify 'socket' or 'abstract' or 'path' parameter"
"not enough parameters for 'unix' connection - you need to specify 'socket' or 'path' parameter"
);
}
case 'unixexec': {
Expand Down Expand Up @@ -91,7 +77,7 @@ function createStream (opts) {
}
}

function createConnection (opts) {
function createConnection(opts) {
const self = new EventEmitter();
opts = opts || {};
const stream = (self.stream = createStream(opts));
Expand All @@ -114,7 +100,7 @@ function createConnection (opts) {
return self;
};

function afterHandshake (error, guid) {
function afterHandshake(error, guid) {
if (error) {
return self.emit('error', error);
}
Expand Down
Loading

0 comments on commit 0599e61

Please sign in to comment.