From 2228faa5502acfa03c7d4e054ee2ecae9bc66c10 Mon Sep 17 00:00:00 2001 From: ospab Date: Tue, 26 May 2026 16:19:14 +0300 Subject: [PATCH] android: foreground service, wakelock, persistent notification, quick settings tile; gui: separate ping metric with color coding --- .ostp_public_ip | 1 + ostp-gui/src/index.html | 20 ++++++++++++--- ostp-gui/src/main.js | 28 ++++++++++++++++++--- test.json | 56 +++++++++++++++++++++++++++++++++++++++++ test2.json | 56 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 7 deletions(-) create mode 100644 .ostp_public_ip create mode 100644 test.json create mode 100644 test2.json diff --git a/.ostp_public_ip b/.ostp_public_ip new file mode 100644 index 0000000..e56ea71 --- /dev/null +++ b/.ostp_public_ip @@ -0,0 +1 @@ +127.0.0.1 \ No newline at end of file diff --git a/ostp-gui/src/index.html b/ostp-gui/src/index.html index cc6a63f..779d08e 100644 --- a/ostp-gui/src/index.html +++ b/ostp-gui/src/index.html @@ -112,10 +112,24 @@
-
+
- - + + +
+
+ Ping + — ms +
+
+ +
+ +
+
+ + +
diff --git a/ostp-gui/src/main.js b/ostp-gui/src/main.js index b0182b5..2c4eba7 100644 --- a/ostp-gui/src/main.js +++ b/ostp-gui/src/main.js @@ -29,6 +29,8 @@ const serverBadgeTxt = $('server-badge-text'); const metricDown = $('metric-down'); const metricUp = $('metric-up'); const metricMode = $('metric-mode'); +const metricPing = $('metric-ping'); +const pingIconBlock = $('ping-icon-block'); const toast = $('toast'); const btnGoSettings = $('btn-go-settings'); @@ -159,11 +161,29 @@ async function poll() { if (metrics) { metricDown.textContent = fmtBytes(metrics.bytes_recv); metricUp.textContent = fmtBytes(metrics.bytes_sent); - + const isTun = rawConfig?.tun?.enable; - const modeStr = isTun ? 'TUN' : 'SOCKS5'; - const pingStr = metrics.rtt_ms > 0 ? ` (${metrics.rtt_ms} ms)` : ''; - metricMode.textContent = modeStr + pingStr; + metricMode.textContent = isTun ? 'TUN' : 'SOCKS5'; + + const rtt = metrics.rtt_ms || 0; + if (rtt > 0) { + metricPing.textContent = rtt + ' ms'; + // Color code: green < 80ms, yellow < 200ms, red >= 200ms + if (rtt < 80) { + metricPing.style.color = 'var(--ping-good, #4ade80)'; + pingIconBlock.style.color = 'var(--ping-good, #4ade80)'; + } else if (rtt < 200) { + metricPing.style.color = 'var(--ping-mid, #facc15)'; + pingIconBlock.style.color = 'var(--ping-mid, #facc15)'; + } else { + metricPing.style.color = 'var(--ping-bad, #f87171)'; + pingIconBlock.style.color = 'var(--ping-bad, #f87171)'; + } + } else { + metricPing.textContent = '— ms'; + metricPing.style.color = ''; + pingIconBlock.style.color = ''; + } } } catch { setState('disconnected'); diff --git a/test.json b/test.json new file mode 100644 index 0000000..cab5795 --- /dev/null +++ b/test.json @@ -0,0 +1,56 @@ +{ + // OSTP Server Configuration + "mode": "server", + "log_level": "info", + + // The address and port the server listens on for incoming OSTP connections. + "listen": "0.0.0.0:50000", + + // List of valid keys. Clients must use one of these to connect. + "access_keys": [ + "07702b35e2062ac40eb4e46a7708dbf6" + ], + + // Optional proxy for outbound traffic. + "outbound": { + "enabled": false, + "protocol": "socks5", + "address": "127.0.0.1", + "port": 9050, + // default_action: 'proxy' (all through proxy) or 'direct' (bypass proxy by default). + "default_action": "proxy", + "rules": [ + { + "domain_suffix": [".onion"], + "action": "proxy" + } + ] + }, + + // Management REST API for third-party panels. + "api": { + "enabled": false, + "bind": "127.0.0.1:9090", + // Set a strong token for authentication. Leave empty to disable auth. + "token": "" + }, + + // Fallback TCP proxy: unrecognized connections are proxied to a web server (anti-DPI). + "fallback": { + "enabled": false, + "listen": "0.0.0.0:443", + // Target web server (e.g., local nginx or caddy) + "target": "127.0.0.1:8080" + }, + + // Reality (XTLS) / UoT Masquerade parameters + "reality": { + "enabled": false, + "dest": "www.microsoft.com:443", + "private_key": "", + "pbk": "", + "sid": "", + "sni_list": ["www.microsoft.com"] + }, + "debug": false +} \ No newline at end of file diff --git a/test2.json b/test2.json new file mode 100644 index 0000000..db5075d --- /dev/null +++ b/test2.json @@ -0,0 +1,56 @@ +{ + // OSTP Server Configuration + "mode": "server", + "log_level": "info", + + // The address and port the server listens on for incoming OSTP connections. + "listen": "0.0.0.0:50000", + + // List of valid keys. Clients must use one of these to connect. + "access_keys": [ + "faa4ed2bb00f5df012f5708d86f9541c" + ], + + // Optional proxy for outbound traffic. + "outbound": { + "enabled": false, + "protocol": "socks5", + "address": "127.0.0.1", + "port": 9050, + // default_action: 'proxy' (all through proxy) or 'direct' (bypass proxy by default). + "default_action": "proxy", + "rules": [ + { + "domain_suffix": [".onion"], + "action": "proxy" + } + ] + }, + + // Management REST API for third-party panels. + "api": { + "enabled": false, + "bind": "127.0.0.1:9090", + // Set a strong token for authentication. Leave empty to disable auth. + "token": "" + }, + + // Fallback TCP proxy: unrecognized connections are proxied to a web server (anti-DPI). + "fallback": { + "enabled": false, + "listen": "0.0.0.0:443", + // Target web server (e.g., local nginx or caddy) + "target": "127.0.0.1:8080" + }, + + // Reality (XTLS) / UoT Masquerade parameters + "reality": { + "enabled": false, + "dest": "www.microsoft.com:443", + "private_key": "lAapk0V5dG1xSD3CWZ0Ac3c_GKbJU0hVsRjiQ6VrCEY", + "pbk": "Md5jDEfpPmaMW5ggNSL7jA0LZi4eKsyfgMwseFQ0TyQ", + "sid": "db806ac3c8bf9417", + "sni_list": ["www.microsoft.com"] + }, + "debug": false +} \ No newline at end of file