Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions design/project/FaMain.dc.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions design/project/FaTray.dc.html

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions design/project/Main.dc.html

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions design/project/RuMain.dc.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions design/project/RuTray.dc.html

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions design/project/TrMain.dc.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions design/project/TrTray.dc.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions design/project/Tray.dc.html

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions design/project/ZhMain.dc.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions design/project/ZhTray.dc.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions design/project/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3379,3 +3379,5 @@ a.det{text-decoration:none}
[dir=rtl] .mg .bp-det b .i,[dir=rtl] .mg .bp-go .i,[dir=rtl] .mg .bp-ord .i{transform:scaleX(-1)}
[dir=rtl] .mg .bp-field input{font-family:var(--sans)}
/* bypass:end */

.wlh-auto{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:10px;border-top:1px solid var(--wl-line);font-size:13px;line-height:1.35;color:var(--muted)}
2 changes: 2 additions & 0 deletions design/project/app.fa.css
Original file line number Diff line number Diff line change
Expand Up @@ -3390,3 +3390,5 @@ a.det{text-decoration:none}
[dir=rtl] .mg .bp-det b .i,[dir=rtl] .mg .bp-go .i,[dir=rtl] .mg .bp-ord .i{transform:scaleX(-1)}
[dir=rtl] .mg .bp-field input{font-family:var(--sans)}
/* bypass:end */

.wlh-auto{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:10px;border-top:1px solid var(--wl-line);font-size:13px;line-height:1.35;color:var(--muted)}
2 changes: 2 additions & 0 deletions design/project/app.zh.css
Original file line number Diff line number Diff line change
Expand Up @@ -3379,3 +3379,5 @@ a.det{text-decoration:none}
[dir=rtl] .mg .bp-det b .i,[dir=rtl] .mg .bp-go .i,[dir=rtl] .mg .bp-ord .i{transform:scaleX(-1)}
[dir=rtl] .mg .bp-field input{font-family:var(--sans)}
/* bypass:end */

.wlh-auto{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:10px;border-top:1px solid var(--wl-line);font-size:13px;line-height:1.35;color:var(--muted)}
1,668 changes: 1,667 additions & 1 deletion design/project/canvas.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ui/src/design/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3379,3 +3379,5 @@ a.det{text-decoration:none}
[dir=rtl] .mg .bp-det b .i,[dir=rtl] .mg .bp-go .i,[dir=rtl] .mg .bp-ord .i{transform:scaleX(-1)}
[dir=rtl] .mg .bp-field input{font-family:var(--sans)}
/* bypass:end */

.wlh-auto{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:10px;border-top:1px solid var(--wl-line);font-size:13px;line-height:1.35;color:var(--muted)}
2 changes: 2 additions & 0 deletions ui/src/design/app.fa.css
Original file line number Diff line number Diff line change
Expand Up @@ -3390,3 +3390,5 @@ a.det{text-decoration:none}
[dir=rtl] .mg .bp-det b .i,[dir=rtl] .mg .bp-go .i,[dir=rtl] .mg .bp-ord .i{transform:scaleX(-1)}
[dir=rtl] .mg .bp-field input{font-family:var(--sans)}
/* bypass:end */

.wlh-auto{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:10px;border-top:1px solid var(--wl-line);font-size:13px;line-height:1.35;color:var(--muted)}
2 changes: 2 additions & 0 deletions ui/src/design/app.zh.css
Original file line number Diff line number Diff line change
Expand Up @@ -3379,3 +3379,5 @@ a.det{text-decoration:none}
[dir=rtl] .mg .bp-det b .i,[dir=rtl] .mg .bp-go .i,[dir=rtl] .mg .bp-ord .i{transform:scaleX(-1)}
[dir=rtl] .mg .bp-field input{font-family:var(--sans)}
/* bypass:end */

.wlh-auto{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;padding-top:10px;border-top:1px solid var(--wl-line);font-size:13px;line-height:1.35;color:var(--muted)}
24 changes: 19 additions & 5 deletions ui/src/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { words } from './live-i18n';
import { pref } from './live-settings';

type Status = { state: string; step: string; since_unix: number; server: string; server_id?: string; protocol: string; error: string;
purpose?: string; whitelist_by_rule?: boolean; whitelist_hint?: boolean }; // the channel for allowlists: in use, chosen by the rule, worth offering
purpose?: string; whitelist_by_rule?: boolean; whitelist_hint?: boolean; // the channel for allowlists: in use, chosen by the rule, worth offering
resync?: string; resync_unix?: number }; // the subscription asked for again after no server answered: running, changed, same, failed
// The design's states for that. "failed" has none: the ordinary state stays.
const RESYNC: Record<string, string> = { running: 'rf', changed: 'rfnew', same: 'rfsame' };
type Traffic = { rx_bps: number; tx_bps: number; rtt_ms: number };
// node, country, city, via (direct | relay | warp) and ipv6 come from a panel's client API only
export type Server = { id: string; name: string; protocol: string; node?: string; country?: string; city?: string; via?: string; ipv6?: boolean; load?: string; version?: string;
Expand Down Expand Up @@ -244,7 +247,9 @@ export function liveHome(Base: typeof DCLogic): typeof DCLogic {
listen<{ mode: string; effective: string }>('mg://routes', (e) => { this.route = e.payload; this.paint(); }),
// a subscription link from a mistgate:// link: put into the form like a pasted one, never fetched or added by itself
listen('mg://add', () => this.takeLink()),
listen<{ whitelist_auto?: boolean }>('mg://settings', (e) => this.setState({ wlAuto: !!e.payload.whitelist_auto })),
];
rpc<{ whitelist_auto?: boolean }>('settings.get').then((r) => this.setState({ wlAuto: !!r.whitelist_auto }), () => {});
this.takeLink();
document.addEventListener('paste', this.onPaste, true);
document.addEventListener('click', this.onWhere, true);
Expand Down Expand Up @@ -381,14 +386,18 @@ export function liveHome(Base: typeof DCLogic): typeof DCLogic {
Object.assign(next, { phase: 'on', secs: Math.max(0, Math.floor(Date.now() / 1000) - s.since_unix), wave: was === 'connecting' });
if (next.wave) { clearTimeout(this.t2); this.t2 = setTimeout(() => this.setState({ wave: false }), 1900); }
} else if (s.state === 'connecting') Object.assign(next, { phase: 'ing', cstep: STEP[s.step] ?? 0 });
else if (s.state === 'reconnecting') Object.assign(next, { phase: 'ing', cs: s.error === 'offline' ? 'offline' : 'rec' });
else if (s.state === 'reconnecting') Object.assign(next, { phase: 'ing', cs: s.error === 'offline' ? 'offline' : RESYNC[s.resync ?? ''] ?? 'rec' });
else if (s.state === 'blocked') Object.assign(next, { phase: 'off', cs: 'ks' });
else if (s.state === 'error' && s.error === 'no_subscription') next.phase = 'off';
else if (s.state === 'error') Object.assign(next, { phase: 'off', cs: s.error === 'offline' ? 'offline' : 'error' });
else if (s.state === 'error') Object.assign(next, { phase: 'off', cs: s.error === 'offline' ? 'offline' : this.failed(s) });
else next.phase = 'off';
this.setState(next);
}

// How a session that ended in an error is shown. "New settings: connecting again" is not said here: an ended
// session is not retried, the person presses the button.
failed(s: Status): string { return s.resync === 'running' ? 'rf' : s.resync === 'same' ? 'rfsame' : 'error'; }

// ---- subscriptions
sub(): Sub | null {
const list = this.subsList ?? [];
Expand Down Expand Up @@ -570,7 +579,10 @@ export function liveHome(Base: typeof DCLogic): typeof DCLogic {
renderVals() {
const wls = this.wls(), wlSel = this.wlPicked(), real = this.state;
let v: any;
this.state = { ...real, wl: wls.length ? 'yes' : 'none', wlN: wls.length > 1 ? 3 : 1, ...(wlSel ? { sel: 'wl' } : {}) };
// the chosen channel for allowlists that did not come up has a state of its own (the status names no purpose
// once the session has ended: the choice says it)
const wlErr = wlSel && (real?.cs === 'error' || real?.cs === 'rfsame');
this.state = { ...real, wl: wls.length ? 'yes' : 'none', wlN: wls.length > 1 ? 3 : 1, ...(wlSel ? { sel: 'wl' } : {}), ...(wlErr ? { cs: 'wlerr' } : {}) };
try { v = super.renderVals(); } finally { this.state = real; }
PROTO.trusttunnel[0] = 'isTt' in (v.cur ?? {}) ? 'tt' : 'vless';
const s: Status | null = this.live;
Expand All @@ -584,7 +596,8 @@ export function liveHome(Base: typeof DCLogic): typeof DCLogic {
// the service opens the network and reports off.
v.csUnblock = () => (s?.error === 'kill_switch' ? void rpc('settings.set', { kill_switch: 'while' }).catch(() => {}) : this.ask('disconnect'));
v.det = { on: false }; // the detector's chip is the design's sample until the detectors exist
if (v.isErr) v.csS = ''; // the design's line counts tried servers; the service does not report that yet
if (this.cs === 'error') v.csS = ''; // the design's line counts tried servers; the service does not report that yet
if (this.cs === 'wlerr' && s?.error !== 'no_server_answers') v.csS = ''; // "no DNS server answers" is that code only
if (this.subsList) this.subsVals(v, on ? s : null);
if (wlSel) v.msTxt.cur = v.cur.ms = '—'; // the channel has no latency number
return v;
Expand All @@ -611,6 +624,7 @@ export function liveHome(Base: typeof DCLogic): typeof DCLogic {
pick: () => { if (!wlSel) go(c.id); },
// the service says when the ordinary servers have failed for a reason of the network
hint: !this.st().wlHintOff && (!!this.live?.whitelist_hint || trying),
autoT: () => void rpc<{ whitelist_auto?: boolean }>('settings.set', { whitelist_auto: !this.st().wlAuto }).then((r) => this.setState({ wlAuto: !!r.whitelist_auto }), () => {}),
// a failed session is not running: choosing alone would not connect
tryGo: () => { if (trying) return; pref.set('wl', c.id); pref.set('server', c.id); this.setState({ sel: c.id, pop: false, wlTry: true, phase: 'ing', cs: '', cstep: 0, wave: false }, () => this.connect()); },
});
Expand Down
7 changes: 4 additions & 3 deletions ui/src/screens/en/Main.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h2 class="onb-t rise d1">Add your subscription</h2>
<span><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19V5"/><path d="m6 11 6-6 6 6"/></svg>{{up}} <small>Mbps</small></span>
<span>{{msTxt.cur}} <small>ms</small></span>
</div>
<sc-if value="{{wl.onNow}}" hint-placeholder-val="{{false}}"><p class="det wl rise d3" role="status"><svg class="i s16" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7h6a3 3 0 0 1 3 3v4a3 3 0 0 0 3 3h6"/><path d="m18 14 3 3-3 3"/></svg>for allowlists · backup channel</p></sc-if>
<sc-if value="{{wl.onNow}}" hint-placeholder-val="{{false}}"><p class="det wl rise d3" role="status"><svg class="i s16" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7h6a3 3 0 0 1 3 3v4a3 3 0 0 0 3 3h6"/><path d="m18 14 3 3-3 3"/></svg>over DNS · connected, slow</p></sc-if>
<sc-if value="{{det.on}}" hint-placeholder-val="{{true}}"><a class="det rise d3 {{det.c}}" href="Diag.dc.html"><svg class="i s16" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v5.5M12 7.6v.01"/></svg>{{det.t}}<b>{{det.a}}<svg class="i s14" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></b></a></sc-if>
</sc-if>
<sc-if value="{{csNote}}" hint-placeholder-val="{{false}}">
Expand Down Expand Up @@ -179,7 +179,7 @@ <h2 class="onb-t rise d1">Add your subscription</h2>
</div>
<div class="stip-p"><sc-for list="{{tip.pl}}" as="q" hint-placeholder-count="2"><span class="stip-c {{q.c}}">{{q.t}}</span></sc-for></div>
<sc-if value="{{tip.notWl}}" hint-placeholder-val="{{true}}"><div class="stip-l"><span>Load</span><span class="bar" aria-hidden="true"><i class="{{tip.loadC}}" style="width:{{tip.load}}%"></i></span><b>{{tip.load}}%</b></div></sc-if>
<sc-if value="{{tip.isWl}}" hint-placeholder-val="{{false}}"><div class="stip-w"><p><span class="gl g-dashboard-speed" aria-hidden="true"></span>Backup channel: speed may be lower than usual</p><sc-if value="{{tip.noUdp}}" hint-placeholder-val="{{false}}"><p class="no"><span class="gl g-gamepad" aria-hidden="true"></span>Calls and games do not work</p></sc-if></div></sc-if>
<sc-if value="{{tip.isWl}}" hint-placeholder-val="{{false}}"><div class="stip-w"><p><span class="gl g-dashboard-speed" aria-hidden="true"></span>Emergency channel over DNS. Never used by Auto</p><sc-if value="{{tip.noUdp}}" hint-placeholder-val="{{false}}"><p class="no"><span class="gl g-gamepad" aria-hidden="true"></span>Calls and games do not work</p></sc-if></div></sc-if>
</div>
<section class="servers {{svCls}}" aria-label="Servers">
<div class="sv-h">
Expand Down Expand Up @@ -241,8 +241,9 @@ <h2 class="onb-t rise d1">Add your subscription</h2>
<sc-if value="{{wl.hint}}" hint-placeholder-val="{{false}}">
<div class="wlh rise" role="status">
<span class="wlh-ic"><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7h6a3 3 0 0 1 3 3v4a3 3 0 0 0 3 3h6"/><path d="m18 14 3 3-3 3"/></svg></span>
<span class="tx"><b>Regular servers do not respond</b><span>Try the channel for allowlists?</span><em>Backup channel: speed may be lower than usual</em></span>
<span class="tx"><b>Regular servers do not respond</b><span>Three attempts in two minutes failed. Try the channel for allowlists?</span><em>Emergency channel over DNS: slow</em></span>
<span class="wlh-a"><button class="addb {{wl.tryC}}" onClick="{{wl.tryGo}}">{{wl.tryT}}</button><button class="wlh-n" onClick="{{wl.hintOff}}">Not now</button></span>
<span class="wlh-auto"><span>Switch to it automatically</span><button class="sw {{wl.autoC}}" role="switch" aria-checked="{{wl.autoA}}" aria-label="Switch to it automatically" onClick="{{wl.autoT}}"></button></span>
</div>
</sc-if>
<div class="srow">
Expand Down
Loading
Loading