Skip to content

Commit

Permalink
???
Browse files Browse the repository at this point in the history
  • Loading branch information
booploops committed Jun 27, 2024
1 parent 354bd7d commit eb3ab51
Show file tree
Hide file tree
Showing 8 changed files with 551 additions and 5,008 deletions.
20 changes: 11 additions & 9 deletions airplay-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ const {
parentPort,
workerData,
} = require("node:worker_threads");
var { WebSocketServer } = require("ws");
const wss = new WebSocketServer({ port: 8980 });
wss.on("connection", function connection(ws) {
ws.on("message", function message(data) {
parentPort.postMessage({ message: data });
try {
var { WebSocketServer } = require("ws");
const wss = new WebSocketServer({ port: 8980 });
wss.on("connection", function connection(ws) {
ws.on("message", function message(data) {
parentPort.postMessage({ message: data });
});
parentPort.on("message", (data) => {
ws.send(data);
});
});
parentPort.on("message", (data) => {
ws.send(data);
});
});
} catch (_) {}
Binary file added bun.lockb
Binary file not shown.
35 changes: 15 additions & 20 deletions examples/play_stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,29 +352,24 @@ function ondeviceup(name, host, port, addresses, text, airplay2 = null, devicety
}

function getIp() {
try {
let ip = "";
let ip2 = [];
let alias = 0;
const ifaces = os.networkInterfaces();
for (let dev in ifaces) {
ifaces[dev].forEach((details) => {
if (details.family === "IPv4" && !details.internal) {
if (!/(loopback|vmware|internal|hamachi|vboxnet|virtualbox)/gi.test(dev + (alias ? ":" + alias : ""))) {
if (details.address.substring(0, 8) === "192.168." || details.address.substring(0, 7) === "172.16." || details.address.substring(0, 3) === "10.") {
if (!ip.startsWith("192.168.") || (ip2.startsWith("192.168.") && !ip.startsWith("192.168.") && ip2.startsWith("172.16.") && !ip.startsWith("192.168.") && !ip.startsWith("172.16.")) || (ip2.startsWith("10.") && !ip.startsWith("192.168.") && !ip.startsWith("172.16.") && !ip.startsWith("10."))) {
ip = details.address;
}
++alias;
let ip = "";
let ip2 = [];
let alias = 0;
const ifaces= os.networkInterfaces();
for (let dev in ifaces) {
ifaces[dev].forEach((details) => {
if (details.family === "IPv4" && !details.internal) {
if (!/(loopback|vmware|internal|hamachi|vboxnet|virtualbox)/gi.test(dev + (alias ? ":" + alias : ""))) {
if (details.address.substring(0, 8) === "192.168." || details.address.substring(0, 7) === "172.16." || details.address.substring(0, 3) === "10.") {
if (!ip.startsWith("192.168.") || (ip2.startsWith("192.168.") && !ip.startsWith("192.168.") && ip2.startsWith("172.16.") && !ip.startsWith("192.168.") && !ip.startsWith("172.16.")) || (ip2.startsWith("10.") && !ip.startsWith("192.168.") && !ip.startsWith("172.16.") && !ip.startsWith("10."))) {
ip = details.address;
}
++alias;
}
}
});
}
return ip;
} catch (_) {
return ip.address();
}
});
}
return ip;
}


Loading

0 comments on commit eb3ab51

Please sign in to comment.