sessix-server 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +117 -61
- package/dist/server.js +117 -61
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299,7 +299,7 @@ var import_uuid5 = require("uuid");
|
|
|
299
299
|
var import_promises4 = require("fs/promises");
|
|
300
300
|
var import_node_os6 = require("os");
|
|
301
301
|
var import_node_path5 = require("path");
|
|
302
|
-
var
|
|
302
|
+
var import_node_child_process6 = require("child_process");
|
|
303
303
|
var import_node_util = require("util");
|
|
304
304
|
|
|
305
305
|
// src/providers/ProcessProvider.ts
|
|
@@ -2059,79 +2059,120 @@ var ApprovalProxy = class _ApprovalProxy {
|
|
|
2059
2059
|
};
|
|
2060
2060
|
|
|
2061
2061
|
// src/mdns/MdnsService.ts
|
|
2062
|
-
var
|
|
2062
|
+
var import_node_child_process3 = require("child_process");
|
|
2063
2063
|
var import_node_os4 = require("os");
|
|
2064
|
-
function
|
|
2065
|
-
|
|
2066
|
-
for (const [name, addrs] of Object.entries((0, import_node_os4.networkInterfaces)())) {
|
|
2067
|
-
if (name.startsWith("utun") || name === "lo") continue;
|
|
2068
|
-
if (isWindows && (name.startsWith("vEthernet") || name.includes("Loopback"))) continue;
|
|
2069
|
-
for (const addr of addrs ?? []) {
|
|
2070
|
-
if (addr.family === "IPv4" && !addr.internal) {
|
|
2071
|
-
results.push(addr.address);
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
return results;
|
|
2064
|
+
function buildTxtArgs(txt) {
|
|
2065
|
+
return Object.entries(txt).map(([k, v]) => `${k}=${v}`);
|
|
2076
2066
|
}
|
|
2077
2067
|
var MdnsService = class {
|
|
2078
|
-
|
|
2079
|
-
|
|
2068
|
+
proc = null;
|
|
2069
|
+
bonjourInstance = null;
|
|
2070
|
+
bonjourService = null;
|
|
2080
2071
|
wsPort;
|
|
2081
2072
|
httpPort;
|
|
2082
2073
|
version;
|
|
2083
2074
|
pairing;
|
|
2075
|
+
useDnsSd;
|
|
2084
2076
|
constructor(options) {
|
|
2085
2077
|
this.wsPort = options.wsPort;
|
|
2086
2078
|
this.httpPort = options.httpPort;
|
|
2087
2079
|
this.version = options.version ?? "0.1.0";
|
|
2088
2080
|
this.pairing = options.pairing ?? "closed";
|
|
2081
|
+
this.useDnsSd = (0, import_node_os4.platform)() === "darwin";
|
|
2082
|
+
}
|
|
2083
|
+
getTxt() {
|
|
2084
|
+
return {
|
|
2085
|
+
version: this.version,
|
|
2086
|
+
httpPort: String(this.httpPort),
|
|
2087
|
+
wsPort: String(this.wsPort),
|
|
2088
|
+
pairing: this.pairing
|
|
2089
|
+
};
|
|
2089
2090
|
}
|
|
2090
2091
|
/**
|
|
2091
2092
|
* 启动 mDNS 广播
|
|
2092
2093
|
*/
|
|
2093
2094
|
start() {
|
|
2094
|
-
if (this.
|
|
2095
|
+
if (this.useDnsSd) {
|
|
2096
|
+
this.startDnsSd();
|
|
2097
|
+
} else {
|
|
2098
|
+
this.startBonjour();
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
startDnsSd() {
|
|
2102
|
+
if (this.proc) {
|
|
2095
2103
|
console.warn(`[MdnsService] ${t("mdns.alreadyRunning")}`);
|
|
2096
2104
|
return;
|
|
2097
2105
|
}
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
wsPort: String(this.wsPort),
|
|
2117
|
-
pairing: this.pairing
|
|
2106
|
+
const args = [
|
|
2107
|
+
"-R",
|
|
2108
|
+
"Sessix",
|
|
2109
|
+
"_sessix._tcp",
|
|
2110
|
+
"local",
|
|
2111
|
+
String(this.wsPort),
|
|
2112
|
+
...buildTxtArgs(this.getTxt())
|
|
2113
|
+
];
|
|
2114
|
+
this.proc = (0, import_node_child_process3.spawn)("dns-sd", args, { stdio: "ignore" });
|
|
2115
|
+
this.proc.on("error", (err) => {
|
|
2116
|
+
console.warn(`[MdnsService] dns-sd failed, falling back to bonjour-service: ${err.message}`);
|
|
2117
|
+
this.proc = null;
|
|
2118
|
+
this.useDnsSd = false;
|
|
2119
|
+
this.startBonjour();
|
|
2120
|
+
});
|
|
2121
|
+
this.proc.on("exit", (code) => {
|
|
2122
|
+
if (code !== null && code !== 0) {
|
|
2123
|
+
console.warn(`[MdnsService] dns-sd exited with code ${code}`);
|
|
2118
2124
|
}
|
|
2125
|
+
this.proc = null;
|
|
2119
2126
|
});
|
|
2120
|
-
console.log(`[MdnsService] ${t("mdns.started", { port: this.wsPort })}`);
|
|
2127
|
+
console.log(`[MdnsService] ${t("mdns.started", { port: this.wsPort })} (dns-sd)`);
|
|
2128
|
+
}
|
|
2129
|
+
async startBonjour() {
|
|
2130
|
+
if (this.bonjourInstance) {
|
|
2131
|
+
console.warn(`[MdnsService] ${t("mdns.alreadyRunning")}`);
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
try {
|
|
2135
|
+
const { default: Bonjour } = await import("bonjour-service");
|
|
2136
|
+
const { networkInterfaces: networkInterfaces2 } = await import("os");
|
|
2137
|
+
const lanAddrs = getLanAddresses(networkInterfaces2);
|
|
2138
|
+
const opts = lanAddrs.length > 0 ? { interface: lanAddrs[0] } : {};
|
|
2139
|
+
const onError = (err) => {
|
|
2140
|
+
if (err.code === "EADDRINUSE") return;
|
|
2141
|
+
console.warn(`[MdnsService] mDNS error (non-fatal): ${err.message}`);
|
|
2142
|
+
};
|
|
2143
|
+
this.bonjourInstance = new Bonjour(opts, onError);
|
|
2144
|
+
this.bonjourInstance.server?.mdns?.on("error", onError);
|
|
2145
|
+
if (lanAddrs.length > 0) {
|
|
2146
|
+
console.log(`[MdnsService] ${t("mdns.boundInterface", { ip: lanAddrs[0] })}`);
|
|
2147
|
+
}
|
|
2148
|
+
this.bonjourService = this.bonjourInstance.publish({
|
|
2149
|
+
name: "Sessix",
|
|
2150
|
+
type: "sessix",
|
|
2151
|
+
port: this.wsPort,
|
|
2152
|
+
txt: this.getTxt()
|
|
2153
|
+
});
|
|
2154
|
+
console.log(`[MdnsService] ${t("mdns.started", { port: this.wsPort })} (bonjour-service)`);
|
|
2155
|
+
} catch (err) {
|
|
2156
|
+
console.warn(`[MdnsService] bonjour-service failed: ${err.message}`);
|
|
2157
|
+
}
|
|
2121
2158
|
}
|
|
2122
2159
|
/**
|
|
2123
2160
|
* 停止 mDNS 广播
|
|
2124
2161
|
*/
|
|
2125
2162
|
stop() {
|
|
2126
|
-
if (this.
|
|
2127
|
-
this.
|
|
2163
|
+
if (this.proc) {
|
|
2164
|
+
this.proc.kill();
|
|
2165
|
+
this.proc = null;
|
|
2166
|
+
}
|
|
2167
|
+
if (this.bonjourService) {
|
|
2168
|
+
this.bonjourService.stop?.(() => {
|
|
2128
2169
|
console.log(`[MdnsService] ${t("mdns.stopped")}`);
|
|
2129
2170
|
});
|
|
2130
|
-
this.
|
|
2171
|
+
this.bonjourService = null;
|
|
2131
2172
|
}
|
|
2132
|
-
if (this.
|
|
2133
|
-
this.
|
|
2134
|
-
this.
|
|
2173
|
+
if (this.bonjourInstance) {
|
|
2174
|
+
this.bonjourInstance.destroy();
|
|
2175
|
+
this.bonjourInstance = null;
|
|
2135
2176
|
}
|
|
2136
2177
|
console.log(`[MdnsService] ${t("mdns.closed")}`);
|
|
2137
2178
|
}
|
|
@@ -2140,30 +2181,45 @@ var MdnsService = class {
|
|
|
2140
2181
|
*/
|
|
2141
2182
|
updatePairingState(state) {
|
|
2142
2183
|
this.pairing = state;
|
|
2143
|
-
if (
|
|
2184
|
+
if (this.useDnsSd) {
|
|
2185
|
+
if (this.proc) {
|
|
2186
|
+
this.proc.kill();
|
|
2187
|
+
this.proc = null;
|
|
2188
|
+
}
|
|
2189
|
+
this.startDnsSd();
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
if (!this.bonjourInstance) return;
|
|
2144
2193
|
const republish = () => {
|
|
2145
|
-
if (!this.
|
|
2146
|
-
this.
|
|
2194
|
+
if (!this.bonjourInstance) return;
|
|
2195
|
+
this.bonjourService = this.bonjourInstance.publish({
|
|
2147
2196
|
name: "Sessix",
|
|
2148
2197
|
type: "sessix",
|
|
2149
2198
|
port: this.wsPort,
|
|
2150
|
-
txt:
|
|
2151
|
-
version: this.version,
|
|
2152
|
-
httpPort: String(this.httpPort),
|
|
2153
|
-
wsPort: String(this.wsPort),
|
|
2154
|
-
pairing: state
|
|
2155
|
-
}
|
|
2199
|
+
txt: this.getTxt()
|
|
2156
2200
|
});
|
|
2157
2201
|
};
|
|
2158
|
-
if (this.
|
|
2159
|
-
const old = this.
|
|
2160
|
-
this.
|
|
2202
|
+
if (this.bonjourService) {
|
|
2203
|
+
const old = this.bonjourService;
|
|
2204
|
+
this.bonjourService = null;
|
|
2161
2205
|
old.stop?.(() => republish());
|
|
2162
2206
|
} else {
|
|
2163
2207
|
republish();
|
|
2164
2208
|
}
|
|
2165
2209
|
}
|
|
2166
2210
|
};
|
|
2211
|
+
function getLanAddresses(networkInterfacesFn) {
|
|
2212
|
+
const results = [];
|
|
2213
|
+
for (const [name, addrs] of Object.entries(networkInterfacesFn())) {
|
|
2214
|
+
if (name.startsWith("utun") || name === "lo") continue;
|
|
2215
|
+
for (const addr of addrs ?? []) {
|
|
2216
|
+
if (addr.family === "IPv4" && !addr.internal) {
|
|
2217
|
+
results.push(addr.address);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
return results;
|
|
2222
|
+
}
|
|
2167
2223
|
|
|
2168
2224
|
// src/hooks/HookInstaller.ts
|
|
2169
2225
|
var import_promises2 = require("fs/promises");
|
|
@@ -2637,7 +2693,7 @@ var NotificationService = class {
|
|
|
2637
2693
|
};
|
|
2638
2694
|
|
|
2639
2695
|
// src/notification/DesktopNotificationChannel.ts
|
|
2640
|
-
var
|
|
2696
|
+
var import_node_child_process4 = require("child_process");
|
|
2641
2697
|
var DesktopNotificationChannel = class {
|
|
2642
2698
|
isAvailable() {
|
|
2643
2699
|
return process.platform === "darwin";
|
|
@@ -2649,7 +2705,7 @@ var DesktopNotificationChannel = class {
|
|
|
2649
2705
|
const sound = payload.sound ?? "Ping";
|
|
2650
2706
|
const script = `display notification "${body}" with title "${title}" sound name "${sound}"`;
|
|
2651
2707
|
return new Promise((resolve) => {
|
|
2652
|
-
(0,
|
|
2708
|
+
(0, import_node_child_process4.execFile)("osascript", ["-e", script], (err) => {
|
|
2653
2709
|
if (err) {
|
|
2654
2710
|
console.warn("[DesktopNotificationChannel] Send notification failed:", err.message);
|
|
2655
2711
|
}
|
|
@@ -3401,7 +3457,7 @@ var AuthManager = class extends import_events2.EventEmitter {
|
|
|
3401
3457
|
var import_promises5 = require("fs/promises");
|
|
3402
3458
|
|
|
3403
3459
|
// src/terminal/TerminalExecutor.ts
|
|
3404
|
-
var
|
|
3460
|
+
var import_node_child_process5 = require("child_process");
|
|
3405
3461
|
var import_uuid4 = require("uuid");
|
|
3406
3462
|
var EXEC_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
3407
3463
|
var TerminalExecutor = class {
|
|
@@ -3427,7 +3483,7 @@ var TerminalExecutor = class {
|
|
|
3427
3483
|
const execId = (0, import_uuid4.v4)();
|
|
3428
3484
|
const shell = isWindows ? "powershell" : "bash";
|
|
3429
3485
|
const args = isWindows ? ["-Command", command] : ["-c", command];
|
|
3430
|
-
const proc = (0,
|
|
3486
|
+
const proc = (0, import_node_child_process5.spawn)(shell, args, {
|
|
3431
3487
|
cwd,
|
|
3432
3488
|
stdio: ["ignore", "pipe", "pipe"],
|
|
3433
3489
|
env: { ...process.env }
|
|
@@ -3490,7 +3546,7 @@ var TerminalExecutor = class {
|
|
|
3490
3546
|
// src/server.ts
|
|
3491
3547
|
var WS_PORT = 3745;
|
|
3492
3548
|
var HTTP_PORT = 3746;
|
|
3493
|
-
var execAsync = (0, import_node_util.promisify)(
|
|
3549
|
+
var execAsync = (0, import_node_util.promisify)(import_node_child_process6.exec);
|
|
3494
3550
|
async function killPortProcess(port) {
|
|
3495
3551
|
try {
|
|
3496
3552
|
if (isWindows) {
|
package/dist/server.js
CHANGED
|
@@ -305,7 +305,7 @@ var import_uuid5 = require("uuid");
|
|
|
305
305
|
var import_promises4 = require("fs/promises");
|
|
306
306
|
var import_node_os6 = require("os");
|
|
307
307
|
var import_node_path5 = require("path");
|
|
308
|
-
var
|
|
308
|
+
var import_node_child_process6 = require("child_process");
|
|
309
309
|
var import_node_util = require("util");
|
|
310
310
|
|
|
311
311
|
// src/providers/ProcessProvider.ts
|
|
@@ -2065,79 +2065,120 @@ var ApprovalProxy = class _ApprovalProxy {
|
|
|
2065
2065
|
};
|
|
2066
2066
|
|
|
2067
2067
|
// src/mdns/MdnsService.ts
|
|
2068
|
-
var
|
|
2068
|
+
var import_node_child_process3 = require("child_process");
|
|
2069
2069
|
var import_node_os4 = require("os");
|
|
2070
|
-
function
|
|
2071
|
-
|
|
2072
|
-
for (const [name, addrs] of Object.entries((0, import_node_os4.networkInterfaces)())) {
|
|
2073
|
-
if (name.startsWith("utun") || name === "lo") continue;
|
|
2074
|
-
if (isWindows && (name.startsWith("vEthernet") || name.includes("Loopback"))) continue;
|
|
2075
|
-
for (const addr of addrs ?? []) {
|
|
2076
|
-
if (addr.family === "IPv4" && !addr.internal) {
|
|
2077
|
-
results.push(addr.address);
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
return results;
|
|
2070
|
+
function buildTxtArgs(txt) {
|
|
2071
|
+
return Object.entries(txt).map(([k, v]) => `${k}=${v}`);
|
|
2082
2072
|
}
|
|
2083
2073
|
var MdnsService = class {
|
|
2084
|
-
|
|
2085
|
-
|
|
2074
|
+
proc = null;
|
|
2075
|
+
bonjourInstance = null;
|
|
2076
|
+
bonjourService = null;
|
|
2086
2077
|
wsPort;
|
|
2087
2078
|
httpPort;
|
|
2088
2079
|
version;
|
|
2089
2080
|
pairing;
|
|
2081
|
+
useDnsSd;
|
|
2090
2082
|
constructor(options) {
|
|
2091
2083
|
this.wsPort = options.wsPort;
|
|
2092
2084
|
this.httpPort = options.httpPort;
|
|
2093
2085
|
this.version = options.version ?? "0.1.0";
|
|
2094
2086
|
this.pairing = options.pairing ?? "closed";
|
|
2087
|
+
this.useDnsSd = (0, import_node_os4.platform)() === "darwin";
|
|
2088
|
+
}
|
|
2089
|
+
getTxt() {
|
|
2090
|
+
return {
|
|
2091
|
+
version: this.version,
|
|
2092
|
+
httpPort: String(this.httpPort),
|
|
2093
|
+
wsPort: String(this.wsPort),
|
|
2094
|
+
pairing: this.pairing
|
|
2095
|
+
};
|
|
2095
2096
|
}
|
|
2096
2097
|
/**
|
|
2097
2098
|
* 启动 mDNS 广播
|
|
2098
2099
|
*/
|
|
2099
2100
|
start() {
|
|
2100
|
-
if (this.
|
|
2101
|
+
if (this.useDnsSd) {
|
|
2102
|
+
this.startDnsSd();
|
|
2103
|
+
} else {
|
|
2104
|
+
this.startBonjour();
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
startDnsSd() {
|
|
2108
|
+
if (this.proc) {
|
|
2101
2109
|
console.warn(`[MdnsService] ${t("mdns.alreadyRunning")}`);
|
|
2102
2110
|
return;
|
|
2103
2111
|
}
|
|
2104
|
-
const
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
wsPort: String(this.wsPort),
|
|
2123
|
-
pairing: this.pairing
|
|
2112
|
+
const args = [
|
|
2113
|
+
"-R",
|
|
2114
|
+
"Sessix",
|
|
2115
|
+
"_sessix._tcp",
|
|
2116
|
+
"local",
|
|
2117
|
+
String(this.wsPort),
|
|
2118
|
+
...buildTxtArgs(this.getTxt())
|
|
2119
|
+
];
|
|
2120
|
+
this.proc = (0, import_node_child_process3.spawn)("dns-sd", args, { stdio: "ignore" });
|
|
2121
|
+
this.proc.on("error", (err) => {
|
|
2122
|
+
console.warn(`[MdnsService] dns-sd failed, falling back to bonjour-service: ${err.message}`);
|
|
2123
|
+
this.proc = null;
|
|
2124
|
+
this.useDnsSd = false;
|
|
2125
|
+
this.startBonjour();
|
|
2126
|
+
});
|
|
2127
|
+
this.proc.on("exit", (code) => {
|
|
2128
|
+
if (code !== null && code !== 0) {
|
|
2129
|
+
console.warn(`[MdnsService] dns-sd exited with code ${code}`);
|
|
2124
2130
|
}
|
|
2131
|
+
this.proc = null;
|
|
2125
2132
|
});
|
|
2126
|
-
console.log(`[MdnsService] ${t("mdns.started", { port: this.wsPort })}`);
|
|
2133
|
+
console.log(`[MdnsService] ${t("mdns.started", { port: this.wsPort })} (dns-sd)`);
|
|
2134
|
+
}
|
|
2135
|
+
async startBonjour() {
|
|
2136
|
+
if (this.bonjourInstance) {
|
|
2137
|
+
console.warn(`[MdnsService] ${t("mdns.alreadyRunning")}`);
|
|
2138
|
+
return;
|
|
2139
|
+
}
|
|
2140
|
+
try {
|
|
2141
|
+
const { default: Bonjour } = await import("bonjour-service");
|
|
2142
|
+
const { networkInterfaces } = await import("os");
|
|
2143
|
+
const lanAddrs = getLanAddresses(networkInterfaces);
|
|
2144
|
+
const opts = lanAddrs.length > 0 ? { interface: lanAddrs[0] } : {};
|
|
2145
|
+
const onError = (err) => {
|
|
2146
|
+
if (err.code === "EADDRINUSE") return;
|
|
2147
|
+
console.warn(`[MdnsService] mDNS error (non-fatal): ${err.message}`);
|
|
2148
|
+
};
|
|
2149
|
+
this.bonjourInstance = new Bonjour(opts, onError);
|
|
2150
|
+
this.bonjourInstance.server?.mdns?.on("error", onError);
|
|
2151
|
+
if (lanAddrs.length > 0) {
|
|
2152
|
+
console.log(`[MdnsService] ${t("mdns.boundInterface", { ip: lanAddrs[0] })}`);
|
|
2153
|
+
}
|
|
2154
|
+
this.bonjourService = this.bonjourInstance.publish({
|
|
2155
|
+
name: "Sessix",
|
|
2156
|
+
type: "sessix",
|
|
2157
|
+
port: this.wsPort,
|
|
2158
|
+
txt: this.getTxt()
|
|
2159
|
+
});
|
|
2160
|
+
console.log(`[MdnsService] ${t("mdns.started", { port: this.wsPort })} (bonjour-service)`);
|
|
2161
|
+
} catch (err) {
|
|
2162
|
+
console.warn(`[MdnsService] bonjour-service failed: ${err.message}`);
|
|
2163
|
+
}
|
|
2127
2164
|
}
|
|
2128
2165
|
/**
|
|
2129
2166
|
* 停止 mDNS 广播
|
|
2130
2167
|
*/
|
|
2131
2168
|
stop() {
|
|
2132
|
-
if (this.
|
|
2133
|
-
this.
|
|
2169
|
+
if (this.proc) {
|
|
2170
|
+
this.proc.kill();
|
|
2171
|
+
this.proc = null;
|
|
2172
|
+
}
|
|
2173
|
+
if (this.bonjourService) {
|
|
2174
|
+
this.bonjourService.stop?.(() => {
|
|
2134
2175
|
console.log(`[MdnsService] ${t("mdns.stopped")}`);
|
|
2135
2176
|
});
|
|
2136
|
-
this.
|
|
2177
|
+
this.bonjourService = null;
|
|
2137
2178
|
}
|
|
2138
|
-
if (this.
|
|
2139
|
-
this.
|
|
2140
|
-
this.
|
|
2179
|
+
if (this.bonjourInstance) {
|
|
2180
|
+
this.bonjourInstance.destroy();
|
|
2181
|
+
this.bonjourInstance = null;
|
|
2141
2182
|
}
|
|
2142
2183
|
console.log(`[MdnsService] ${t("mdns.closed")}`);
|
|
2143
2184
|
}
|
|
@@ -2146,30 +2187,45 @@ var MdnsService = class {
|
|
|
2146
2187
|
*/
|
|
2147
2188
|
updatePairingState(state) {
|
|
2148
2189
|
this.pairing = state;
|
|
2149
|
-
if (
|
|
2190
|
+
if (this.useDnsSd) {
|
|
2191
|
+
if (this.proc) {
|
|
2192
|
+
this.proc.kill();
|
|
2193
|
+
this.proc = null;
|
|
2194
|
+
}
|
|
2195
|
+
this.startDnsSd();
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
if (!this.bonjourInstance) return;
|
|
2150
2199
|
const republish = () => {
|
|
2151
|
-
if (!this.
|
|
2152
|
-
this.
|
|
2200
|
+
if (!this.bonjourInstance) return;
|
|
2201
|
+
this.bonjourService = this.bonjourInstance.publish({
|
|
2153
2202
|
name: "Sessix",
|
|
2154
2203
|
type: "sessix",
|
|
2155
2204
|
port: this.wsPort,
|
|
2156
|
-
txt:
|
|
2157
|
-
version: this.version,
|
|
2158
|
-
httpPort: String(this.httpPort),
|
|
2159
|
-
wsPort: String(this.wsPort),
|
|
2160
|
-
pairing: state
|
|
2161
|
-
}
|
|
2205
|
+
txt: this.getTxt()
|
|
2162
2206
|
});
|
|
2163
2207
|
};
|
|
2164
|
-
if (this.
|
|
2165
|
-
const old = this.
|
|
2166
|
-
this.
|
|
2208
|
+
if (this.bonjourService) {
|
|
2209
|
+
const old = this.bonjourService;
|
|
2210
|
+
this.bonjourService = null;
|
|
2167
2211
|
old.stop?.(() => republish());
|
|
2168
2212
|
} else {
|
|
2169
2213
|
republish();
|
|
2170
2214
|
}
|
|
2171
2215
|
}
|
|
2172
2216
|
};
|
|
2217
|
+
function getLanAddresses(networkInterfacesFn) {
|
|
2218
|
+
const results = [];
|
|
2219
|
+
for (const [name, addrs] of Object.entries(networkInterfacesFn())) {
|
|
2220
|
+
if (name.startsWith("utun") || name === "lo") continue;
|
|
2221
|
+
for (const addr of addrs ?? []) {
|
|
2222
|
+
if (addr.family === "IPv4" && !addr.internal) {
|
|
2223
|
+
results.push(addr.address);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
return results;
|
|
2228
|
+
}
|
|
2173
2229
|
|
|
2174
2230
|
// src/hooks/HookInstaller.ts
|
|
2175
2231
|
var import_promises2 = require("fs/promises");
|
|
@@ -2643,7 +2699,7 @@ var NotificationService = class {
|
|
|
2643
2699
|
};
|
|
2644
2700
|
|
|
2645
2701
|
// src/notification/DesktopNotificationChannel.ts
|
|
2646
|
-
var
|
|
2702
|
+
var import_node_child_process4 = require("child_process");
|
|
2647
2703
|
var DesktopNotificationChannel = class {
|
|
2648
2704
|
isAvailable() {
|
|
2649
2705
|
return process.platform === "darwin";
|
|
@@ -2655,7 +2711,7 @@ var DesktopNotificationChannel = class {
|
|
|
2655
2711
|
const sound = payload.sound ?? "Ping";
|
|
2656
2712
|
const script = `display notification "${body}" with title "${title}" sound name "${sound}"`;
|
|
2657
2713
|
return new Promise((resolve) => {
|
|
2658
|
-
(0,
|
|
2714
|
+
(0, import_node_child_process4.execFile)("osascript", ["-e", script], (err) => {
|
|
2659
2715
|
if (err) {
|
|
2660
2716
|
console.warn("[DesktopNotificationChannel] Send notification failed:", err.message);
|
|
2661
2717
|
}
|
|
@@ -3407,7 +3463,7 @@ var AuthManager = class extends import_events2.EventEmitter {
|
|
|
3407
3463
|
var import_promises5 = require("fs/promises");
|
|
3408
3464
|
|
|
3409
3465
|
// src/terminal/TerminalExecutor.ts
|
|
3410
|
-
var
|
|
3466
|
+
var import_node_child_process5 = require("child_process");
|
|
3411
3467
|
var import_uuid4 = require("uuid");
|
|
3412
3468
|
var EXEC_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
3413
3469
|
var TerminalExecutor = class {
|
|
@@ -3433,7 +3489,7 @@ var TerminalExecutor = class {
|
|
|
3433
3489
|
const execId = (0, import_uuid4.v4)();
|
|
3434
3490
|
const shell = isWindows ? "powershell" : "bash";
|
|
3435
3491
|
const args = isWindows ? ["-Command", command] : ["-c", command];
|
|
3436
|
-
const proc = (0,
|
|
3492
|
+
const proc = (0, import_node_child_process5.spawn)(shell, args, {
|
|
3437
3493
|
cwd,
|
|
3438
3494
|
stdio: ["ignore", "pipe", "pipe"],
|
|
3439
3495
|
env: { ...process.env }
|
|
@@ -3496,7 +3552,7 @@ var TerminalExecutor = class {
|
|
|
3496
3552
|
// src/server.ts
|
|
3497
3553
|
var WS_PORT = 3745;
|
|
3498
3554
|
var HTTP_PORT = 3746;
|
|
3499
|
-
var execAsync = (0, import_node_util.promisify)(
|
|
3555
|
+
var execAsync = (0, import_node_util.promisify)(import_node_child_process6.exec);
|
|
3500
3556
|
async function killPortProcess(port) {
|
|
3501
3557
|
try {
|
|
3502
3558
|
if (isWindows) {
|