diff --git a/.gitignore b/.gitignore index 7a1537b..a8dce37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .idea -node_modules +client/node_modules diff --git a/client/package-lock.json b/client/package-lock.json new file mode 100644 index 0000000..a77e10e --- /dev/null +++ b/client/package-lock.json @@ -0,0 +1,1170 @@ +{ + "name": "dashboard", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "dashboard", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "dotenv": "^17.4.1", + "express": "^5.2.1", + "node-gpsd": "^0.3.4" + }, + "devDependencies": { + "nodemon": "^3.1.10" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dotenv": { + "version": "17.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.1.tgz", + "integrity": "sha512-k8DaKGP6r1G30Lx8V4+pCsLzKr8vLmV2paqEj1Y55GdAgJuIqpRp5FfajGF8KtwMxCz9qJc6wUIJnm053d/WCw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-gpsd": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/node-gpsd/-/node-gpsd-0.3.4.tgz", + "integrity": "sha512-sI9hPfHiaWDmhjE1oJZnhMo7UF2vQVGl3qk0K4HbN1L8BkS0I+rd6V687eHOj/6ervXiHrhwXzYYsWdXxGy0Qg==", + "engines": { + "node": ">=v0.8.0" + } + }, + "node_modules/nodemon": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", + "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, + "node_modules/qs": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz", + "integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/code/package.json b/client/package.json old mode 100755 new mode 100644 similarity index 87% rename from code/package.json rename to client/package.json index 6b47216..0b00fba --- a/code/package.json +++ b/client/package.json @@ -11,6 +11,8 @@ "license": "MIT", "description": "Dashboard", "dependencies": { + "dotenv": "^17.4.1", + "express": "^5.2.1", "node-gpsd": "^0.3.4" }, "devDependencies": { diff --git a/client/public/code-book-print.html b/client/public/code-book-print.html new file mode 100644 index 0000000..aa45674 --- /dev/null +++ b/client/public/code-book-print.html @@ -0,0 +1,284 @@ + + + + Code Book + + + + + +
+
+

Encryption Key

+ +
+ +

ASCII Reference Table

+
+
+ + +
+

ONE-TIME PASSWORDS (HOTP)

+
+
+ + +
+

AUTHENTICATION TABLES

+
+
+ + +
+

ONE-TIME PAD

+
+
+ + + + + + diff --git a/client/public/code-book.html b/client/public/code-book.html new file mode 100644 index 0000000..3f7a99b --- /dev/null +++ b/client/public/code-book.html @@ -0,0 +1,669 @@ + + + + Code Book + + + + + + + +
+
+
+ Logo + +
+
+
+ +
+
+
+ +
+ + + +
+
+
+ + +
+
One Time Password (HOTP)
+
+ Description + +
+

Use a 3-digit challenge to generate & verify a corresponding 3-letter response.

+

Provides higher entropy and security than authentication tables while being easier to use.

+ +
+ Pre-Authenticate: +
+

A->B: AUTH 123 ABC

+

B->A: ACK. AUTH 456 DEF

+
+
+ +
+ Challenge-Response: +
+

A->B: CONFIRM 123

+

B->A: ACK ABC. CONFIRM 456

+

A->B: ACK DEF

+
+
+
+
+
+ + +
---
+
+
+ + +
+
Authentication Tables
+
+ Description + +
+

Challenge-response tables for authentication.

+ +
+ Example: +
+

A->B: CONFIRM CEY (Table: Charlie, Column: E, Row: Y)

+

B->A: ACK 7. CONFIRM AIT (Table: Alpha, Column: I, Row: T)

+

A->B: ACK T

+
+
+
+
+
+ + +
+
+
+ + +
+
One-Time Pad
+
+ Description + +
+

Use a 5-digit key to generate a corresponding fixed (paper friendly) or streamed (more secure) cipher.

+

Cipher values are added to the ASCII encoded message to create encrypted message.

+ +
+ Encoding: +
+ Message: "HI"
+ Pad Key: 12345
+ Cipher: 42 85 28 71 14 ...

+ + H = ASCII 72 → 72 + 42 = 114 → Hex 72
+ I = ASCII 73 → 73 + 85 = 158 → Hex 9E

+ + Encoded: 729E +
+
+ +
+ Decoding: +
+ Encoded: 729E
+ Pad Key: 12345
+ Cipher: 42 85 28 71 14 ...

+ + 72 (Hex) = 114 → 114 - 42 = 72 → ASCII 'H'
+ 9E (Hex) = 158 → 158 - 85 = 73 → ASCII 'I'

+ + Decoded: "HI" +
+
+
+
+
+
+ + +
+ + +
+
+
+
+
+
+ +
+ + +
+ +
+
+ + +
+
ASCII Reference Table
+
+
+
+ + + + + + diff --git a/code/public/downloads/ATAK_5.4.0.16.apk b/client/public/downloads/ATAK_5.4.0.16.apk old mode 100755 new mode 100644 similarity index 100% rename from code/public/downloads/ATAK_5.4.0.16.apk rename to client/public/downloads/ATAK_5.4.0.16.apk diff --git a/code/public/downloads/Element.apk b/client/public/downloads/Element.apk old mode 100755 new mode 100644 similarity index 100% rename from code/public/downloads/Element.apk rename to client/public/downloads/Element.apk diff --git a/code/public/downloads/Meshtastic_2.7.1.apk b/client/public/downloads/Meshtastic_2.7.1.apk old mode 100755 new mode 100644 similarity index 100% rename from code/public/downloads/Meshtastic_2.7.1.apk rename to client/public/downloads/Meshtastic_2.7.1.apk diff --git a/code/public/downloads/Remote Desktop 8_8.1.82.445.apk b/client/public/downloads/Remote Desktop 8_8.1.82.445.apk old mode 100755 new mode 100644 similarity index 100% rename from code/public/downloads/Remote Desktop 8_8.1.82.445.apk rename to client/public/downloads/Remote Desktop 8_8.1.82.445.apk diff --git a/code/public/downloads/SDRangel_7.21.3.1.apk b/client/public/downloads/SDRangel_7.21.3.1.apk old mode 100755 new mode 100644 similarity index 100% rename from code/public/downloads/SDRangel_7.21.3.1.apk rename to client/public/downloads/SDRangel_7.21.3.1.apk diff --git a/client/public/encryption.js b/client/public/encryption.js new file mode 100644 index 0000000..288eec1 --- /dev/null +++ b/client/public/encryption.js @@ -0,0 +1,113 @@ +// encryption.js + +// Phonetic alphabet for table names +const PHONETIC = ['Alpha', 'Bravo', 'Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf', 'Hotel', + 'India', 'Juliet', 'Kilo', 'Lima', 'Mike', 'November', 'Oscar', 'Papa', + 'Quebec', 'Romeo', 'Sierra', 'Tango', 'Uniform', 'Victor', 'Whiskey', + 'Xray', 'Yankee', 'Zulu']; + +const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; +const LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +// Seeded RNG using SHA256 +class SeededRandom { + constructor(seed) { + this.seed = seed; + this.counter = 0; + } + + next() { + const hash = CryptoJS.SHA256(this.seed + ':' + this.counter); + this.counter++; + const hex = hash.toString(CryptoJS.enc.Hex); + return parseInt(hex.substring(0, 8), 16) / 0xFFFFFFFF; + } + + nextInt(min, max) { + return Math.floor(this.next() * (max - min)) + min; + } + + choice(arr) { + return arr[this.nextInt(0, arr.length)]; + } +} + +// HOTP Generation - 3 digit nonce -> 3 letter code +function generateHOTP(secret, nonce) { + const rng = new SeededRandom(secret + ':hotp:' + nonce); + let code = ''; + for (let i = 0; i < 3; i++) { + code += rng.choice(LETTERS.split('')); + } + return code; +} + +// Auth Tables +function generateAuthTable(seed, tableIndex) { + const rng = new SeededRandom(seed + ':table:' + tableIndex); + const rows = 'NOPQRSTUVWXYZ'.split(''); + const cols = 'ABCDEFGHIJKLM'.split(''); + + const table = []; + for (let row of rows) { + const rowData = []; + for (let col of cols) { + rowData.push(rng.choice(CHARS.split(''))); + } + table.push(rowData); + } + + return table; +} + +// One-Time Pad (for encode/decode) +function generatePad(seed, padKey, length = 60) { + const rng = new SeededRandom(seed + ':pad:' + padKey); + const pad = []; + for (let i = 0; i < length; i++) { + pad.push(rng.nextInt(0, 256)); + } + return pad; +} + +function generatePadDisplay(seed, padKey) { + const rng = new SeededRandom(seed + ':pad:' + padKey); + const groups = []; + for (let i = 0; i < 12; i++) { + const num = rng.nextInt(0, 100000).toString().padStart(5, '0'); + groups.push(num); + } + return groups.join(' '); +} + +function encodeMessage(message, key, padKey, useStream = true) { + const messageBytes = new TextEncoder().encode(message); + const padLength = useStream ? messageBytes.length : 60; + const pad = generatePad(key, padKey, padLength); + + const encoded = []; + for (let i = 0; i < messageBytes.length; i++) { + const padByte = pad[i % pad.length]; + encoded.push(messageBytes[i] ^ padByte); + } + + return Array.from(encoded).map(b => b.toString(16).padStart(2, '0')).join(''); +} + +function decodeMessage(encoded, key, padKey, useStream = true) { + const bytes = []; + for (let i = 0; i < encoded.length; i += 2) { + bytes.push(parseInt(encoded.substr(i, 2), 16)); + } + + const padLength = useStream ? bytes.length : 60; + const pad = generatePad(key, padKey, padLength); + + const decoded = []; + for (let i = 0; i < bytes.length; i++) { + const padByte = pad[i % pad.length]; + decoded.push(bytes[i] ^ padByte); + } + + return new TextDecoder().decode(new Uint8Array(decoded)); +} diff --git a/code/public/favicon.png b/client/public/favicon.png old mode 100755 new mode 100644 similarity index 100% rename from code/public/favicon.png rename to client/public/favicon.png diff --git a/client/public/icons/cog.svg b/client/public/icons/cog.svg new file mode 100644 index 0000000..d8bf436 --- /dev/null +++ b/client/public/icons/cog.svg @@ -0,0 +1 @@ + diff --git a/client/public/icons/download.svg b/client/public/icons/download.svg new file mode 100644 index 0000000..7077ced --- /dev/null +++ b/client/public/icons/download.svg @@ -0,0 +1 @@ + diff --git a/client/public/icons/guage.svg b/client/public/icons/guage.svg new file mode 100644 index 0000000..9137cff --- /dev/null +++ b/client/public/icons/guage.svg @@ -0,0 +1 @@ + diff --git a/client/public/icons/open-sight.png b/client/public/icons/open-sight.png new file mode 100644 index 0000000..63671a7 Binary files /dev/null and b/client/public/icons/open-sight.png differ diff --git a/code/public/index.html b/client/public/index.html old mode 100755 new mode 100644 similarity index 87% rename from code/public/index.html rename to client/public/index.html index 31ee457..d2bfdac --- a/code/public/index.html +++ b/client/public/index.html @@ -1,953 +1,926 @@ - - - - MRS Dashboard - - - - - - - -
-
-
- Logo -
- -
Hostname
-
-
-
-
-
-
Local
-
00:00:00
-
Jan 1, 2025
-
-
-
Zulu / UTC
-
00:00:00
-
Jan 1, 2025
-
-
-
-
-
-
- - - - - - - - - - - - - - - -
-
- - - - - -
-
- - - - - - - - - - - - - - - - -
-
- - - - - - -
-
- - - - -
-
- - - -
-
-
-
- -
-
-
-
- - - - - - - - -
System ?°C
-
-
-
-
CPU - Load
-
-
-
0%
-
-
-
-
Memory
-
-
-
0%
-
-
-
-
Disk
-
-
-
0%
-
-
-
-
- -
-
- - - - - - - - - - - - - - - -
GPS
-
-
-
39.2000, -49.0000
-
No Fix
-
-
- -
-
- - - - - -
LoRa
-
-
-
0 / 0 Online
-
Ch 0% Air 0%
-
-
- -
-
- - - - - - - - - - - - - - - - -
Mesh
-
-
-
Connected
-
900 Mhz -45 dBm
-
-
- -
-
- - - - - - -
WiFi
-
-
-
Access Point
-
SSID: Hostname
-
-
- -
-
- - - - -
Ethernet
-
-
-
Disconnected
-
No cable detected
-
-
- -
-
-
- -
- - -
- -
- - - - - - - - - -
-
AI Assistant
-
- - -
- - - -
- - - - - - -
-
-
ATAK
-
- - -
- - - - - -
- - - - - - -
-
-
Desktop
-
- - -
- - - -
-
File Browser
-
- - -
- - - - -
- - - - - - - - - - - -
-
-
Library
-
- - -
- - - - - -
-
Maps
-
- - -
- - - - - -
- - - - - - -
-
-
Meshtastic
-
- - -
- - - -
- - - - - - -
-
-
Messages
-
- - -
- - - - -
-
Pentesting
-
- - -
- - - - - - - - - - -
- - - - - - -
-
-
SDR
-
- - -
- - - - -
-
Situation Room
-
- - -
- - - -
-
Speed Test
-
-
-
- - - - + + + + MRS Dashboard + + + + + + + +
+
+
+ Logo +
+ +
Hostname
+
+
+
+
+
+
Local
+
00:00:00
+
Jan 1, 2025
+
+
+
Zulu / UTC
+
00:00:00
+
Jan 1, 2025
+
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+
+ + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
+ + + + +
+
+ + + +
+
+
+
+ +
+
+
+
+ + + + + + + + +
System ?°C
+
+
+
+
CPU - Load
+
+
+
0%
+
+
+
+
Memory
+
+
+
0%
+
+
+
+
Disk
+
+
+
0%
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + +
GPS
+
+
+
39.2000, -49.0000
+
No Fix
+
+
+ +
+
+ + + + + +
LoRa
+
+
+
0 / 0 Online
+
Ch 0% Air 0%
+
+
+ +
+
+ + + + + + + + + + + + + + + + +
Mesh
+
+
+
Connected
+
900 Mhz -45 dBm
+
+
+ +
+
+ + + + + + +
WiFi
+
+
+
Access Point
+
SSID: Hostname
+
+
+ +
+
+ + + + +
Ethernet
+
+
+
Disconnected
+
No cable detected
+
+
+ +
+
+
+ +
+ + +
+ +
+ + + + + + + + + +
+
AI Assistant
+
+ + +
+ + + +
+ Download +
+
+
ATAK
+
+ + +
+ + + + +
+ Download +
+
+
Code Book
+
+ + +
+ + + + + +
+ Download +
+
+
Desktop
+
+ + +
+ + + +
+
File Browser
+
+ + +
+ + + + +
+ Download +
+
+
Library
+
+ + +
+ + + + + +
+
Maps
+
+ + +
+ + + + + +
+ Download +
+
+
Meshtastic
+
+ + +
+ + + +
+ Download +
+
+
Messages
+
+ + +
+ +
+
Pentesting
+
+ + +
+ + + + + + + + + + +
+ Download +
+
+
SDR
+
+ + +
+ OpenSight +
+
Intelligence
+
+ + +
+ +
+
Speed Test
+
+
+
+ + + + diff --git a/code/public/index.js b/client/public/index.js old mode 100755 new mode 100644 similarity index 97% rename from code/public/index.js rename to client/public/index.js index d07c59d..949deb0 --- a/code/public/index.js +++ b/client/public/index.js @@ -1,368 +1,374 @@ - -class Dashboard { - constructor() { - this.statusCache = null; - this.lastFetch = 0; - this.hostname = 'localhost'; - this.serverTimeOffset = null; // Track difference between server and client time - this.isTimeServerSynced = false; // Track if we're using server time - this.init(); - } - - async init() { - await this.fetchHostname(); - this.updateHostname(); - this.startTimeUpdates(); // Start with client time immediately - this.startStatusUpdates(); - this.initializeEventListeners(); - } - - async fetchHostname() { - try { - const response = await fetch('/api/hostname'); - const data = await response.json(); - this.hostname = data.hostname.toLowerCase(); - } catch (error) { - console.warn('Failed to fetch hostname:', error); - } - } - - updateHostname() { - const hostnameElement = document.querySelector('.hostname'); - if (hostnameElement) { - hostnameElement.textContent = this.hostname; - } - } - - async fetchStatus() { - try { - // Record start time for latency calculation - const requestStart = performance.now(); - const response = await fetch('/api/status'); - const requestEnd = performance.now(); - - if (!response.ok) throw new Error('Status fetch failed'); - - const status = await response.json(); - this.statusCache = status; - this.updateUI(status, requestStart, requestEnd); - } catch (error) { - console.error('Failed to fetch status:', error); - this.showOfflineStatus(); - } - } - - updateUI(status, requestStart, requestEnd) { - this.updateSystemMetrics(status.system); - this.updateGPSStatus(status.gps); - this.updateNetworkStatus(status.network); - this.updateLoRaStatus(status.lora); - this.updateTimeSync(status.time, requestStart, requestEnd); - } - - updateSystemMetrics(system) { - // Update temperature - const tempElement = document.getElementById('temp'); - if (tempElement && system.temperature) { - tempElement.textContent = `${system.temperature}°C`; - } - - // Update load average - const loadElement = document.getElementById('load'); - if (loadElement && system.load !== undefined) { - loadElement.textContent = `${system.load.toFixed(1)} Load`; - } - - // Update progress bars - this.updateProgressBar('cpu-usage', system.cpu); - this.updateProgressBar('memory-usage', system.memory); - this.updateProgressBar('disk-usage', system.storage); - } - - updateProgressBar(id, percentage) { - const fillElement = document.getElementById(`${id}-fill`); - const textElement = document.getElementById(`${id}-text`); - - if (fillElement && textElement) { - const value = Math.round(percentage); - fillElement.style.width = `${value}%`; - textElement.textContent = `${value}%`; - - // Update color based on usage - if (value > 80) { - fillElement.style.background = '#ef4444'; // Red - } else if (value > 60) { - fillElement.style.background = '#f59e0b'; // Orange - } else { - fillElement.style.background = '#10b981'; // Green - } - } - } - - updateGPSStatus(gps) { - const gpsStatus = document.getElementById('gps-status'); - const gpsTile = document.getElementById('gps-tile'); - - if (gpsStatus && gpsTile) { - const hasValidFix = gps.fix !== 'No Fix' && gps.latitude !== null; - - // Update status indicator - if (hasValidFix) { - gpsStatus.classList.remove('disconnected'); - gpsStatus.classList.add('connected'); - gpsTile.classList.remove('disconnected'); - gpsTile.classList.add('connected'); - } else { - gpsStatus.classList.remove('connected'); - gpsStatus.classList.add('disconnected'); - gpsTile.classList.remove('connected'); - gpsTile.classList.add('disconnected'); - } - - // Update GPS tile info - const gpsInfo = gpsTile.querySelector('.tile-info'); - const gpsDetail = gpsTile.querySelector('.tile-detail'); - - if (gpsInfo && gpsDetail) { - if (hasValidFix) { - gpsInfo.textContent = `${gps.latitude.toFixed(4)}, ${gps.longitude.toFixed(4)}`; - gpsDetail.textContent = `${gps.fix} • ${gps.satellites} sats • Alt: ${Math.round(gps.altitude)}m`; - } else { - gpsInfo.textContent = gps.satellites > 0 ? 'Acquiring Fix...' : 'No Signal'; - gpsDetail.textContent = `${gps.satellites} satellites`; - } - } - } - } - - updateNetworkStatus(network) { - // Update WiFi status - const wifiTile = document.getElementById('wifi-tile'); - if (wifiTile) { - const wifiInfo = wifiTile.querySelector('.tile-info'); - const wifiDetail = wifiTile.querySelector('.tile-detail'); - - if (wifiInfo && wifiDetail) { - if (network.wifi.mode === 'ap') { - wifiInfo.textContent = 'Access Point'; - wifiDetail.textContent = `SSID: ${network.wifi.ssid}`; - } else { - wifiInfo.textContent = 'Client Mode'; - wifiDetail.textContent = `SSID: ${network.wifi.ssid}`; - } - } - } - - // Update Ethernet status - const ethernetStatus = document.getElementById('ethernet-status'); - const ethernetTile = document.getElementById('ethernet-tile'); - - if (ethernetStatus && ethernetTile) { - if (network.ethernet.connected) { - ethernetStatus.classList.remove('disconnected'); - ethernetStatus.classList.add('connected'); - ethernetTile.classList.remove('disconnected'); - ethernetTile.classList.add('connected'); - - const ethernetInfo = ethernetTile.querySelector('.tile-info'); - const ethernetDetail = ethernetTile.querySelector('.tile-detail'); - if (ethernetInfo && ethernetDetail) { - ethernetInfo.textContent = 'Connected'; - ethernetDetail.textContent = 'Link detected'; - } - } else { - ethernetStatus.classList.remove('connected'); - ethernetStatus.classList.add('disconnected'); - ethernetTile.classList.remove('connected'); - ethernetTile.classList.add('disconnected'); - - const ethernetInfo = ethernetTile.querySelector('.tile-info'); - const ethernetDetail = ethernetTile.querySelector('.tile-detail'); - if (ethernetInfo && ethernetDetail) { - ethernetInfo.textContent = 'Disconnected'; - ethernetDetail.textContent = 'No cable detected'; - } - } - } - } - - updateLoRaStatus(lora) { - const loraStatus = document.getElementById('lora-status'); - const loraTile = document.getElementById('lora-tile'); - - if (loraStatus && loraTile) { - if (lora.connected) { - loraStatus.classList.remove('disconnected'); - loraStatus.classList.add('connected'); - loraTile.classList.remove('disconnected'); - loraTile.classList.add('connected'); - - const loraInfo = loraTile.querySelector('.tile-info'); - const loraDetail = loraTile.querySelector('.tile-detail'); - - if (loraInfo && loraDetail) { - loraInfo.textContent = `${lora.onlineNodes}/${lora.totalNodes} Online`; - loraDetail.textContent = `CH: ${lora.channelUtilization.toFixed(1)}% • Air: ${lora.airtimeUtilization.toFixed(1)}%`; - } - } else { - loraStatus.classList.remove('connected'); - loraStatus.classList.add('disconnected'); - loraTile.classList.remove('connected'); - loraTile.classList.add('disconnected'); - - const loraInfo = loraTile.querySelector('.tile-info'); - const loraDetail = loraTile.querySelector('.tile-detail'); - - if (loraInfo && loraDetail) { - loraInfo.textContent = 'Disconnected'; - loraDetail.textContent = 'No device found'; - } - } - } - } - - updateTimeSync(serverTimeString, requestStart, requestEnd) { - if (serverTimeString && requestStart && requestEnd) { - // Calculate network latency (round-trip time / 2) - const networkLatency = (requestEnd - requestStart) / 2; - - // Parse server time and adjust for network latency - const serverTime = new Date(serverTimeString); - const adjustedServerTime = new Date(serverTime.getTime() + networkLatency); - - // Calculate the offset between adjusted server time and client time - const clientTime = new Date(); - this.serverTimeOffset = adjustedServerTime.getTime() - clientTime.getTime(); - this.isTimeServerSynced = true; - - console.log(`Time synchronized with server (latency: ${networkLatency.toFixed(1)}ms, offset: ${this.serverTimeOffset.toFixed(1)}ms)`); - } - - // Update time displays - this.updateCurrentTime(); - } - - updateCurrentTime() { - const now = new Date(); - let displayTime; - - if (this.isTimeServerSynced && this.serverTimeOffset !== null) { - // Use server-synchronized time - displayTime = new Date(now.getTime() + this.serverTimeOffset); - } else { - // Use client time (default) - displayTime = now; - } - - this.updateTimeDisplay('local', displayTime, false); - this.updateTimeDisplay('zulu', displayTime, true); - } - - updateTimeDisplay(type, date, isUtc) { - const timeElement = document.getElementById(`${type}-time`); - const dateElement = document.getElementById(`${type}-date`); - - if (timeElement && dateElement) { - const displayDate = isUtc ? new Date(date.getTime()) : date; - - const timeStr = isUtc ? - displayDate.toUTCString().split(' ')[4] : - displayDate.toLocaleTimeString(); - - const dateStr = isUtc ? - displayDate.toUTCString().split(' ').slice(0, 4).join(' ') : - displayDate.toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - year: 'numeric' - }); - - timeElement.textContent = timeStr; - dateElement.textContent = dateStr; - - // Color time orange when using client time, white when server-synced - if (this.isTimeServerSynced) { - timeElement.style.color = '#fff'; - dateElement.style.color = '#64748b'; - } else { - timeElement.style.color = '#f59e0b'; - dateElement.style.color = '#f59e0b'; - } - } - } - - showOfflineStatus() { - // Reset to client time and show orange color - this.serverTimeOffset = null; - this.isTimeServerSynced = false; - console.warn('System appears offline - falling back to client time'); - } - - startStatusUpdates() { - // Initial fetch - this.fetchStatus(); - - // Update every 60 seconds - setInterval(() => { - this.fetchStatus(); - }, 60000); - } - - startTimeUpdates() { - // Start immediately with client time - this.updateCurrentTime(); - - // Update time every second - setInterval(() => { - this.updateCurrentTime(); - }, 1000); - } - - initializeEventListeners() { - // Expand/collapse status - const expandToggle = document.getElementById('expand-toggle'); - const expandedStatus = document.getElementById('expanded-status'); - const expandIcon = document.getElementById('expand-icon'); - - if (expandToggle && expandedStatus && expandIcon) { - expandToggle.addEventListener('click', () => { - expandedStatus.classList.toggle('visible'); - expandIcon.classList.toggle('expanded'); - }); - } - - // Search functionality - const searchInput = document.getElementById('search-input'); - const appsGrid = document.getElementById('apps-grid'); - - if (searchInput && appsGrid) { - searchInput.addEventListener('input', (e) => { - const query = e.target.value.toLowerCase(); - const apps = appsGrid.querySelectorAll('.app-item'); - - apps.forEach(app => { - const name = app.getAttribute('data-name')?.toLowerCase() || ''; - app.style.display = name.includes(query) ? 'flex' : 'none'; - }); - }); - } - } -} - -function openKiwixm(event) { - event.stopPropagation(); - event.preventDefault(); - window.location.href = window.location.origin.replace(/:\d+/g, '') + ':1300/admin'; -} - -// Initialize dashboard when DOM is ready -document.addEventListener('DOMContentLoaded', () => { - new Dashboard(); - - document.querySelectorAll('.app-item[href^=":"]').forEach(link => { - const port = link.getAttribute('href').substring(1); // Remove the ':' - const url = new URL(location.origin); - url.port = port; - link.href = url.toString(); - }); -}); + +class Dashboard { + constructor() { + this.statusCache = null; + this.lastFetch = 0; + this.hostname = 'localhost'; + this.serverTimeOffset = null; // Track difference between server and client time + this.isTimeServerSynced = false; // Track if we're using server time + this.init(); + } + + async init() { + await this.fetchHostname(); + this.updateHostname(); + this.startTimeUpdates(); // Start with client time immediately + this.startStatusUpdates(); + this.initializeEventListeners(); + } + + async fetchHostname() { + try { + const response = await fetch('/api/hostname'); + const data = await response.json(); + this.hostname = data.hostname.toLowerCase(); + } catch (error) { + console.warn('Failed to fetch hostname:', error); + } + } + + updateHostname() { + const hostnameElement = document.querySelector('.hostname'); + if (hostnameElement) { + hostnameElement.textContent = this.hostname; + } + } + + async fetchStatus() { + try { + // Record start time for latency calculation + const requestStart = performance.now(); + const response = await fetch('/api/status'); + const requestEnd = performance.now(); + + if (!response.ok) throw new Error('Status fetch failed'); + + const status = await response.json(); + this.statusCache = status; + this.updateUI(status, requestStart, requestEnd); + } catch (error) { + console.error('Failed to fetch status:', error); + this.showOfflineStatus(); + } + } + + updateUI(status, requestStart, requestEnd) { + this.updateSystemMetrics(status.system); + this.updateGPSStatus(status.gps); + this.updateNetworkStatus(status.network); + this.updateLoRaStatus(status.lora); + this.updateTimeSync(status.time, requestStart, requestEnd); + } + + updateSystemMetrics(system) { + // Update temperature + const tempElement = document.getElementById('temp'); + if (tempElement && system.temperature) { + tempElement.textContent = `${system.temperature}°C`; + } + + // Update load average + const loadElement = document.getElementById('load'); + if (loadElement && system.load !== undefined) { + loadElement.textContent = `${system.load.toFixed(1)} Load`; + } + + // Update progress bars + this.updateProgressBar('cpu-usage', system.cpu); + this.updateProgressBar('memory-usage', system.memory); + this.updateProgressBar('disk-usage', system.storage); + } + + updateProgressBar(id, percentage) { + const fillElement = document.getElementById(`${id}-fill`); + const textElement = document.getElementById(`${id}-text`); + + if (fillElement && textElement) { + const value = Math.round(percentage); + fillElement.style.width = `${value}%`; + textElement.textContent = `${value}%`; + + // Update color based on usage + if (value > 80) { + fillElement.style.background = '#ef4444'; // Red + } else if (value > 60) { + fillElement.style.background = '#f59e0b'; // Orange + } else { + fillElement.style.background = '#10b981'; // Green + } + } + } + + updateGPSStatus(gps) { + const gpsStatus = document.getElementById('gps-status'); + const gpsTile = document.getElementById('gps-tile'); + + if (gpsStatus && gpsTile) { + const hasValidFix = gps.fix !== 'No Fix' && gps.latitude !== null; + + // Update status indicator + if (hasValidFix) { + gpsStatus.classList.remove('disconnected'); + gpsStatus.classList.add('connected'); + gpsTile.classList.remove('disconnected'); + gpsTile.classList.add('connected'); + } else { + gpsStatus.classList.remove('connected'); + gpsStatus.classList.add('disconnected'); + gpsTile.classList.remove('connected'); + gpsTile.classList.add('disconnected'); + } + + // Update GPS tile info + const gpsInfo = gpsTile.querySelector('.tile-info'); + const gpsDetail = gpsTile.querySelector('.tile-detail'); + + if (gpsInfo && gpsDetail) { + if (hasValidFix) { + gpsInfo.textContent = `${gps.latitude.toFixed(4)}, ${gps.longitude.toFixed(4)}`; + gpsDetail.textContent = `${gps.fix} • ${gps.satellites} sats • Alt: ${Math.round(gps.altitude)}m`; + } else { + gpsInfo.textContent = gps.satellites > 0 ? 'Acquiring Fix...' : 'No Signal'; + gpsDetail.textContent = `${gps.satellites} satellites`; + } + } + } + } + + updateNetworkStatus(network) { + // Update WiFi status + const wifiTile = document.getElementById('wifi-tile'); + if (wifiTile) { + const wifiInfo = wifiTile.querySelector('.tile-info'); + const wifiDetail = wifiTile.querySelector('.tile-detail'); + + if (wifiInfo && wifiDetail) { + if (network.wifi.mode === 'ap') { + wifiInfo.textContent = 'Access Point'; + wifiDetail.textContent = `SSID: ${network.wifi.ssid}`; + } else { + wifiInfo.textContent = 'Client Mode'; + wifiDetail.textContent = `SSID: ${network.wifi.ssid}`; + } + } + } + + // Update Ethernet status + const ethernetStatus = document.getElementById('ethernet-status'); + const ethernetTile = document.getElementById('ethernet-tile'); + + if (ethernetStatus && ethernetTile) { + if (network.ethernet.connected) { + ethernetStatus.classList.remove('disconnected'); + ethernetStatus.classList.add('connected'); + ethernetTile.classList.remove('disconnected'); + ethernetTile.classList.add('connected'); + + const ethernetInfo = ethernetTile.querySelector('.tile-info'); + const ethernetDetail = ethernetTile.querySelector('.tile-detail'); + if (ethernetInfo && ethernetDetail) { + ethernetInfo.textContent = 'Connected'; + ethernetDetail.textContent = 'Link detected'; + } + } else { + ethernetStatus.classList.remove('connected'); + ethernetStatus.classList.add('disconnected'); + ethernetTile.classList.remove('connected'); + ethernetTile.classList.add('disconnected'); + + const ethernetInfo = ethernetTile.querySelector('.tile-info'); + const ethernetDetail = ethernetTile.querySelector('.tile-detail'); + if (ethernetInfo && ethernetDetail) { + ethernetInfo.textContent = 'Disconnected'; + ethernetDetail.textContent = 'No cable detected'; + } + } + } + } + + updateLoRaStatus(lora) { + const loraStatus = document.getElementById('lora-status'); + const loraTile = document.getElementById('lora-tile'); + + if (loraStatus && loraTile) { + if (lora.connected) { + loraStatus.classList.remove('disconnected'); + loraStatus.classList.add('connected'); + loraTile.classList.remove('disconnected'); + loraTile.classList.add('connected'); + + const loraInfo = loraTile.querySelector('.tile-info'); + const loraDetail = loraTile.querySelector('.tile-detail'); + + if (loraInfo && loraDetail) { + loraInfo.textContent = `${lora.onlineNodes}/${lora.totalNodes} Online`; + loraDetail.textContent = `CH: ${lora.channelUtilization.toFixed(1)}% • Air: ${lora.airtimeUtilization.toFixed(1)}%`; + } + } else { + loraStatus.classList.remove('connected'); + loraStatus.classList.add('disconnected'); + loraTile.classList.remove('connected'); + loraTile.classList.add('disconnected'); + + const loraInfo = loraTile.querySelector('.tile-info'); + const loraDetail = loraTile.querySelector('.tile-detail'); + + if (loraInfo && loraDetail) { + loraInfo.textContent = 'Disconnected'; + loraDetail.textContent = 'No device found'; + } + } + } + } + + updateTimeSync(serverTimeString, requestStart, requestEnd) { + if (serverTimeString && requestStart && requestEnd) { + // Calculate network latency (round-trip time / 2) + const networkLatency = (requestEnd - requestStart) / 2; + + // Parse server time and adjust for network latency + const serverTime = new Date(serverTimeString); + const adjustedServerTime = new Date(serverTime.getTime() + networkLatency); + + // Calculate the offset between adjusted server time and client time + const clientTime = new Date(); + this.serverTimeOffset = adjustedServerTime.getTime() - clientTime.getTime(); + this.isTimeServerSynced = true; + + console.log(`Time synchronized with server (latency: ${networkLatency.toFixed(1)}ms, offset: ${this.serverTimeOffset.toFixed(1)}ms)`); + } + + // Update time displays + this.updateCurrentTime(); + } + + updateCurrentTime() { + const now = new Date(); + let displayTime; + + if (this.isTimeServerSynced && this.serverTimeOffset !== null) { + // Use server-synchronized time + displayTime = new Date(now.getTime() + this.serverTimeOffset); + } else { + // Use client time (default) + displayTime = now; + } + + this.updateTimeDisplay('local', displayTime, false); + this.updateTimeDisplay('zulu', displayTime, true); + } + + updateTimeDisplay(type, date, isUtc) { + const timeElement = document.getElementById(`${type}-time`); + const dateElement = document.getElementById(`${type}-date`); + + if (timeElement && dateElement) { + const displayDate = isUtc ? new Date(date.getTime()) : date; + + const timeStr = isUtc ? + displayDate.toUTCString().split(' ')[4] : + displayDate.toLocaleTimeString(); + + const dateStr = isUtc ? + displayDate.toUTCString().split(' ').slice(0, 4).join(' ') : + displayDate.toLocaleDateString('en-US', { + month: 'short', + day: 'numeric', + year: 'numeric' + }); + + timeElement.textContent = timeStr; + dateElement.textContent = dateStr; + + // Color time orange when using client time, white when server-synced + if (this.isTimeServerSynced) { + timeElement.style.color = '#fff'; + dateElement.style.color = '#64748b'; + } else { + timeElement.style.color = '#f59e0b'; + dateElement.style.color = '#f59e0b'; + } + } + } + + showOfflineStatus() { + // Reset to client time and show orange color + this.serverTimeOffset = null; + this.isTimeServerSynced = false; + console.warn('System appears offline - falling back to client time'); + } + + startStatusUpdates() { + // Initial fetch + this.fetchStatus(); + + // Update every 60 seconds + setInterval(() => { + this.fetchStatus(); + }, 60000); + } + + startTimeUpdates() { + // Start immediately with client time + this.updateCurrentTime(); + + // Update time every second + setInterval(() => { + this.updateCurrentTime(); + }, 1000); + } + + initializeEventListeners() { + // Expand/collapse status + const expandToggle = document.getElementById('expand-toggle'); + const expandedStatus = document.getElementById('expanded-status'); + const expandIcon = document.getElementById('expand-icon'); + + if (expandToggle && expandedStatus && expandIcon) { + expandToggle.addEventListener('click', () => { + expandedStatus.classList.toggle('visible'); + expandIcon.classList.toggle('expanded'); + }); + } + + // Search functionality + const searchInput = document.getElementById('search-input'); + const appsGrid = document.getElementById('apps-grid'); + + if (searchInput && appsGrid) { + searchInput.addEventListener('input', (e) => { + const query = e.target.value.toLowerCase(); + const apps = appsGrid.querySelectorAll('.app-item'); + + apps.forEach(app => { + const name = app.getAttribute('data-name')?.toLowerCase() || ''; + app.style.display = name.includes(query) ? 'flex' : 'none'; + }); + }); + } + } +} + +function saveCodeBook() { + event.stopPropagation(); + event.preventDefault(); + window.location.href = '/code-book-print.html'; +} + +function openKiwixm(event) { + event.stopPropagation(); + event.preventDefault(); + window.location.href = window.location.origin.replace(/:\d+/g, '') + ':1400/admin'; +} + +// Initialize dashboard when DOM is ready +document.addEventListener('DOMContentLoaded', () => { + new Dashboard(); + + document.querySelectorAll('.app-item[href^=":"]').forEach(link => { + const port = link.getAttribute('href').substring(1); // Remove the ':' + const url = new URL(location.origin); + url.port = port; + link.href = url.toString(); + }); +}); diff --git a/public/manifest.json b/client/public/manifest.json old mode 100755 new mode 100644 similarity index 94% rename from public/manifest.json rename to client/public/manifest.json index 7b9f337..18263a2 --- a/public/manifest.json +++ b/client/public/manifest.json @@ -1,19 +1,19 @@ -{ - "name": "MRS", - "short_name": "MRS", - "description": "Multipurpose Radio Server", - "start_url": "/", - "display": "standalone", - "background_color": "#000000", - "theme_color": "#000000", - "orientation": "portrait-primary", - "icons": [ - { - "src": "/favicon.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "lang": "en-US", - "scope": "/" -} +{ + "name": "MRS", + "short_name": "MRS", + "description": "Multipurpose Radio Server", + "start_url": "/", + "display": "standalone", + "background_color": "#000000", + "theme_color": "#000000", + "orientation": "portrait-primary", + "icons": [ + { + "src": "/favicon.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "lang": "en-US", + "scope": "/" +} diff --git a/code/src/config.json b/client/src/config.json similarity index 100% rename from code/src/config.json rename to client/src/config.json diff --git a/code/src/main.mjs b/client/src/main.mjs old mode 100755 new mode 100644 similarity index 96% rename from code/src/main.mjs rename to client/src/main.mjs index ebecdb9..6877a30 --- a/code/src/main.mjs +++ b/client/src/main.mjs @@ -1,51 +1,51 @@ - -import express from "express"; -import { join } from 'path'; -import {environment} from './services/environment.mjs'; -import { statusRouter } from './services/status.mjs'; - -(async () => { - const app = express(); - - // Middleware - app.use(express.json()); - app.use((err, req, res, next) => { - console.error('Middleware error:', err); - res.status(500).json({ error: 'Internal server error' }); - }); - - // Routes - console.log(join(environment.root, '../public')); - app.use(express.static(join(environment.root, '../public'))); - - app.use('/api', statusRouter); - - // Error handler - app.use((err, req, res, next) => { - console.error('Unhandled error:', err); - res.status(500).json({ error: 'Internal server error' }); - }); - - // Startup - const server = app.listen(environment.port, () => { - console.log(`Dashboard running on http://localhost:${environment.port}`); - }).on('error', (err) => { - console.error('Server startup error:', err); - process.exit(1); - }); - - // Shutdown - const gracefulShutdown = (signal) => { - console.log(`Received ${signal}, shutting down gracefully`); - server.close((err) => { - if (err) { - console.error('Error during server shutdown:', err); - process.exit(1); - } - console.log('Server closed'); - process.exit(0); - }); - }; - process.on('SIGTERM', () => gracefulShutdown('SIGTERM')); - process.on('SIGINT', () => gracefulShutdown('SIGINT')); -})(); + +import express from "express"; +import { join } from 'path'; +import {environment} from './services/environment.mjs'; +import { statusRouter } from './services/status.mjs'; + +(async () => { + const app = express(); + + // Middleware + app.use(express.json()); + app.use((err, req, res, next) => { + console.error('Middleware error:', err); + res.status(500).json({ error: 'Internal server error' }); + }); + + // Routes + console.log(join(environment.root, '../public')); + app.use(express.static(join(environment.root, '../public'))); + + app.use('/api', statusRouter); + + // Error handler + app.use((err, req, res, next) => { + console.error('Unhandled error:', err); + res.status(500).json({ error: 'Internal server error' }); + }); + + // Startup + const server = app.listen(environment.port, () => { + console.log(`Dashboard running on http://localhost:${environment.port}`); + }).on('error', (err) => { + console.error('Server startup error:', err); + process.exit(1); + }); + + // Shutdown + const gracefulShutdown = (signal) => { + console.log(`Received ${signal}, shutting down gracefully`); + server.close((err) => { + if (err) { + console.error('Error during server shutdown:', err); + process.exit(1); + } + console.log('Server closed'); + process.exit(0); + }); + }; + process.on('SIGTERM', () => gracefulShutdown('SIGTERM')); + process.on('SIGINT', () => gracefulShutdown('SIGINT')); +})(); diff --git a/code/src/services/environment.mjs b/client/src/services/environment.mjs old mode 100755 new mode 100644 similarity index 96% rename from code/src/services/environment.mjs rename to client/src/services/environment.mjs index ca0ef1d..5a39e1c --- a/code/src/services/environment.mjs +++ b/client/src/services/environment.mjs @@ -1,38 +1,38 @@ -import dotenv from 'dotenv'; -import * as fs from 'node:fs'; -import { fileURLToPath } from 'url'; -import { dirname } from 'path'; -import { execSync } from "child_process"; - -dotenv.config(); - -export const environment = { - config: process.env.CONFIG || 'config.json', - hostname: process.env.HOSTNAME || execSync('hostname', { encoding: "utf-8" }) || 'localhost', - gpsd: process.env.GPSD || 2947, - port: process.env.PORT || 80, - root: dirname(dirname(fileURLToPath(import.meta.url))), - settings: {}, -} - -if(!environment.config.startsWith('/')) environment.config = `${environment.root}/${environment.config}`; - -export function loadSettings() { - if(!fs.existsSync(environment.config)) fs.writeFileSync(environment.config, '', { flag: 'a' }); - const value = fs.readFileSync(environment.config, 'utf-8'); - try { return JSON.parse(value); } - catch (e) { - return { - lora: { - mode: 'MESH', - telemetry: true, - } - }; - } -} - -export function saveSettings() { - fs.writeFileSync(environment.config, JSON.stringify(environment.settings, null, 4)); -} - -loadSettings(); +import dotenv from 'dotenv'; +import * as fs from 'node:fs'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; +import { execSync } from "child_process"; + +dotenv.config(); + +export const environment = { + config: process.env.CONFIG || 'config.json', + hostname: process.env.HOSTNAME || execSync('hostname', { encoding: "utf-8" }) || 'localhost', + gpsd: process.env.GPSD || 2947, + port: process.env.PORT || 80, + root: dirname(dirname(fileURLToPath(import.meta.url))), + settings: {}, +} + +if(!environment.config.startsWith('/')) environment.config = `${environment.root}/${environment.config}`; + +export function loadSettings() { + if(!fs.existsSync(environment.config)) fs.writeFileSync(environment.config, '', { flag: 'a' }); + const value = fs.readFileSync(environment.config, 'utf-8'); + try { return JSON.parse(value); } + catch (e) { + return { + lora: { + mode: 'MESH', + telemetry: true, + } + }; + } +} + +export function saveSettings() { + fs.writeFileSync(environment.config, JSON.stringify(environment.settings, null, 4)); +} + +loadSettings(); diff --git a/src/services/status.mjs b/client/src/services/status.mjs old mode 100755 new mode 100644 similarity index 96% rename from src/services/status.mjs rename to client/src/services/status.mjs index 7d6f7ee..2fbb8c9 --- a/src/services/status.mjs +++ b/client/src/services/status.mjs @@ -1,426 +1,426 @@ - -import express from 'express'; -import { exec } from 'child_process'; -import { promisify } from 'util'; -import { readFileSync, existsSync } from 'fs'; -import pkg from 'node-gpsd'; -const { GPS } = pkg; -import {environment} from './environment.mjs'; - -const router = express.Router(); -const execAsync = promisify(exec); - -// Status cache with TTL -let statusCache = null; -let lastUpdate = 0; -const CACHE_TTL = 15 * 1000; // 15 seconds - -// GPS client setup -let gpsClient = null; -let gpsData = { - fix: 'No Fix', - latitude: null, - longitude: null, - altitude: null, - satellites: 0 -}; - -// Initialize GPS connection -async function initGPS() { - try { - gpsClient = new GPS({ hostname: 'localhost', port: 2947 }); - - gpsClient.on('TPV', (data) => { - gpsData.latitude = data.lat || null; - gpsData.longitude = data.lon || null; - gpsData.altitude = data.alt || null; - gpsData.fix = data.mode === 3 ? '3D Fix' : data.mode === 2 ? '2D Fix' : 'No Fix'; - }); - - gpsClient.on('SKY', (data) => { - gpsData.satellites = (data.satellites || []).length; - }); - - gpsClient.on('error', (err) => { - console.warn('GPS error:', err.message); - }); - - await gpsClient.watch(); - console.log('GPS client initialized'); - } catch (error) { - console.warn('GPS not available:', error.message); - } -} - -// CLI-based system information gathering -async function getSystemInfo() { - const info = { - temperature: 0, - load: 0, - cpu: 0, - memory: 0, - storage: 0 - }; - - try { - // CPU temperature (Raspberry Pi specific) - if (existsSync('/sys/class/thermal/thermal_zone0/temp')) { - const tempData = readFileSync('/sys/class/thermal/thermal_zone0/temp', 'utf8'); - info.temperature = Math.round(parseInt(tempData.trim()) / 1000); - } - - // Load average - const { stdout: loadAvg } = await execAsync("cat /proc/loadavg | awk '{print $1}'"); - info.load = parseFloat(loadAvg.trim()) || 0; - - // CPU usage - const { stdout: cpuUsage } = await execAsync("grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$3+$4+$5)} END {print usage}'"); - info.cpu = parseFloat(cpuUsage.trim()) || 0; - - // Memory usage percentage - const { stdout: memUsage } = await execAsync("free | awk 'NR==2{printf \"%.1f\", $3*100/$2}'"); - info.memory = parseFloat(memUsage.trim()) || 0; - - // Disk usage percentage for root filesystem - const { stdout: diskUsage } = await execAsync("df / | awk 'NR==2{printf \"%.1f\", $5}' | sed 's/%//'"); - info.storage = parseFloat(diskUsage.trim()) || 0; - - } catch (error) { - console.warn('System info error:', error.message); - } - - return info; -} - -async function getGPSInfo() { - const gpsInfo = { - satellites: 0, - latitude: null, - longitude: null, - altitude: null - }; - - try { - // Check if gpsd is running - await execAsync('systemctl is-active gpsd'); - - // Try to get GPS data using gpspipe - const { stdout: gpsRaw } = await execAsync('timeout 3s gpspipe -w -n 5 | grep -E \'"class":"TPV"\' | head -1', { timeout: 4000 }); - - if (gpsRaw.trim()) { - const gpsJson = JSON.parse(gpsRaw.trim()); - gpsInfo.latitude = gpsJson.lat || null; - gpsInfo.longitude = gpsJson.lon || null; - gpsInfo.altitude = gpsJson.alt || null; - } - - // Get satellite count - try { - const { stdout: skyRaw } = await execAsync('timeout 2s gpspipe -w -n 3 | grep -E \'"class":"SKY"\' | head -1', { timeout: 3000 }); - if (skyRaw.trim()) { - const skyJson = JSON.parse(skyRaw.trim()); - gpsInfo.satellites = (skyJson.satellites || []).length; - } - } catch (skyError) { } - } catch (error) { - console.warn('GPS info error:', error.message); - // Use cached GPS data from node-gpsd if available - if (gpsData.latitude !== null) { - return gpsData; - } - } - - return gpsInfo; -} - -async function getNetworkInfo() { - const networkInfo = { - wifi: { - mode: 'client', - ssid: 'Unknown' - }, - ethernet: { - connected: false - } - }; - - try { - // Check if hostapd is running (AP mode) - try { - await execAsync('systemctl is-active hostapd'); - networkInfo.wifi.mode = 'ap'; - - // Get AP SSID from hostapd config or use hostname - try { - const { stdout: hostname } = await execAsync('hostname'); - networkInfo.wifi.ssid = process.env.AP_SSID || hostname.trim(); - } catch { - networkInfo.wifi.ssid = 'MRS-AP'; - } - } catch { - // Not in AP mode, check if connected to WiFi - try { - // First, try iwconfig directly since it's more reliable for ESSID - const { stdout: iwconfig } = await execAsync("iwconfig wlan0 2>/dev/null"); - const essidMatch = iwconfig.match(/ESSID:"([^"]+)"/); - - if (essidMatch && essidMatch[1] && essidMatch[1] !== 'off/any') { - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = essidMatch[1]; - } else { - // Fallback to nmcli if iwconfig doesn't work - try { - const { stdout: activeWifi } = await execAsync("nmcli -t -f NAME,TYPE,DEVICE connection show --active | grep -E '(wifi|802-11-wireless)' | cut -d':' -f1 | head -1"); - if (activeWifi.trim()) { - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = activeWifi.trim(); - } else { - // Try getting SSID from currently connected interface - const { stdout: connectedSSID } = await execAsync("nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d':' -f2 | head -1"); - if (connectedSSID.trim()) { - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = connectedSSID.trim(); - } else { - throw new Error('No active WiFi connection found'); - } - } - } catch { - // Final fallback: check if wlan0 interface is up and get info via ip - const { stdout: wlanStatus } = await execAsync("ip addr show wlan0 2>/dev/null | grep 'inet ' | wc -l"); - if (parseInt(wlanStatus.trim()) > 0) { - // Interface has IP but we can't determine SSID - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = 'Connected (Unknown SSID)'; - } else { - networkInfo.wifi.mode = 'disconnected'; - networkInfo.wifi.ssid = 'Not Connected'; - } - } - } - } catch (error) { - console.warn('WiFi detection error:', error.message); - networkInfo.wifi.mode = 'disconnected'; - networkInfo.wifi.ssid = 'Not Connected'; - } - } - - // Check Ethernet status - try { - const { stdout: ethStatus } = await execAsync("ip link show eth0 | grep 'state UP'"); - networkInfo.ethernet.connected = ethStatus.includes('state UP'); - } catch { - networkInfo.ethernet.connected = false; - } - - } catch (error) { - console.warn('Network info error:', error.message); - } - - return networkInfo; -} - -let loraInfo = null; -async function getLoRaInfo() { - if(loraInfo) return loraInfo; - - loraInfo = { - connected: false, - onlineNodes: 0, - totalNodes: 0, - channelUtilization: 0, - airtimeUtilization: 0 - }; - - try { - console.log('Getting LoRa/Meshtastic status...'); - - // Get node information first - const { stdout: nodeList } = await execAsync('timeout 10s meshtastic --nodes 2>/dev/null', { timeout: 15000 }); - - if (nodeList && nodeList.trim()) { - loraInfo.connected = true; - - // Parse node list - look for actual node entries - const lines = nodeList.split('\n'); - let totalNodes = 0; - let onlineNodes = 0; - - for (const line of lines) { - const trimmedLine = line.trim(); - - // Skip header lines and separators - if (trimmedLine.includes('│') && - !trimmedLine.includes('User') && - !trimmedLine.includes('───') && - !trimmedLine.includes('Node') && - trimmedLine.length > 10) { - - totalNodes++; - - // Check if node is online (has recent lastHeard or SNR data) - if (trimmedLine.includes('SNR') || - trimmedLine.match(/\d+[smh]/) || // Time indicators like 5m, 2h, 30s - trimmedLine.includes('now')) { - onlineNodes++; - } - } - } - - loraInfo.totalNodes = totalNodes; - loraInfo.onlineNodes = onlineNodes; - } - - // Get channel and airtime utilization from --info - try { - const { stdout: meshInfo } = await execAsync('timeout 10s meshtastic --info 2>/dev/null', { timeout: 15000 }); - - if (meshInfo && meshInfo.trim()) { - const lines = meshInfo.split('\n'); - - for (const line of lines) { - const trimmedLine = line.trim(); - - // Look for channel utilization (various formats) - if (trimmedLine.includes('channelUtilization') || trimmedLine.includes('Channel utilization')) { - const channelMatch = trimmedLine.match(/([\d.]+)%?/) || trimmedLine.match(/:\s*([\d.]+)/); - if (channelMatch) { - loraInfo.channelUtilization = parseFloat(channelMatch[1]); - } - } - - // Look for airtime utilization (various formats) - if (trimmedLine.includes('airUtilTx') || trimmedLine.includes('Air time') || trimmedLine.includes('Airtime')) { - const airtimeMatch = trimmedLine.match(/([\d.]+)%?/) || trimmedLine.match(/:\s*([\d.]+)/); - if (airtimeMatch) { - loraInfo.airtimeUtilization = parseFloat(airtimeMatch[1]); - } - } - } - } - } catch (infoError) { - console.warn('Failed to get mesh info:', infoError.message); - } - - } catch (error) { - console.warn('LoRa info error:', error.message); - loraInfo.connected = false; - } - - setTimeout(() => loraInfo = null, 60000) - return loraInfo; -} - -// Main status generation function - matches frontend expectations -async function generateStatus() { - try { - console.log('Generating fresh status...'); - - const [systemInfo, gpsInfo, networkInfo, loraInfo] = await Promise.all([ - getSystemInfo(), - getGPSInfo(), - getNetworkInfo(), - getLoRaInfo() - ]); - - // Format exactly as the frontend expects - const status = { - system: { - temperature: systemInfo.temperature, - load: systemInfo.load, - cpu: systemInfo.cpu, - memory: systemInfo.memory, - storage: systemInfo.storage - }, - gps: { - fix: gpsInfo.fix, - satellites: gpsInfo.satellites, - latitude: gpsInfo.latitude, - longitude: gpsInfo.longitude, - altitude: gpsInfo.altitude - }, - network: { - wifi: networkInfo.wifi, - ethernet: networkInfo.ethernet - }, - lora: loraInfo, - time: new Date().toISOString() - }; - - return status; - } catch (error) { - console.error('Status generation error:', error); - throw error; - } -} - -router.get('/hostname', (req, res) => res.json({ hostname: environment.hostname })); - -// Main status endpoint that matches frontend expectations -router.get('/status', async (req, res) => { - try { - const now = Date.now(); - - // Return cached status if within TTL - if (statusCache && (now - lastUpdate) < CACHE_TTL) { - console.log('Returning cached status'); - return res.json(statusCache); - } - - // Generate fresh status - statusCache = await generateStatus(); - lastUpdate = now; - - console.log('Status updated successfully'); - res.json(statusCache); - } catch (error) { - console.error('Status API error:', error); - res.status(500).json({ - error: 'Failed to get system status', - message: error.message, - timestamp: new Date().toISOString() - }); - } -}); - -// Individual debug endpoints -router.get('/system', async (req, res) => { - try { - const systemInfo = await getSystemInfo(); - res.json(systemInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -router.get('/gps', async (req, res) => { - try { - const gpsInfo = await getGPSInfo(); - res.json(gpsInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -router.get('/network', async (req, res) => { - try { - const networkInfo = await getNetworkInfo(); - res.json(networkInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -// Add individual LoRa endpoint -router.get('/lora', async (req, res) => { - try { - const loraInfo = await getLoRaInfo(); - res.json(loraInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -// Initialize GPS on startup -initGPS().catch(err => console.warn('GPS initialization failed:', err.message)); - -export { router as statusRouter }; + +import express from 'express'; +import { exec } from 'child_process'; +import { promisify } from 'util'; +import { readFileSync, existsSync } from 'fs'; +import pkg from 'node-gpsd'; +const { GPS } = pkg; +import {environment} from './environment.mjs'; + +const router = express.Router(); +const execAsync = promisify(exec); + +// Status cache with TTL +let statusCache = null; +let lastUpdate = 0; +const CACHE_TTL = 15 * 1000; // 15 seconds + +// GPS client setup +let gpsClient = null; +let gpsData = { + fix: 'No Fix', + latitude: null, + longitude: null, + altitude: null, + satellites: 0 +}; + +// Initialize GPS connection +async function initGPS() { + try { + gpsClient = new GPS({ hostname: 'localhost', port: 2947 }); + + gpsClient.on('TPV', (data) => { + gpsData.latitude = data.lat || null; + gpsData.longitude = data.lon || null; + gpsData.altitude = data.alt || null; + gpsData.fix = data.mode === 3 ? '3D Fix' : data.mode === 2 ? '2D Fix' : 'No Fix'; + }); + + gpsClient.on('SKY', (data) => { + gpsData.satellites = (data.satellites || []).length; + }); + + gpsClient.on('error', (err) => { + console.warn('GPS error:', err.message); + }); + + await gpsClient.watch(); + console.log('GPS client initialized'); + } catch (error) { + console.warn('GPS not available:', error.message); + } +} + +// CLI-based system information gathering +async function getSystemInfo() { + const info = { + temperature: 0, + load: 0, + cpu: 0, + memory: 0, + storage: 0 + }; + + try { + // CPU temperature (Raspberry Pi specific) + if (existsSync('/sys/class/thermal/thermal_zone0/temp')) { + const tempData = readFileSync('/sys/class/thermal/thermal_zone0/temp', 'utf8'); + info.temperature = Math.round(parseInt(tempData.trim()) / 1000); + } + + // Load average + const { stdout: loadAvg } = await execAsync("cat /proc/loadavg | awk '{print $1}'"); + info.load = parseFloat(loadAvg.trim()) || 0; + + // CPU usage + const { stdout: cpuUsage } = await execAsync("grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$3+$4+$5)} END {print usage}'"); + info.cpu = parseFloat(cpuUsage.trim()) || 0; + + // Memory usage percentage + const { stdout: memUsage } = await execAsync("free | awk 'NR==2{printf \"%.1f\", $3*100/$2}'"); + info.memory = parseFloat(memUsage.trim()) || 0; + + // Disk usage percentage for root filesystem + const { stdout: diskUsage } = await execAsync("df / | awk 'NR==2{printf \"%.1f\", $5}' | sed 's/%//'"); + info.storage = parseFloat(diskUsage.trim()) || 0; + + } catch (error) { + console.warn('System info error:', error.message); + } + + return info; +} + +async function getGPSInfo() { + const gpsInfo = { + satellites: 0, + latitude: null, + longitude: null, + altitude: null + }; + + try { + // Check if gpsd is running + await execAsync('systemctl is-active gpsd'); + + // Try to get GPS data using gpspipe + const { stdout: gpsRaw } = await execAsync('timeout 3s gpspipe -w -n 5 | grep -E \'"class":"TPV"\' | head -1', { timeout: 4000 }); + + if (gpsRaw.trim()) { + const gpsJson = JSON.parse(gpsRaw.trim()); + gpsInfo.latitude = gpsJson.lat || null; + gpsInfo.longitude = gpsJson.lon || null; + gpsInfo.altitude = gpsJson.alt || null; + } + + // Get satellite count + try { + const { stdout: skyRaw } = await execAsync('timeout 2s gpspipe -w -n 3 | grep -E \'"class":"SKY"\' | head -1', { timeout: 3000 }); + if (skyRaw.trim()) { + const skyJson = JSON.parse(skyRaw.trim()); + gpsInfo.satellites = (skyJson.satellites || []).length; + } + } catch (skyError) { } + } catch (error) { + console.warn('GPS info error:', error.message); + // Use cached GPS data from node-gpsd if available + if (gpsData.latitude !== null) { + return gpsData; + } + } + + return gpsInfo; +} + +async function getNetworkInfo() { + const networkInfo = { + wifi: { + mode: 'client', + ssid: 'Unknown' + }, + ethernet: { + connected: false + } + }; + + try { + // Check if hostapd is running (AP mode) + try { + await execAsync('systemctl is-active hostapd'); + networkInfo.wifi.mode = 'ap'; + + // Get AP SSID from hostapd config or use hostname + try { + const { stdout: hostname } = await execAsync('hostname'); + networkInfo.wifi.ssid = process.env.AP_SSID || hostname.trim(); + } catch { + networkInfo.wifi.ssid = 'MRS-AP'; + } + } catch { + // Not in AP mode, check if connected to WiFi + try { + // First, try iwconfig directly since it's more reliable for ESSID + const { stdout: iwconfig } = await execAsync("iwconfig wlan0 2>/dev/null"); + const essidMatch = iwconfig.match(/ESSID:"([^"]+)"/); + + if (essidMatch && essidMatch[1] && essidMatch[1] !== 'off/any') { + networkInfo.wifi.mode = 'client'; + networkInfo.wifi.ssid = essidMatch[1]; + } else { + // Fallback to nmcli if iwconfig doesn't work + try { + const { stdout: activeWifi } = await execAsync("nmcli -t -f NAME,TYPE,DEVICE connection show --active | grep -E '(wifi|802-11-wireless)' | cut -d':' -f1 | head -1"); + if (activeWifi.trim()) { + networkInfo.wifi.mode = 'client'; + networkInfo.wifi.ssid = activeWifi.trim(); + } else { + // Try getting SSID from currently connected interface + const { stdout: connectedSSID } = await execAsync("nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d':' -f2 | head -1"); + if (connectedSSID.trim()) { + networkInfo.wifi.mode = 'client'; + networkInfo.wifi.ssid = connectedSSID.trim(); + } else { + throw new Error('No active WiFi connection found'); + } + } + } catch { + // Final fallback: check if wlan0 interface is up and get info via ip + const { stdout: wlanStatus } = await execAsync("ip addr show wlan0 2>/dev/null | grep 'inet ' | wc -l"); + if (parseInt(wlanStatus.trim()) > 0) { + // Interface has IP but we can't determine SSID + networkInfo.wifi.mode = 'client'; + networkInfo.wifi.ssid = 'Connected (Unknown SSID)'; + } else { + networkInfo.wifi.mode = 'disconnected'; + networkInfo.wifi.ssid = 'Not Connected'; + } + } + } + } catch (error) { + console.warn('WiFi detection error:', error.message); + networkInfo.wifi.mode = 'disconnected'; + networkInfo.wifi.ssid = 'Not Connected'; + } + } + + // Check Ethernet status + try { + const { stdout: ethStatus } = await execAsync("ip link show eth0 | grep 'state UP'"); + networkInfo.ethernet.connected = ethStatus.includes('state UP'); + } catch { + networkInfo.ethernet.connected = false; + } + + } catch (error) { + console.warn('Network info error:', error.message); + } + + return networkInfo; +} + +let loraInfo = null; +async function getLoRaInfo() { + if(loraInfo) return loraInfo; + + loraInfo = { + connected: false, + onlineNodes: 0, + totalNodes: 0, + channelUtilization: 0, + airtimeUtilization: 0 + }; + + try { + console.log('Getting LoRa/Meshtastic status...'); + + // Get node information first + const { stdout: nodeList } = await execAsync('timeout 10s meshtastic --nodes 2>/dev/null', { timeout: 15000 }); + + if (nodeList && nodeList.trim()) { + loraInfo.connected = true; + + // Parse node list - look for actual node entries + const lines = nodeList.split('\n'); + let totalNodes = 0; + let onlineNodes = 0; + + for (const line of lines) { + const trimmedLine = line.trim(); + + // Skip header lines and separators + if (trimmedLine.includes('│') && + !trimmedLine.includes('User') && + !trimmedLine.includes('───') && + !trimmedLine.includes('Node') && + trimmedLine.length > 10) { + + totalNodes++; + + // Check if node is online (has recent lastHeard or SNR data) + if (trimmedLine.includes('SNR') || + trimmedLine.match(/\d+[smh]/) || // Time indicators like 5m, 2h, 30s + trimmedLine.includes('now')) { + onlineNodes++; + } + } + } + + loraInfo.totalNodes = totalNodes; + loraInfo.onlineNodes = onlineNodes; + } + + // Get channel and airtime utilization from --info + try { + const { stdout: meshInfo } = await execAsync('timeout 10s meshtastic --info 2>/dev/null', { timeout: 15000 }); + + if (meshInfo && meshInfo.trim()) { + const lines = meshInfo.split('\n'); + + for (const line of lines) { + const trimmedLine = line.trim(); + + // Look for channel utilization (various formats) + if (trimmedLine.includes('channelUtilization') || trimmedLine.includes('Channel utilization')) { + const channelMatch = trimmedLine.match(/([\d.]+)%?/) || trimmedLine.match(/:\s*([\d.]+)/); + if (channelMatch) { + loraInfo.channelUtilization = parseFloat(channelMatch[1]); + } + } + + // Look for airtime utilization (various formats) + if (trimmedLine.includes('airUtilTx') || trimmedLine.includes('Air time') || trimmedLine.includes('Airtime')) { + const airtimeMatch = trimmedLine.match(/([\d.]+)%?/) || trimmedLine.match(/:\s*([\d.]+)/); + if (airtimeMatch) { + loraInfo.airtimeUtilization = parseFloat(airtimeMatch[1]); + } + } + } + } + } catch (infoError) { + console.warn('Failed to get mesh info:', infoError.message); + } + + } catch (error) { + console.warn('LoRa info error:', error.message); + loraInfo.connected = false; + } + + setTimeout(() => loraInfo = null, 60000) + return loraInfo; +} + +// Main status generation function - matches frontend expectations +async function generateStatus() { + try { + console.log('Generating fresh status...'); + + const [systemInfo, gpsInfo, networkInfo, loraInfo] = await Promise.all([ + getSystemInfo(), + getGPSInfo(), + getNetworkInfo(), + getLoRaInfo() + ]); + + // Format exactly as the frontend expects + const status = { + system: { + temperature: systemInfo.temperature, + load: systemInfo.load, + cpu: systemInfo.cpu, + memory: systemInfo.memory, + storage: systemInfo.storage + }, + gps: { + fix: gpsInfo.fix, + satellites: gpsInfo.satellites, + latitude: gpsInfo.latitude, + longitude: gpsInfo.longitude, + altitude: gpsInfo.altitude + }, + network: { + wifi: networkInfo.wifi, + ethernet: networkInfo.ethernet + }, + lora: loraInfo, + time: new Date().toISOString() + }; + + return status; + } catch (error) { + console.error('Status generation error:', error); + throw error; + } +} + +router.get('/hostname', (req, res) => res.json({ hostname: environment.hostname })); + +// Main status endpoint that matches frontend expectations +router.get('/status', async (req, res) => { + try { + const now = Date.now(); + + // Return cached status if within TTL + if (statusCache && (now - lastUpdate) < CACHE_TTL) { + console.log('Returning cached status'); + return res.json(statusCache); + } + + // Generate fresh status + statusCache = await generateStatus(); + lastUpdate = now; + + console.log('Status updated successfully'); + res.json(statusCache); + } catch (error) { + console.error('Status API error:', error); + res.status(500).json({ + error: 'Failed to get system status', + message: error.message, + timestamp: new Date().toISOString() + }); + } +}); + +// Individual debug endpoints +router.get('/system', async (req, res) => { + try { + const systemInfo = await getSystemInfo(); + res.json(systemInfo); + } catch (error) { + res.status(500).json({ error: error.message }); + } +}); + +router.get('/gps', async (req, res) => { + try { + const gpsInfo = await getGPSInfo(); + res.json(gpsInfo); + } catch (error) { + res.status(500).json({ error: error.message }); + } +}); + +router.get('/network', async (req, res) => { + try { + const networkInfo = await getNetworkInfo(); + res.json(networkInfo); + } catch (error) { + res.status(500).json({ error: error.message }); + } +}); + +// Add individual LoRa endpoint +router.get('/lora', async (req, res) => { + try { + const loraInfo = await getLoRaInfo(); + res.json(loraInfo); + } catch (error) { + res.status(500).json({ error: error.message }); + } +}); + +// Initialize GPS on startup +initGPS().catch(err => console.warn('GPS initialization failed:', err.message)); + +export { router as statusRouter }; diff --git a/code/package-lock.json b/code/package-lock.json deleted file mode 100755 index 0e95487..0000000 --- a/code/package-lock.json +++ /dev/null @@ -1,370 +0,0 @@ -{ - "name": "dashboard", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "dashboard", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "node-gpsd": "^0.3.4" - }, - "devDependencies": { - "nodemon": "^3.1.10" - } - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", - "dev": true - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "node_modules/node-gpsd": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/node-gpsd/-/node-gpsd-0.3.4.tgz", - "integrity": "sha512-sI9hPfHiaWDmhjE1oJZnhMo7UF2vQVGl3qk0K4HbN1L8BkS0I+rd6V687eHOj/6ervXiHrhwXzYYsWdXxGy0Qg==", - "engines": { - "node": ">=v0.8.0" - } - }, - "node_modules/nodemon": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", - "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", - "dev": true, - "dependencies": { - "chokidar": "^3.5.2", - "debug": "^4", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "bin": { - "nodemon": "bin/nodemon.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nodemon" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "dev": true - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/touch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", - "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", - "dev": true, - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, - "node_modules/undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "dev": true - } - } -} diff --git a/code/public/manifest.json b/code/public/manifest.json deleted file mode 100755 index 7b9f337..0000000 --- a/code/public/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "MRS", - "short_name": "MRS", - "description": "Multipurpose Radio Server", - "start_url": "/", - "display": "standalone", - "background_color": "#000000", - "theme_color": "#000000", - "orientation": "portrait-primary", - "icons": [ - { - "src": "/favicon.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "lang": "en-US", - "scope": "/" -} diff --git a/code/src/services/status.mjs b/code/src/services/status.mjs deleted file mode 100755 index 7d6f7ee..0000000 --- a/code/src/services/status.mjs +++ /dev/null @@ -1,426 +0,0 @@ - -import express from 'express'; -import { exec } from 'child_process'; -import { promisify } from 'util'; -import { readFileSync, existsSync } from 'fs'; -import pkg from 'node-gpsd'; -const { GPS } = pkg; -import {environment} from './environment.mjs'; - -const router = express.Router(); -const execAsync = promisify(exec); - -// Status cache with TTL -let statusCache = null; -let lastUpdate = 0; -const CACHE_TTL = 15 * 1000; // 15 seconds - -// GPS client setup -let gpsClient = null; -let gpsData = { - fix: 'No Fix', - latitude: null, - longitude: null, - altitude: null, - satellites: 0 -}; - -// Initialize GPS connection -async function initGPS() { - try { - gpsClient = new GPS({ hostname: 'localhost', port: 2947 }); - - gpsClient.on('TPV', (data) => { - gpsData.latitude = data.lat || null; - gpsData.longitude = data.lon || null; - gpsData.altitude = data.alt || null; - gpsData.fix = data.mode === 3 ? '3D Fix' : data.mode === 2 ? '2D Fix' : 'No Fix'; - }); - - gpsClient.on('SKY', (data) => { - gpsData.satellites = (data.satellites || []).length; - }); - - gpsClient.on('error', (err) => { - console.warn('GPS error:', err.message); - }); - - await gpsClient.watch(); - console.log('GPS client initialized'); - } catch (error) { - console.warn('GPS not available:', error.message); - } -} - -// CLI-based system information gathering -async function getSystemInfo() { - const info = { - temperature: 0, - load: 0, - cpu: 0, - memory: 0, - storage: 0 - }; - - try { - // CPU temperature (Raspberry Pi specific) - if (existsSync('/sys/class/thermal/thermal_zone0/temp')) { - const tempData = readFileSync('/sys/class/thermal/thermal_zone0/temp', 'utf8'); - info.temperature = Math.round(parseInt(tempData.trim()) / 1000); - } - - // Load average - const { stdout: loadAvg } = await execAsync("cat /proc/loadavg | awk '{print $1}'"); - info.load = parseFloat(loadAvg.trim()) || 0; - - // CPU usage - const { stdout: cpuUsage } = await execAsync("grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$3+$4+$5)} END {print usage}'"); - info.cpu = parseFloat(cpuUsage.trim()) || 0; - - // Memory usage percentage - const { stdout: memUsage } = await execAsync("free | awk 'NR==2{printf \"%.1f\", $3*100/$2}'"); - info.memory = parseFloat(memUsage.trim()) || 0; - - // Disk usage percentage for root filesystem - const { stdout: diskUsage } = await execAsync("df / | awk 'NR==2{printf \"%.1f\", $5}' | sed 's/%//'"); - info.storage = parseFloat(diskUsage.trim()) || 0; - - } catch (error) { - console.warn('System info error:', error.message); - } - - return info; -} - -async function getGPSInfo() { - const gpsInfo = { - satellites: 0, - latitude: null, - longitude: null, - altitude: null - }; - - try { - // Check if gpsd is running - await execAsync('systemctl is-active gpsd'); - - // Try to get GPS data using gpspipe - const { stdout: gpsRaw } = await execAsync('timeout 3s gpspipe -w -n 5 | grep -E \'"class":"TPV"\' | head -1', { timeout: 4000 }); - - if (gpsRaw.trim()) { - const gpsJson = JSON.parse(gpsRaw.trim()); - gpsInfo.latitude = gpsJson.lat || null; - gpsInfo.longitude = gpsJson.lon || null; - gpsInfo.altitude = gpsJson.alt || null; - } - - // Get satellite count - try { - const { stdout: skyRaw } = await execAsync('timeout 2s gpspipe -w -n 3 | grep -E \'"class":"SKY"\' | head -1', { timeout: 3000 }); - if (skyRaw.trim()) { - const skyJson = JSON.parse(skyRaw.trim()); - gpsInfo.satellites = (skyJson.satellites || []).length; - } - } catch (skyError) { } - } catch (error) { - console.warn('GPS info error:', error.message); - // Use cached GPS data from node-gpsd if available - if (gpsData.latitude !== null) { - return gpsData; - } - } - - return gpsInfo; -} - -async function getNetworkInfo() { - const networkInfo = { - wifi: { - mode: 'client', - ssid: 'Unknown' - }, - ethernet: { - connected: false - } - }; - - try { - // Check if hostapd is running (AP mode) - try { - await execAsync('systemctl is-active hostapd'); - networkInfo.wifi.mode = 'ap'; - - // Get AP SSID from hostapd config or use hostname - try { - const { stdout: hostname } = await execAsync('hostname'); - networkInfo.wifi.ssid = process.env.AP_SSID || hostname.trim(); - } catch { - networkInfo.wifi.ssid = 'MRS-AP'; - } - } catch { - // Not in AP mode, check if connected to WiFi - try { - // First, try iwconfig directly since it's more reliable for ESSID - const { stdout: iwconfig } = await execAsync("iwconfig wlan0 2>/dev/null"); - const essidMatch = iwconfig.match(/ESSID:"([^"]+)"/); - - if (essidMatch && essidMatch[1] && essidMatch[1] !== 'off/any') { - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = essidMatch[1]; - } else { - // Fallback to nmcli if iwconfig doesn't work - try { - const { stdout: activeWifi } = await execAsync("nmcli -t -f NAME,TYPE,DEVICE connection show --active | grep -E '(wifi|802-11-wireless)' | cut -d':' -f1 | head -1"); - if (activeWifi.trim()) { - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = activeWifi.trim(); - } else { - // Try getting SSID from currently connected interface - const { stdout: connectedSSID } = await execAsync("nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d':' -f2 | head -1"); - if (connectedSSID.trim()) { - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = connectedSSID.trim(); - } else { - throw new Error('No active WiFi connection found'); - } - } - } catch { - // Final fallback: check if wlan0 interface is up and get info via ip - const { stdout: wlanStatus } = await execAsync("ip addr show wlan0 2>/dev/null | grep 'inet ' | wc -l"); - if (parseInt(wlanStatus.trim()) > 0) { - // Interface has IP but we can't determine SSID - networkInfo.wifi.mode = 'client'; - networkInfo.wifi.ssid = 'Connected (Unknown SSID)'; - } else { - networkInfo.wifi.mode = 'disconnected'; - networkInfo.wifi.ssid = 'Not Connected'; - } - } - } - } catch (error) { - console.warn('WiFi detection error:', error.message); - networkInfo.wifi.mode = 'disconnected'; - networkInfo.wifi.ssid = 'Not Connected'; - } - } - - // Check Ethernet status - try { - const { stdout: ethStatus } = await execAsync("ip link show eth0 | grep 'state UP'"); - networkInfo.ethernet.connected = ethStatus.includes('state UP'); - } catch { - networkInfo.ethernet.connected = false; - } - - } catch (error) { - console.warn('Network info error:', error.message); - } - - return networkInfo; -} - -let loraInfo = null; -async function getLoRaInfo() { - if(loraInfo) return loraInfo; - - loraInfo = { - connected: false, - onlineNodes: 0, - totalNodes: 0, - channelUtilization: 0, - airtimeUtilization: 0 - }; - - try { - console.log('Getting LoRa/Meshtastic status...'); - - // Get node information first - const { stdout: nodeList } = await execAsync('timeout 10s meshtastic --nodes 2>/dev/null', { timeout: 15000 }); - - if (nodeList && nodeList.trim()) { - loraInfo.connected = true; - - // Parse node list - look for actual node entries - const lines = nodeList.split('\n'); - let totalNodes = 0; - let onlineNodes = 0; - - for (const line of lines) { - const trimmedLine = line.trim(); - - // Skip header lines and separators - if (trimmedLine.includes('│') && - !trimmedLine.includes('User') && - !trimmedLine.includes('───') && - !trimmedLine.includes('Node') && - trimmedLine.length > 10) { - - totalNodes++; - - // Check if node is online (has recent lastHeard or SNR data) - if (trimmedLine.includes('SNR') || - trimmedLine.match(/\d+[smh]/) || // Time indicators like 5m, 2h, 30s - trimmedLine.includes('now')) { - onlineNodes++; - } - } - } - - loraInfo.totalNodes = totalNodes; - loraInfo.onlineNodes = onlineNodes; - } - - // Get channel and airtime utilization from --info - try { - const { stdout: meshInfo } = await execAsync('timeout 10s meshtastic --info 2>/dev/null', { timeout: 15000 }); - - if (meshInfo && meshInfo.trim()) { - const lines = meshInfo.split('\n'); - - for (const line of lines) { - const trimmedLine = line.trim(); - - // Look for channel utilization (various formats) - if (trimmedLine.includes('channelUtilization') || trimmedLine.includes('Channel utilization')) { - const channelMatch = trimmedLine.match(/([\d.]+)%?/) || trimmedLine.match(/:\s*([\d.]+)/); - if (channelMatch) { - loraInfo.channelUtilization = parseFloat(channelMatch[1]); - } - } - - // Look for airtime utilization (various formats) - if (trimmedLine.includes('airUtilTx') || trimmedLine.includes('Air time') || trimmedLine.includes('Airtime')) { - const airtimeMatch = trimmedLine.match(/([\d.]+)%?/) || trimmedLine.match(/:\s*([\d.]+)/); - if (airtimeMatch) { - loraInfo.airtimeUtilization = parseFloat(airtimeMatch[1]); - } - } - } - } - } catch (infoError) { - console.warn('Failed to get mesh info:', infoError.message); - } - - } catch (error) { - console.warn('LoRa info error:', error.message); - loraInfo.connected = false; - } - - setTimeout(() => loraInfo = null, 60000) - return loraInfo; -} - -// Main status generation function - matches frontend expectations -async function generateStatus() { - try { - console.log('Generating fresh status...'); - - const [systemInfo, gpsInfo, networkInfo, loraInfo] = await Promise.all([ - getSystemInfo(), - getGPSInfo(), - getNetworkInfo(), - getLoRaInfo() - ]); - - // Format exactly as the frontend expects - const status = { - system: { - temperature: systemInfo.temperature, - load: systemInfo.load, - cpu: systemInfo.cpu, - memory: systemInfo.memory, - storage: systemInfo.storage - }, - gps: { - fix: gpsInfo.fix, - satellites: gpsInfo.satellites, - latitude: gpsInfo.latitude, - longitude: gpsInfo.longitude, - altitude: gpsInfo.altitude - }, - network: { - wifi: networkInfo.wifi, - ethernet: networkInfo.ethernet - }, - lora: loraInfo, - time: new Date().toISOString() - }; - - return status; - } catch (error) { - console.error('Status generation error:', error); - throw error; - } -} - -router.get('/hostname', (req, res) => res.json({ hostname: environment.hostname })); - -// Main status endpoint that matches frontend expectations -router.get('/status', async (req, res) => { - try { - const now = Date.now(); - - // Return cached status if within TTL - if (statusCache && (now - lastUpdate) < CACHE_TTL) { - console.log('Returning cached status'); - return res.json(statusCache); - } - - // Generate fresh status - statusCache = await generateStatus(); - lastUpdate = now; - - console.log('Status updated successfully'); - res.json(statusCache); - } catch (error) { - console.error('Status API error:', error); - res.status(500).json({ - error: 'Failed to get system status', - message: error.message, - timestamp: new Date().toISOString() - }); - } -}); - -// Individual debug endpoints -router.get('/system', async (req, res) => { - try { - const systemInfo = await getSystemInfo(); - res.json(systemInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -router.get('/gps', async (req, res) => { - try { - const gpsInfo = await getGPSInfo(); - res.json(gpsInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -router.get('/network', async (req, res) => { - try { - const networkInfo = await getNetworkInfo(); - res.json(networkInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -// Add individual LoRa endpoint -router.get('/lora', async (req, res) => { - try { - const loraInfo = await getLoRaInfo(); - res.json(loraInfo); - } catch (error) { - res.status(500).json({ error: error.message }); - } -}); - -// Initialize GPS on startup -initGPS().catch(err => console.warn('GPS initialization failed:', err.message)); - -export { router as statusRouter }; diff --git a/public/favicon.png b/public/favicon.png deleted file mode 100755 index 4e81999..0000000 Binary files a/public/favicon.png and /dev/null differ diff --git a/public/index.html b/public/index.html deleted file mode 100755 index 26e5733..0000000 --- a/public/index.html +++ /dev/null @@ -1,939 +0,0 @@ - - - - MRS Dashboard - - - - - - - -
-
-
- Logo -
- -
Hostname
-
-
-
-
-
-
Local
-
00:00:00
-
Jan 1, 2025
-
-
-
Zulu
-
00:00:00
-
Jan 1, 2025
-
-
-
-
-
-
- - - - - - - - - - - - - - - -
-
- - - - - -
-
- - - - - - - - - - - - - - - - -
-
- - - - - - -
-
- - - - -
-
- - - -
-
-
-
- -
-
-
-
- - - - - - - - -
System ?°C
-
-
-
-
CPU - Load
-
-
-
0%
-
-
-
-
Memory
-
-
-
0%
-
-
-
-
Disk
-
-
-
0%
-
-
-
-
- -
-
- - - - - - - - - - - - - - - -
GPS
-
-
-
39.2000, -49.0000
-
No Fix
-
-
- -
-
- - - - - -
LoRa
-
-
-
0 / 0 Online
-
Ch 0% Air 0%
-
-
- -
-
- - - - - - - - - - - - - - - - -
Mesh
-
-
-
Connected
-
900 Mhz -45 dBm
-
-
- -
-
- - - - - - -
WiFi
-
-
-
Access Point
-
SSID: Hostname
-
-
- -
-
- - - - -
Ethernet
-
-
-
Disconnected
-
No cable detected
-
-
- -
-
-
- -
- - -
- -
- - - - - - - - - -
-
AI Assistant
-
- - -
- - - -
- - - - - - -
-
-
ATAK
-
- - -
- - - -
-
File Browser
-
- - -
- - - - -
- - - - - - - - - - - -
-
-
Library
-
- - -
- - - - - -
-
Maps
-
- - -
- - - - - -
- - - - - - -
-
-
Meshtastic
-
- - -
- - - -
- - - - - - -
-
-
Messages
-
- - -
- - - - -
-
Pentesting
-
- - -
- - - - - -
-
Remote Desktop
-
- - -
- - - - - - - - -
-
SDR
-
- - -
- - - - -
-
Situation Room
-
- - -
- - - -
-
Speed Test
-
-
-
- - - - diff --git a/public/index.js b/public/index.js deleted file mode 100755 index f30310f..0000000 --- a/public/index.js +++ /dev/null @@ -1,368 +0,0 @@ - -class Dashboard { - constructor() { - this.statusCache = null; - this.lastFetch = 0; - this.hostname = 'localhost'; - this.serverTimeOffset = null; // Track difference between server and client time - this.isTimeServerSynced = false; // Track if we're using server time - this.init(); - } - - async init() { - await this.fetchHostname(); - this.updateHostname(); - this.startTimeUpdates(); // Start with client time immediately - this.startStatusUpdates(); - this.initializeEventListeners(); - } - - async fetchHostname() { - try { - const response = await fetch('/api/hostname'); - const data = await response.json(); - this.hostname = data.hostname; - } catch (error) { - console.warn('Failed to fetch hostname:', error); - } - } - - updateHostname() { - const hostnameElement = document.querySelector('.hostname'); - if (hostnameElement) { - hostnameElement.textContent = this.hostname; - } - } - - async fetchStatus() { - try { - // Record start time for latency calculation - const requestStart = performance.now(); - const response = await fetch('/api/status'); - const requestEnd = performance.now(); - - if (!response.ok) throw new Error('Status fetch failed'); - - const status = await response.json(); - this.statusCache = status; - this.updateUI(status, requestStart, requestEnd); - } catch (error) { - console.error('Failed to fetch status:', error); - this.showOfflineStatus(); - } - } - - updateUI(status, requestStart, requestEnd) { - this.updateSystemMetrics(status.system); - this.updateGPSStatus(status.gps); - this.updateNetworkStatus(status.network); - this.updateLoRaStatus(status.lora); - this.updateTimeSync(status.time, requestStart, requestEnd); - } - - updateSystemMetrics(system) { - // Update temperature - const tempElement = document.getElementById('temp'); - if (tempElement && system.temperature) { - tempElement.textContent = `${system.temperature}°C`; - } - - // Update load average - const loadElement = document.getElementById('load'); - if (loadElement && system.load !== undefined) { - loadElement.textContent = `${system.load.toFixed(1)} Load`; - } - - // Update progress bars - this.updateProgressBar('cpu-usage', system.cpu); - this.updateProgressBar('memory-usage', system.memory); - this.updateProgressBar('disk-usage', system.storage); - } - - updateProgressBar(id, percentage) { - const fillElement = document.getElementById(`${id}-fill`); - const textElement = document.getElementById(`${id}-text`); - - if (fillElement && textElement) { - const value = Math.round(percentage); - fillElement.style.width = `${value}%`; - textElement.textContent = `${value}%`; - - // Update color based on usage - if (value > 80) { - fillElement.style.background = '#ef4444'; // Red - } else if (value > 60) { - fillElement.style.background = '#f59e0b'; // Orange - } else { - fillElement.style.background = '#10b981'; // Green - } - } - } - - updateGPSStatus(gps) { - const gpsStatus = document.getElementById('gps-status'); - const gpsTile = document.getElementById('gps-tile'); - - if (gpsStatus && gpsTile) { - const hasValidFix = gps.fix !== 'No Fix' && gps.latitude !== null; - - // Update status indicator - if (hasValidFix) { - gpsStatus.classList.remove('disconnected'); - gpsStatus.classList.add('connected'); - gpsTile.classList.remove('disconnected'); - gpsTile.classList.add('connected'); - } else { - gpsStatus.classList.remove('connected'); - gpsStatus.classList.add('disconnected'); - gpsTile.classList.remove('connected'); - gpsTile.classList.add('disconnected'); - } - - // Update GPS tile info - const gpsInfo = gpsTile.querySelector('.tile-info'); - const gpsDetail = gpsTile.querySelector('.tile-detail'); - - if (gpsInfo && gpsDetail) { - if (hasValidFix) { - gpsInfo.textContent = `${gps.latitude.toFixed(4)}, ${gps.longitude.toFixed(4)}`; - gpsDetail.textContent = `${gps.fix} • ${gps.satellites} sats • Alt: ${Math.round(gps.altitude)}m`; - } else { - gpsInfo.textContent = gps.satellites > 0 ? 'Acquiring Fix...' : 'No Signal'; - gpsDetail.textContent = `${gps.satellites} satellites`; - } - } - } - } - - updateNetworkStatus(network) { - // Update WiFi status - const wifiTile = document.getElementById('wifi-tile'); - if (wifiTile) { - const wifiInfo = wifiTile.querySelector('.tile-info'); - const wifiDetail = wifiTile.querySelector('.tile-detail'); - - if (wifiInfo && wifiDetail) { - if (network.wifi.mode === 'ap') { - wifiInfo.textContent = 'Access Point'; - wifiDetail.textContent = `SSID: ${network.wifi.ssid}`; - } else { - wifiInfo.textContent = 'Client Mode'; - wifiDetail.textContent = `SSID: ${network.wifi.ssid}`; - } - } - } - - // Update Ethernet status - const ethernetStatus = document.getElementById('ethernet-status'); - const ethernetTile = document.getElementById('ethernet-tile'); - - if (ethernetStatus && ethernetTile) { - if (network.ethernet.connected) { - ethernetStatus.classList.remove('disconnected'); - ethernetStatus.classList.add('connected'); - ethernetTile.classList.remove('disconnected'); - ethernetTile.classList.add('connected'); - - const ethernetInfo = ethernetTile.querySelector('.tile-info'); - const ethernetDetail = ethernetTile.querySelector('.tile-detail'); - if (ethernetInfo && ethernetDetail) { - ethernetInfo.textContent = 'Connected'; - ethernetDetail.textContent = 'Link detected'; - } - } else { - ethernetStatus.classList.remove('connected'); - ethernetStatus.classList.add('disconnected'); - ethernetTile.classList.remove('connected'); - ethernetTile.classList.add('disconnected'); - - const ethernetInfo = ethernetTile.querySelector('.tile-info'); - const ethernetDetail = ethernetTile.querySelector('.tile-detail'); - if (ethernetInfo && ethernetDetail) { - ethernetInfo.textContent = 'Disconnected'; - ethernetDetail.textContent = 'No cable detected'; - } - } - } - } - - updateLoRaStatus(lora) { - const loraStatus = document.getElementById('lora-status'); - const loraTile = document.getElementById('lora-tile'); - - if (loraStatus && loraTile) { - if (lora.connected) { - loraStatus.classList.remove('disconnected'); - loraStatus.classList.add('connected'); - loraTile.classList.remove('disconnected'); - loraTile.classList.add('connected'); - - const loraInfo = loraTile.querySelector('.tile-info'); - const loraDetail = loraTile.querySelector('.tile-detail'); - - if (loraInfo && loraDetail) { - loraInfo.textContent = `${lora.onlineNodes}/${lora.totalNodes} Online`; - loraDetail.textContent = `CH: ${lora.channelUtilization.toFixed(1)}% • Air: ${lora.airtimeUtilization.toFixed(1)}%`; - } - } else { - loraStatus.classList.remove('connected'); - loraStatus.classList.add('disconnected'); - loraTile.classList.remove('connected'); - loraTile.classList.add('disconnected'); - - const loraInfo = loraTile.querySelector('.tile-info'); - const loraDetail = loraTile.querySelector('.tile-detail'); - - if (loraInfo && loraDetail) { - loraInfo.textContent = 'Disconnected'; - loraDetail.textContent = 'No device found'; - } - } - } - } - - updateTimeSync(serverTimeString, requestStart, requestEnd) { - if (serverTimeString && requestStart && requestEnd) { - // Calculate network latency (round-trip time / 2) - const networkLatency = (requestEnd - requestStart) / 2; - - // Parse server time and adjust for network latency - const serverTime = new Date(serverTimeString); - const adjustedServerTime = new Date(serverTime.getTime() + networkLatency); - - // Calculate the offset between adjusted server time and client time - const clientTime = new Date(); - this.serverTimeOffset = adjustedServerTime.getTime() - clientTime.getTime(); - this.isTimeServerSynced = true; - - console.log(`Time synchronized with server (latency: ${networkLatency.toFixed(1)}ms, offset: ${this.serverTimeOffset.toFixed(1)}ms)`); - } - - // Update time displays - this.updateCurrentTime(); - } - - updateCurrentTime() { - const now = new Date(); - let displayTime; - - if (this.isTimeServerSynced && this.serverTimeOffset !== null) { - // Use server-synchronized time - displayTime = new Date(now.getTime() + this.serverTimeOffset); - } else { - // Use client time (default) - displayTime = now; - } - - this.updateTimeDisplay('local', displayTime, false); - this.updateTimeDisplay('zulu', displayTime, true); - } - - updateTimeDisplay(type, date, isUtc) { - const timeElement = document.getElementById(`${type}-time`); - const dateElement = document.getElementById(`${type}-date`); - - if (timeElement && dateElement) { - const displayDate = isUtc ? new Date(date.getTime()) : date; - - const timeStr = isUtc ? - displayDate.toUTCString().split(' ')[4] : - displayDate.toLocaleTimeString(); - - const dateStr = isUtc ? - displayDate.toUTCString().split(' ').slice(0, 4).join(' ') : - displayDate.toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - year: 'numeric' - }); - - timeElement.textContent = timeStr; - dateElement.textContent = dateStr; - - // Color time orange when using client time, white when server-synced - if (this.isTimeServerSynced) { - timeElement.style.color = '#fff'; - dateElement.style.color = '#64748b'; - } else { - timeElement.style.color = '#f59e0b'; - dateElement.style.color = '#f59e0b'; - } - } - } - - showOfflineStatus() { - // Reset to client time and show orange color - this.serverTimeOffset = null; - this.isTimeServerSynced = false; - console.warn('System appears offline - falling back to client time'); - } - - startStatusUpdates() { - // Initial fetch - this.fetchStatus(); - - // Update every 60 seconds - setInterval(() => { - this.fetchStatus(); - }, 60000); - } - - startTimeUpdates() { - // Start immediately with client time - this.updateCurrentTime(); - - // Update time every second - setInterval(() => { - this.updateCurrentTime(); - }, 1000); - } - - initializeEventListeners() { - // Expand/collapse status - const expandToggle = document.getElementById('expand-toggle'); - const expandedStatus = document.getElementById('expanded-status'); - const expandIcon = document.getElementById('expand-icon'); - - if (expandToggle && expandedStatus && expandIcon) { - expandToggle.addEventListener('click', () => { - expandedStatus.classList.toggle('visible'); - expandIcon.classList.toggle('expanded'); - }); - } - - // Search functionality - const searchInput = document.getElementById('search-input'); - const appsGrid = document.getElementById('apps-grid'); - - if (searchInput && appsGrid) { - searchInput.addEventListener('input', (e) => { - const query = e.target.value.toLowerCase(); - const apps = appsGrid.querySelectorAll('.app-item'); - - apps.forEach(app => { - const name = app.getAttribute('data-name')?.toLowerCase() || ''; - app.style.display = name.includes(query) ? 'flex' : 'none'; - }); - }); - } - } -} - -function openKiwixm(event) { - event.stopPropagation(); - event.preventDefault(); - window.location.href = window.location.origin.replace(/:\d+/g, '') + ':1300/admin'; -} - -// Initialize dashboard when DOM is ready -document.addEventListener('DOMContentLoaded', () => { - new Dashboard(); - - document.querySelectorAll('.app-item[href^=":"]').forEach(link => { - const port = link.getAttribute('href').substring(1); // Remove the ':' - const url = new URL(location.origin); - url.port = port; - link.href = url.toString(); - }); -}); diff --git a/src/main.mjs b/src/main.mjs deleted file mode 100755 index ebecdb9..0000000 --- a/src/main.mjs +++ /dev/null @@ -1,51 +0,0 @@ - -import express from "express"; -import { join } from 'path'; -import {environment} from './services/environment.mjs'; -import { statusRouter } from './services/status.mjs'; - -(async () => { - const app = express(); - - // Middleware - app.use(express.json()); - app.use((err, req, res, next) => { - console.error('Middleware error:', err); - res.status(500).json({ error: 'Internal server error' }); - }); - - // Routes - console.log(join(environment.root, '../public')); - app.use(express.static(join(environment.root, '../public'))); - - app.use('/api', statusRouter); - - // Error handler - app.use((err, req, res, next) => { - console.error('Unhandled error:', err); - res.status(500).json({ error: 'Internal server error' }); - }); - - // Startup - const server = app.listen(environment.port, () => { - console.log(`Dashboard running on http://localhost:${environment.port}`); - }).on('error', (err) => { - console.error('Server startup error:', err); - process.exit(1); - }); - - // Shutdown - const gracefulShutdown = (signal) => { - console.log(`Received ${signal}, shutting down gracefully`); - server.close((err) => { - if (err) { - console.error('Error during server shutdown:', err); - process.exit(1); - } - console.log('Server closed'); - process.exit(0); - }); - }; - process.on('SIGTERM', () => gracefulShutdown('SIGTERM')); - process.on('SIGINT', () => gracefulShutdown('SIGINT')); -})(); diff --git a/src/services/environment.mjs b/src/services/environment.mjs deleted file mode 100755 index 08590a2..0000000 --- a/src/services/environment.mjs +++ /dev/null @@ -1,38 +0,0 @@ -import dotenv from 'dotenv'; -import * as fs from 'node:fs'; -import { fileURLToPath } from 'url'; -import { dirname } from 'path'; -import { execSync } from "child_process"; - -dotenv.config(); - -export const environment = { - config: process.env.CONFIG || 'config.json', - hostname: process.env.HOSTNAME || execSync('hostname', { encoding: "utf-8" }) || 'localhost', - gpsd: process.env.GPSD || 2947, - port: process.env.PORT || 3000, - root: dirname(dirname(fileURLToPath(import.meta.url))), - settings: {}, -} - -if(!environment.config.startsWith('/')) environment.config = `${environment.root}/${environment.config}`; - -export function loadSettings() { - if(!fs.existsSync(environment.config)) fs.writeFileSync(environment.config, '', { flag: 'a' }); - const value = fs.readFileSync(environment.config, 'utf-8'); - try { return JSON.parse(value); } - catch (e) { - return { - lora: { - mode: 'MESH', - telemetry: true, - } - }; - } -} - -export function saveSettings() { - fs.writeFileSync(environment.config, JSON.stringify(environment.settings, null, 4)); -} - -loadSettings();