Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
{
"files": {
"ignore": [
"ui/node_modules/**/*",
"ui/vendor/**/*",
"ui/dist/**/*",
"config.json",
"gsm_operator_cache.json"
"includes": [
"./package.json",
"**/server/**/*",
"**/ui/**/*",
"**/*.json",
"!**/ui/node_modules/**/*",
"!**/ui/vendor/**/*",
"!**/ui/dist/**/*",
"!**/config.json",
"!**/gsm_operator_cache.json"
],
"include": ["server/**/*", "ui/**/*", "*.json"],
"ignoreUnknown": true
},
"linter": {
"rules": {
"style": {
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
}
}
}
}
Binary file modified bun.lockb
Binary file not shown.
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "@belaui/root",
"type": "module",
"workspaces": ["server", "ui"],
"workspaces": [
"server",
"ui"
],
"dependencies": {},
"devDependencies": {
"@types/bun": "^1.2.4",
Expand All @@ -11,7 +14,7 @@
},
"scripts": {
"check": "bun run --bun --filter '*' check && run-p check:*",
"check:biome": "bun x --bun @biomejs/biome check",
"check:biome": "bun x --bun @biomejs/biome check .",
"dev": "bun run --bun --filter '*' dev",
"fix": "bun run --bun --filter '*' fix",
"lint": "bun run --bun --filter '*' lint",
Expand All @@ -20,5 +23,8 @@
"build:copy-ui": "mkdir -p ./dist/public && rm -rf ./dist/public/* && cp -r ./ui/dist/* ./dist/public/",
"build:copy-server": "mkdir -p ./dist && cp ./server/belaUI ./dist/"
},
"trustedDependencies": ["@biomejs/biome", "esbuild"]
"trustedDependencies": [
"@biomejs/biome",
"esbuild"
]
}
4 changes: 2 additions & 2 deletions server/helpers/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function execPNR(cmd: string) {
try {
const res = await execP(cmd);
return { stdout: res.stdout, stderr: res.stderr, code: 0 };
} catch (err) {
} catch (_err) {
return { stdout: "", stderr: "", code: 1 };
}
}
Expand All @@ -21,7 +21,7 @@ export function checkExecPathSafe(path: string) {
try {
fs.accessSync(path, fs.constants.R_OK);
return true;
} catch (err) {
} catch (_err) {
logger.error(
`\n\n${path} not found, double check the settings in setup.json`,
);
Expand Down
2 changes: 1 addition & 1 deletion server/modules/ingest/srt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function runSLT() {
try {
const stats = JSON.parse(data.toString("utf8"));
ingestStats = `${Math.round(stats.recv.mbitRate * 1024)} Kbps, ${Math.round(stats.link.rtt)} ms RTT`;
} catch (err) {}
} catch (_err) {}
});

proc.stderr.on("data", (data) => {
Expand Down
2 changes: 1 addition & 1 deletion server/modules/modems/modem-network-scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { broadcastMsg } from "../ui/websocket-server.ts";
import { mmNetworkScan } from "./mmcli.ts";
import {
type AvailableNetwork,
type Modem,
getAvailableNetworksForModem,
getModem,
getModemIds,
type Modem,
} from "./modems-state.ts";

function modemBuildAvailableNetworksMessage(id: number) {
Expand Down
4 changes: 2 additions & 2 deletions server/modules/modems/modem-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { broadcastMsg } from "../ui/websocket-server.ts";
import type { ModemId } from "./mmcli.ts";
import {
type AvailableNetwork,
type Modem,
type ModemConfig,
getAvailableNetworksForModem,
getModem,
getModemIds,
type Modem,
type ModemConfig,
} from "./modems-state.ts";

type ModemsResponseModemStatus = {
Expand Down
8 changes: 4 additions & 4 deletions server/modules/modems/modem-update-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
type NetworkManagerConnection,
type NetworkManagerConnectionModemConfig,
nmConnAdd,
nmConnGetFields,
nmConnect,
nmConnGetFields,
} from "../network/network-manager.ts";

import { setup } from "../setup.ts";
Expand All @@ -32,20 +32,20 @@ import { getGsmConnections, resetGsmConnections } from "./gsm-connections.ts";
import {
type ModemId,
type ModemInfo,
type SimInfo,
mmConvertAccessTech,
mmConvertNetworkType,
mmConvertNetworkTypes,
mmGetModem,
mmGetSim,
mmList,
type SimInfo,
} from "./mmcli.ts";
import { broadcastModems } from "./modem-status.ts";
import {
type Modem,
type ModemConfig,
getModem,
getModems,
type Modem,
type ModemConfig,
removeModem,
setModem,
} from "./modems-state.ts";
Expand Down
9 changes: 6 additions & 3 deletions server/modules/modems/modems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { mmSetNetworkTypes } from "./mmcli.ts";
import { modemNetworkScan } from "./modem-network-scan.ts";
import { broadcastModems } from "./modem-status.ts";
import { sanitizeModemConfigForNetworkManager } from "./modem-update-loop.ts";
import { type ModemConfig, getModem } from "./modems-state.ts";
import { getModem, type ModemConfig } from "./modems-state.ts";

type ModemConfigMessage = {
config: {
Expand Down Expand Up @@ -71,7 +71,7 @@ async function updateModemConnection(
}

async function handleModemConfig(
conn: WebSocket,
_conn: WebSocket,
msg: ModemConfigMessage["config"],
) {
if (!msg.device) {
Expand Down Expand Up @@ -186,7 +186,10 @@ async function handleModemConfig(
broadcastModems({ [msg.device]: true });
}

async function handleModemScan(conn: WebSocket, msg: ModemScanMessage["scan"]) {
async function handleModemScan(
_conn: WebSocket,
msg: ModemScanMessage["scan"],
) {
const modemId = Number.parseInt(msg.device, 10);
if (!msg || !getModem(modemId)) return;

Expand Down
2 changes: 1 addition & 1 deletion server/modules/network/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ let dnsCache: Record<string, DnsCacheEntry> = {};
const dnsResults: Record<string, ResolveResult> = {};
try {
dnsCache = JSON.parse(fs.readFileSync(DNS_CACHE_FILE, "utf8"));
} catch (err) {
} catch (_err) {
logger.warn(
"Failed to load the persistent DNS cache, starting with an empty cache",
);
Expand Down
5 changes: 2 additions & 3 deletions server/modules/network/gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*/

import { execP } from "../../helpers/exec.ts";
import { getms } from "../../helpers/time.ts";

import { logger } from "../../helpers/logger.ts";
import { getms } from "../../helpers/time.ts";
import {
notificationBroadcast,
notificationRemove,
Expand All @@ -41,7 +40,7 @@ async function clear_default_gws() {
while (true) {
await execP("ip route del default");
}
} catch (err) {
} catch (_err) {
return;
}
}
Expand Down
7 changes: 2 additions & 5 deletions server/modules/network/network-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@

/* Network interface list */
import { exec } from "node:child_process";

import { EventEmitter } from "node:events";
import type WebSocket from "ws";

import { getms } from "../../helpers/time.ts";

import { logger } from "../../helpers/logger.ts";
import { ACTIVE_TO } from "../../helpers/shared.ts";

import { EventEmitter } from "node:events";
import { getms } from "../../helpers/time.ts";
import {
notificationBroadcast,
notificationRemove,
Expand Down
6 changes: 3 additions & 3 deletions server/modules/remote/remote-relays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ try {
relaysCache = JSON.parse(
fs.readFileSync(RELAYS_CACHE_FILE, "utf8"),
) as RelayCache;
} catch (err) {
} catch (_err) {
logger.warn("Failed to load the relays cache, starting with an empty cache");
}

Expand Down Expand Up @@ -135,7 +135,7 @@ export function buildRelaysMsg() {
export async function updateCachedRelays(relays: RelayCache | undefined) {
try {
assert.deepStrictEqual(relays, relaysCache);
} catch (err) {
} catch (_err) {
logger.debug("updated the relays cache", relays);
relaysCache = relays;
await writeTextFile(RELAYS_CACHE_FILE, JSON.stringify(relays));
Expand Down Expand Up @@ -182,7 +182,7 @@ function validateRemoteRelays(msg: ValidateRemoteRelaysMessage["relays"]) {
if (Object.keys(out.servers).length < 1) return;

return out;
} catch (err) {
} catch (_err) {
return undefined;
}
}
Expand Down
9 changes: 5 additions & 4 deletions server/modules/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ import {
broadcastMsgLocal,
deleteSocketSenderId,
getLastActive,
handleMessage,
type Message,
markConnectionActive,
setSocketSenderId,
} from "../ui/websocket-server.ts";
import { type Message, handleMessage } from "../ui/websocket-server.ts";

import {
type ValidateRemoteRelaysMessage,
buildRelaysMsg,
handleRemoteRelays,
updateCachedRelays,
type ValidateRemoteRelaysMessage,
} from "./remote-relays.ts";

type RemoteAuthEncoderMessage = {
Expand All @@ -78,7 +79,7 @@ const remoteEndpointPath = setup.remote_endpoint_path ?? "/ws/remote";
const remoteTimeout = 5000;
const remoteConnectTimeout = 10000;

let remoteWs: WebSocket | undefined = undefined;
let remoteWs: WebSocket | undefined;
let remoteStatusHandled = false;

export function getRemoteWebSocket() {
Expand Down Expand Up @@ -194,7 +195,7 @@ async function remoteConnect() {
queueUpdateGw();
logger.warn(`remote: DNS lookup failed, using cached address ${host}`);
}
} catch (err) {
} catch (_err) {
return remoteRetry();
}

Expand Down
1 change: 0 additions & 1 deletion server/modules/streaming/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { setup } from "../setup.ts";
import { notificationBroadcast } from "../ui/notifications.ts";
import { broadcastMsg } from "../ui/websocket-server.ts";

import { resolveSrtla } from "./srtla.ts";
import { startError } from "./streaming.ts";

const deviceDir = setup.sound_device_dir ?? "/sys/class/sound";
Expand Down
2 changes: 1 addition & 1 deletion server/modules/streaming/camlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function checkCamlinkUsb2() {
if (!version.match("3.00")) {
foundUsb2 = true;
}
} catch (err) {}
} catch (_err) {}
}

if (foundUsb2) {
Expand Down
2 changes: 1 addition & 1 deletion server/modules/streaming/srtla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function resolveSrtla(addr: string, conn: WebSocket) {
const res = await dnsCacheResolve(addr, "a");
addrs = res.addrs;
fromCache = res.fromCache;
} catch (err) {
} catch (_err) {
const senderId = getSocketSenderId(conn) ?? "unknown sender";
startError(conn, `failed to resolve SRTLA addr ${addr}`, senderId);
queueUpdateGw();
Expand Down
11 changes: 5 additions & 6 deletions server/modules/streaming/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import type WebSocket from "ws";
import { validateInteger, validatePortNo } from "../../helpers/number.ts";

import { getConfig, saveConfig } from "../config.ts";
import {
convertManualToRemoteRelay,
getRelays,
} from "../remote/remote-relays.ts";
import { notificationSend } from "../ui/notifications.ts";
import type { StatusResponseMessage } from "../ui/status.ts";
import {
Expand All @@ -30,17 +34,12 @@ import {
getSocketSenderId,
setSocketSenderId,
} from "../ui/websocket-server.ts";

import {
convertManualToRemoteRelay,
getRelays,
} from "../remote/remote-relays.ts";
import {
DEFAULT_AUDIO_ID,
abortAsrcRetry,
asrcProbe,
asrcScheduleRetry,
audioCodecs,
DEFAULT_AUDIO_ID,
getAudioDevices,
isAsrcRetryScheduled,
pipelineSetAsrc,
Expand Down
6 changes: 3 additions & 3 deletions server/modules/system/revisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const revisions: Record<string, string> = {};
function readRevision(cmd: string) {
try {
return execSync(cmd).toString().trim();
} catch (err) {
} catch (_err) {
return "unknown revision";
}
}

export function initRevisions() {
try {
revisions.belaUI = fs.readFileSync("revision", "utf8");
} catch (err) {
} catch (_err) {
revisions.belaUI = readRevision("git rev-parse --short HEAD");
}

Expand All @@ -51,7 +51,7 @@ export function initRevisions() {
revisions["BELABOX image"] = fs
.readFileSync("/etc/belabox_img_version", "utf8")
.trim();
} catch (err) {}
} catch (_err) {}
logger.debug("Revisions", revisions);
}

Expand Down
Loading