This commit is contained in:
2026-02-15 19:16:18 +01:00
commit 96ab29b481
8 changed files with 422 additions and 0 deletions

27
unix-socket.mjs Normal file
View File

@@ -0,0 +1,27 @@
import fs from 'node:fs';
export class Unix_Socket {
constructor(path) {
Object.assign(this, { path });
}
get connect_options() {
const { path } = this;
return { path };
}
listen(server, on_listening) {
const { path } = this;
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
server.listen(path, () => {
fs.chmodSync(path, 0o666);
on_listening?.();
});
}
}