aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-10 20:39:11 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-10 20:39:11 -0800
commit8911c398d9ed8a7bcb0413128f2db62b355e2adc (patch)
treee8f12ee5433092406acf6ac0c7914a367eaf72f3
parent1738588f38413e9e29c899eaa8f22e4220f949ef (diff)
downloadbun-8911c398d9ed8a7bcb0413128f2db62b355e2adc.tar.gz
bun-8911c398d9ed8a7bcb0413128f2db62b355e2adc.tar.zst
bun-8911c398d9ed8a7bcb0413128f2db62b355e2adc.zip
Support socketPath
-rw-r--r--src/bun.js/net.exports.js29
1 files changed, 22 insertions, 7 deletions
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;
}