Skip to content

Commit 8bd302b

Browse files
committed
add simple ui implementation for docker
1 parent 5222cda commit 8bd302b

File tree

13 files changed

+358
-95
lines changed

13 files changed

+358
-95
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ jobs:
147147
- if: ${{ matrix.cross }}
148148
run: cargo +beta install cross --git https://github.com/cross-rs/cross
149149
- if: ${{ matrix.cross }}
150-
run: cross +beta build --release --target '${{ matrix.target }}' --locked
150+
run: cross +beta build --features tui --release --target '${{ matrix.target }}' --locked
151151
- if: ${{ !matrix.cross }}
152-
run: cargo +beta build --release --target '${{ matrix.target }}' --locked
152+
run: cargo +beta build --features tui --release --target '${{ matrix.target }}' --locked
153153
- run: mkdir dist
154154
- run: echo -n '${{ github.sha }}' > dist/commit-sha.txt
155155
shell: bash
@@ -178,6 +178,13 @@ jobs:
178178
jobs: ${{ toJSON(needs) }}
179179
clippy:
180180
runs-on: ubuntu-24.04
181+
strategy:
182+
matrix:
183+
features:
184+
- "--features tui"
185+
- "--features logger"
186+
- ""
187+
fail-fast: false
181188
env:
182189
SCCACHE_GHA_ENABLED: "true"
183190
RUSTC_WRAPPER: "sccache"
@@ -187,7 +194,7 @@ jobs:
187194
persist-credentials: false
188195
- run: rustup toolchain install beta --profile minimal --component clippy --allow-downgrade
189196
- uses: mozilla-actions/sccache-action@v0.0.9
190-
- run: cargo +beta clippy --all-targets --all-features -- -Dwarnings -Wclippy::pedantic
197+
- run: cargo +beta clippy --all-targets ${{ matrix.features }} -- -Dwarnings -Wclippy::pedantic
191198
pre-commit:
192199
runs-on: ubuntu-24.04
193200
steps:

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "rust-analyzer.cargo.features": ["tui"] }

Cargo.lock

Lines changed: 146 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,32 @@ license = "MIT"
66
publish = false
77

88
[dependencies]
9+
cfg-if = "=1.0.0"
910
color-eyre = "=0.6.3"
10-
crossterm = { version = "=0.28.1", features = ["event-stream"] }
11+
crossterm = { version = "=0.28.1", features = [
12+
"event-stream",
13+
], optional = true }
1114
derivative = "=2.2.0"
1215
dirs = "=6.0.0"
16+
env_logger = { version = "=0.11.8", optional = true }
1317
fancy-regex = "=0.14.0"
1418
futures = "=0.3.31"
1519
log = "=0.4.27"
1620
maxminddb = "=0.26.0"
17-
ratatui = "=0.29.0"
21+
ratatui = { version = "=0.29.0", optional = true }
1822
rlimit = "=0.10.2"
1923
serde = "=1.0.219"
2024
serde_json = "=1.0.140"
2125
tokio = { version = "=1.44.2", features = ["full"] }
2226
toml = "=0.8.20"
23-
tui-logger = "=0.17.0"
27+
tui-logger = { version = "=0.17.0", optional = true }
2428
url = "=2.5.4"
2529

30+
[features]
31+
default = []
32+
logger = ["dep:env_logger"]
33+
tui = ["dep:crossterm", "dep:ratatui", "dep:tui-logger"]
34+
2635
[target.'cfg(not(target_os = "android"))'.dependencies]
2736
reqwest = { version = "=0.12.15", default-features = false, features = [
2837
"brotli",

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN --mount=source=src,target=src \
99
--mount=source=Cargo.lock,target=Cargo.lock \
1010
--mount=type=cache,target=/app/target \
1111
--mount=type=cache,target=/usr/local/cargo/registry \
12-
cargo build --release --locked \
12+
cargo build --features logger --release --locked \
1313
&& cp target/release/proxy-scraper-checker .
1414

1515

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ You can get proxies obtained using this project in [monosans/proxy-list](https:/
3232

3333
### Docker
3434

35-
> [!WARNING]
36-
> User interface does not work with Docker.
35+
> [!NOTE]
36+
> Only a simple user interface in the form of logs is implemented for Docker.
3737
3838
1. [Install `Docker Compose`](https://docs.docker.com/compose/install/).
3939
1. Download [the archive with the program](https://github.com/monosans/proxy-scraper-checker/archive/refs/heads/main.zip).

compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ services:
88
init: true
99
logging:
1010
driver: local
11-
tty: true
1211
volumes:
1312
- proxy_scraper_checker_cache:/home/app/.cache/proxy_scraper_checker
1413
- ./out:/home/app/.local/share/proxy_scraper_checker

src/event.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use std::collections::HashMap;
2-
31
use crate::proxy::ProxyType;
42

3+
#[allow(dead_code)]
54
pub(crate) enum AppEvent {
65
GeoDbTotal(Option<u64>),
76
GeoDbDownloaded(usize),
@@ -17,36 +16,10 @@ pub(crate) enum AppEvent {
1716
}
1817

1918
pub(crate) enum Event {
19+
#[cfg(feature = "tui")]
2020
Tick,
21+
#[cfg(feature = "tui")]
2122
Crossterm(crossterm::event::Event),
23+
#[allow(dead_code)]
2224
App(AppEvent),
2325
}
24-
25-
#[derive(Default)]
26-
pub(crate) enum AppMode {
27-
#[default]
28-
Running,
29-
Done,
30-
Quit,
31-
}
32-
33-
#[derive(Default)]
34-
pub(crate) struct AppState {
35-
pub(crate) mode: AppMode,
36-
37-
pub(crate) geodb_total: u64,
38-
pub(crate) geodb_downloaded: usize,
39-
40-
pub(crate) sources_total: HashMap<ProxyType, usize>,
41-
pub(crate) sources_scraped: HashMap<ProxyType, usize>,
42-
43-
pub(crate) proxies_total: HashMap<ProxyType, usize>,
44-
pub(crate) proxies_checked: HashMap<ProxyType, usize>,
45-
pub(crate) proxies_working: HashMap<ProxyType, usize>,
46-
}
47-
48-
impl AppState {
49-
pub(crate) fn new() -> Self {
50-
AppState::default()
51-
}
52-
}

0 commit comments

Comments
 (0)