Skip to content

Commit

Permalink
Move to netmask package instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbithell committed Feb 27, 2024
1 parent ae2291b commit ccaeb63
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 195 deletions.
42 changes: 0 additions & 42 deletions client/src/Devices/Scan/DiscoveredDeviceCard.tsx

This file was deleted.

89 changes: 0 additions & 89 deletions client/src/Devices/Scan/ScanModal.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/Operate/Operate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DeviceChannelDisplay = (props: { device: Device, status: number | false, d
return (
<Card>
<Text fw={500} ta="center" mb="md">
{props.device.name} {props.device.ip}
{props.device.name}
</Text>
{props.status === false ? (
<Alert variant="transparent" title="Device Disconnected" icon={<IconPlugConnectedX />} mb="md">
Expand Down
80 changes: 20 additions & 60 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"@types/cors": "^2.8.17",
"@types/ip": "^1.1.3",
"@types/node-osc": "^6.0.3",
"@types/netmask": "^2.0.5",
"better-sqlite3": "^9.4.1",
"cors": "^2.8.5",
"drizzle-orm": "^0.29.3",
"electron-squirrel-startup": "^1.0.0",
"get-ip-range": "^4.0.1",
"netmask": "^2.0.2",
"ip": "^2.0.1",
"node-osc": "^9.1.0",
"portfinder": "^1.0.32",
Expand Down
8 changes: 6 additions & 2 deletions server/src/utils/scanForDevices.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import ip from "ip";
import { getIPRange } from "get-ip-range";
import { Netmask } from "netmask";

export const scanForDevices = () => {
const thisIp = ip.address();
const ips = getIPRange(thisIp + "/24");
if (!thisIp || thisIp === null)
throw new Error("Unable to get the local IP address");
const ips: string[] = [];
const block = new Netmask(thisIp, "255.255.255.0");
block.forEach((ip: string) => ips.push(ip));
console.log("Scanning for devices on the network");
return Promise.allSettled(
ips.map((ip) => {
Expand Down

0 comments on commit ccaeb63

Please sign in to comment.