From 8911c398d9ed8a7bcb0413128f2db62b355e2adc Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 10 Jan 2023 20:39:11 -0800 Subject: Support socketPath --- src/bun.js/net.exports.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/bun.js/net.exports.js b/src/bun.js/net.exports.js index 67fc66ae6..8d283dd1e 100644 --- a/src/bun.js/net.exports.js +++ b/src/bun.js/net.exports.js @@ -196,7 +196,13 @@ export const Socket = (function (InternalSocket) { connect(port, host, connectListener) { // TODO support IPC sockets + var path; if (typeof host == "function") { + if (typeof port === "string") { + path = port; + port = undefined; + } + connectListener = host; host = undefined; } @@ -223,13 +229,22 @@ export const Socket = (function (InternalSocket) { if (typeof bunTLS === "function") { tls = bunTLS.call(this, port, host); } - bunConnect({ - data: this, - hostname: host || "localhost", - port: port, - socket: Socket.#Handlers, - tls, - }); + bunConnect( + path + ? { + data: this, + unix: path, + socket: Socket.#Handlers, + tls, + } + : { + data: this, + hostname: host || "localhost", + port: port, + socket: Socket.#Handlers, + tls, + }, + ); return this; } -- cgit v1.2.3