mirror of https://github.com/ospab/ostp.git
android: foreground service, wakelock, persistent notification, quick settings tile; gui: separate ping metric with color coding
This commit is contained in:
parent
fffb67fbde
commit
2228faa550
|
|
@ -0,0 +1 @@
|
||||||
|
127.0.0.1
|
||||||
|
|
@ -112,10 +112,24 @@
|
||||||
<div class="metric-sep"></div>
|
<div class="metric-sep"></div>
|
||||||
|
|
||||||
<div class="metric">
|
<div class="metric">
|
||||||
<div class="metric-icon ping-icon">
|
<div class="metric-icon ping-icon" id="ping-icon-block">
|
||||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<path d="M1 6l5.5 5.5L12 6l5.5 5.5L23 6"/>
|
<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>
|
||||||
<path d="M1 18l5.5-5.5L12 18l5.5-5.5L23 18"/>
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="metric-body">
|
||||||
|
<span class="metric-label">Ping</span>
|
||||||
|
<span id="metric-ping" class="metric-value">— ms</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="metric-sep"></div>
|
||||||
|
|
||||||
|
<div class="metric">
|
||||||
|
<div class="metric-icon mode-icon">
|
||||||
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="2" y="3" width="20" height="14" rx="2"/>
|
||||||
|
<path d="M8 21h8M12 17v4"/>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="metric-body">
|
<div class="metric-body">
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ const serverBadgeTxt = $('server-badge-text');
|
||||||
const metricDown = $('metric-down');
|
const metricDown = $('metric-down');
|
||||||
const metricUp = $('metric-up');
|
const metricUp = $('metric-up');
|
||||||
const metricMode = $('metric-mode');
|
const metricMode = $('metric-mode');
|
||||||
|
const metricPing = $('metric-ping');
|
||||||
|
const pingIconBlock = $('ping-icon-block');
|
||||||
const toast = $('toast');
|
const toast = $('toast');
|
||||||
|
|
||||||
const btnGoSettings = $('btn-go-settings');
|
const btnGoSettings = $('btn-go-settings');
|
||||||
|
|
@ -159,11 +161,29 @@ async function poll() {
|
||||||
if (metrics) {
|
if (metrics) {
|
||||||
metricDown.textContent = fmtBytes(metrics.bytes_recv);
|
metricDown.textContent = fmtBytes(metrics.bytes_recv);
|
||||||
metricUp.textContent = fmtBytes(metrics.bytes_sent);
|
metricUp.textContent = fmtBytes(metrics.bytes_sent);
|
||||||
|
|
||||||
const isTun = rawConfig?.tun?.enable;
|
const isTun = rawConfig?.tun?.enable;
|
||||||
const modeStr = isTun ? 'TUN' : 'SOCKS5';
|
metricMode.textContent = isTun ? 'TUN' : 'SOCKS5';
|
||||||
const pingStr = metrics.rtt_ms > 0 ? ` (${metrics.rtt_ms} ms)` : '';
|
|
||||||
metricMode.textContent = modeStr + pingStr;
|
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 {
|
} catch {
|
||||||
setState('disconnected');
|
setState('disconnected');
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue