dsh-remote-plugin 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +63 -1
- package/package.json +1 -1
- package/public/admin.html +29 -29
- package/public/app.js +18 -0
- package/public/build.json +2 -2
- package/public/desktop/desktop.html +62 -62
- package/public/e2ee-transport.js +52 -4
- package/public/index.html +68 -67
- package/public/plugin.html +25 -25
- package/public/relay-autopair.js +217 -0
- package/public/relay-settings.css +6 -0
- package/public/skins/blue-fish/preview.html +3 -3
- package/public/skins/bocchi/preview.html +5 -5
- package/public/skins/kita/preview.html +6 -6
- package/public/skins/nijika/preview.html +6 -6
- package/public/skins/penguin/preview.html +3 -3
- package/public/skins/ryo/preview.html +6 -6
- package/public/update.json +8 -8
- package/public/version.json +1 -1
- package/public/workflow.js +1 -1
package/apk/dsh-remote.apk
CHANGED
|
Binary file
|
package/gateway.cjs
CHANGED
|
@@ -1568,6 +1568,8 @@ const DSH_HEALTH_PATH = String(process.env.DSH_HEALTH_PATH || '/').startsWith('/
|
|
|
1568
1568
|
: '/' + String(process.env.DSH_HEALTH_PATH)
|
|
1569
1569
|
const DSH_UPSTREAM_COOKIE_FILE = process.env.DSH_REMOTE_DSH_COOKIE_FILE || path.join(os.homedir(), '.dsh-remote', 'dsh-upstream.cookie')
|
|
1570
1570
|
const TOKEN_FILE = process.env.TOKEN_FILE || path.join(os.homedir(), '.dsh-remote', 'token')
|
|
1571
|
+
const PAIRING_LOG_FILE = process.env.DSH_REMOTE_PAIR_LOG || path.join(os.homedir(), '.dsh-remote', 'pairing.log')
|
|
1572
|
+
const PAIRING_LOG_LIMIT_BYTES = 512 * 1024
|
|
1571
1573
|
const DSH_CONTROL_DIR = path.join(path.dirname(TOKEN_FILE), 'lifecycle-' + PORT)
|
|
1572
1574
|
const NOTES_FILE = process.env.DSH_REMOTE_NOTES || path.join(os.homedir(), '.dsh-remote', 'device-notes.json')
|
|
1573
1575
|
const DEVICE_KEYS_FILE = process.env.DSH_REMOTE_DEVICE_KEYS || path.join(os.homedir(), '.dsh-remote', 'device-keys.json')
|
|
@@ -5418,6 +5420,7 @@ async function serveAdminApi(req, res, url) {
|
|
|
5418
5420
|
}
|
|
5419
5421
|
if (sub === '/relay') return serveRelaySettings(req, res, url)
|
|
5420
5422
|
if (sub === '/relay/e2ee') return serveRelayDevices(req, res, url)
|
|
5423
|
+
if (sub === '/relay/pair') return serveRelayPair(req, res, url)
|
|
5421
5424
|
if (sub === '/dsh') return serveDshControl(req, res, url)
|
|
5422
5425
|
if (sub === '/state' && req.method === 'GET') {
|
|
5423
5426
|
if (!adminAuthorized(req, url)) {
|
|
@@ -5648,7 +5651,7 @@ async function serveRelaySettings(req, res, url) {
|
|
|
5648
5651
|
if (!['GET', 'POST'].includes(req.method)) { res.setHeader('allow', 'GET, POST, OPTIONS'); return reply(405, { error: 'METHOD_NOT_ALLOWED' }) }
|
|
5649
5652
|
const canManage = adminAuthorized(req, url)
|
|
5650
5653
|
if (!canManage && !authorized(req, url)) return reply(401, { error: 'unauthorized' })
|
|
5651
|
-
if (req.method === 'GET') return reply(200, { ...relayHost.status(), canManage, canManageDevices: canManage && localRelayManagement(req) })
|
|
5654
|
+
if (req.method === 'GET') return reply(200, { ...relayHost.status(), canManage, canManageDevices: canManage && localRelayManagement(req), canPairLocally: localRelayPairing(req) })
|
|
5652
5655
|
if (!canManage) return reply(403, { error: 'RELAY_ADMIN_REQUIRED' })
|
|
5653
5656
|
try {
|
|
5654
5657
|
const chunks = []; let size = 0
|
|
@@ -5664,6 +5667,64 @@ async function serveRelaySettings(req, res, url) {
|
|
|
5664
5667
|
}
|
|
5665
5668
|
}
|
|
5666
5669
|
|
|
5670
|
+
function localRelayPairing(req) {
|
|
5671
|
+
// Pairing trust must come from a direct local connection, never the broker.
|
|
5672
|
+
const privateAddress = value => {
|
|
5673
|
+
const ip = String(value || '').replace(/^::ffff:/, '').replace(/^\[|\]$/g, '')
|
|
5674
|
+
if (net.isIP(ip) === 4) {
|
|
5675
|
+
const [a,b] = ip.split('.').map(Number)
|
|
5676
|
+
return a === 10 || a === 127 || a === 192 && b === 168 || a === 172 && b >= 16 && b <= 31
|
|
5677
|
+
}
|
|
5678
|
+
return net.isIP(ip) === 6 && (ip === '::1' || /^(?:fc|fd|fe[89ab])/i.test(ip))
|
|
5679
|
+
}
|
|
5680
|
+
if (!privateAddress(req.socket.remoteAddress) || relayHost.isRelayRequest(req)) return false
|
|
5681
|
+
if (['forwarded','x-forwarded-for','x-forwarded-host','x-real-ip'].some(key => req.headers[key])) return false
|
|
5682
|
+
try {
|
|
5683
|
+
const host = new URL('http://' + req.headers.host)
|
|
5684
|
+
return (host.hostname === 'localhost' || privateAddress(host.hostname)) && Number(host.port || 80) === req.socket.localPort
|
|
5685
|
+
} catch { return false }
|
|
5686
|
+
}
|
|
5687
|
+
function appendPairingLog(entry) {
|
|
5688
|
+
try {
|
|
5689
|
+
const line = JSON.stringify({ at: new Date().toISOString(), ...entry }) + '\n'
|
|
5690
|
+
fs.mkdirSync(path.dirname(PAIRING_LOG_FILE), { recursive: true, mode: 0o700 })
|
|
5691
|
+
try {
|
|
5692
|
+
if (fs.statSync(PAIRING_LOG_FILE).size + Buffer.byteLength(line) > PAIRING_LOG_LIMIT_BYTES) {
|
|
5693
|
+
try { fs.rmSync(PAIRING_LOG_FILE + '.1', { force: true }) } catch {}
|
|
5694
|
+
fs.renameSync(PAIRING_LOG_FILE, PAIRING_LOG_FILE + '.1')
|
|
5695
|
+
}
|
|
5696
|
+
} catch {}
|
|
5697
|
+
fs.appendFileSync(PAIRING_LOG_FILE, line, { mode: 0o600 })
|
|
5698
|
+
} catch {}
|
|
5699
|
+
}
|
|
5700
|
+
async function serveRelayPair(req, res, url) {
|
|
5701
|
+
cors(res)
|
|
5702
|
+
const started = Date.now(), source = String(req.socket.remoteAddress || ''), hostHeader = String(req.headers.host || '')
|
|
5703
|
+
const pairLog = (event, detail = {}) => appendPairingLog({ event, source, host: hostHeader, method: req.method, ms: Date.now() - started, ...detail })
|
|
5704
|
+
const reply = (status, value) => { res.writeHead(status, {'content-type':'application/json; charset=utf-8','cache-control':'no-store'}); res.end(JSON.stringify(value)) }
|
|
5705
|
+
if (!localRelayPairing(req)) { pairLog('pair.denied', { reason: 'local-only' }); return reply(403,{error:'LOCAL_PAIRING_REQUIRED'}) }
|
|
5706
|
+
if (req.method === 'OPTIONS') {res.writeHead(204);return res.end()}
|
|
5707
|
+
if (!/^Bearer \S+$/i.test(req.headers.authorization || '') || !adminAuthorized(req,url) && !authorized(req,url)) { pairLog('pair.denied', { reason: 'unauthorized' }); return reply(401,{error:'unauthorized'}) }
|
|
5708
|
+
if (req.method !== 'POST') { pairLog('pair.denied', { reason: 'method' }); return reply(405,{error:'METHOD_NOT_ALLOWED'}) }
|
|
5709
|
+
if (!String(req.headers['content-type'] || '').toLowerCase().startsWith('application/json')) { pairLog('pair.denied', { reason: 'content-type' }); return reply(415,{error:'JSON_REQUIRED'}) }
|
|
5710
|
+
pairLog('pair.attempt')
|
|
5711
|
+
try {
|
|
5712
|
+
const chunks=[]; let size=0
|
|
5713
|
+
for await (const chunk of req) {size+=chunk.length;if(size>1024){pairLog('pair.rejected',{code:'BODY_TOO_LARGE'});return reply(413,{error:'BODY_TOO_LARGE'})};chunks.push(chunk)}
|
|
5714
|
+
let value
|
|
5715
|
+
try {value=JSON.parse(Buffer.concat(chunks).toString('utf8'))}catch{pairLog('pair.rejected',{code:'INVALID_JSON'});return reply(400,{error:'INVALID_JSON'})}
|
|
5716
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(key=>!['fingerprint','label'].includes(key))) { pairLog('pair.rejected',{code:'INVALID_DEVICE'}); return reply(400,{error:'INVALID_DEVICE'}) }
|
|
5717
|
+
if (!relayHost.e2eeEnabled || !relayHost.endpoint) { pairLog('pair.rejected',{code:'E2EE_NOT_CONFIGURED'}); return reply(409,{error:'E2EE_NOT_CONFIGURED'}) }
|
|
5718
|
+
if (value.fingerprint !== relayHost.e2eeFingerprint) { pairLog('pair.rejected',{code:'E2EE_PAIRING_CHANGED'}); return reply(409,{error:'E2EE_PAIRING_CHANGED'}) }
|
|
5719
|
+
const result=await relayHost.changeDevice({action:'create-device',label:value.label,days:30})
|
|
5720
|
+
pairLog('pair.created', { deviceId: String(result?.pairing?.deviceId || '').slice(0, 64), expiresAt: Number(result?.pairing?.expiresAt) || 0, label: String(value.label || '').slice(0, 80), relayPhase: String(relayHost.phase || '') })
|
|
5721
|
+
return reply(200,{pairing:result.pairing})
|
|
5722
|
+
} catch(error) {
|
|
5723
|
+
const known=new Set(['INVALID_DEVICE','E2EE_DEVICE_LIMIT','RELAY_OPERATION_BUSY','E2EE_NOT_CONFIGURED','HOST_NOT_CONFIGURED'])
|
|
5724
|
+
pairLog('pair.failed', { code: String(error?.code || 'E2EE_OPERATION_FAILED'), httpStatus: Number(error?.status) || 503 })
|
|
5725
|
+
return reply(error.status||503,{error:known.has(error.code)?error.code:'E2EE_OPERATION_FAILED'})
|
|
5726
|
+
}
|
|
5727
|
+
}
|
|
5667
5728
|
function localRelayManagement(req) {
|
|
5668
5729
|
if (!['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(req.socket.remoteAddress) || relayHost.isRelayRequest(req)) return false
|
|
5669
5730
|
try {
|
|
@@ -7647,6 +7708,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
7647
7708
|
if (url.pathname === '/api/file-inbox' || url.pathname.startsWith('/api/file-inbox/') || url.pathname === '/fs/inbox-file' || url.pathname === '/admin/api/file-inbox') return await serveFileInbox(req, res, url)
|
|
7648
7709
|
if (url.pathname === '/relay') return await serveRelaySettings(req, res, url)
|
|
7649
7710
|
if (url.pathname === '/relay/e2ee') return await serveRelayDevices(req, res, url)
|
|
7711
|
+
if (url.pathname === '/relay/pair') return await serveRelayPair(req, res, url)
|
|
7650
7712
|
if (url.pathname === '/fs' || url.pathname.startsWith('/fs/')) return await serveFs(req, res, url)
|
|
7651
7713
|
if (url.pathname === '/workbench' || url.pathname.startsWith('/workbench/')) return serveWorkbench(req, res, url)
|
|
7652
7714
|
if (url.pathname === '/diagnostics') return serveDiagnostics(req, res, url)
|
package/package.json
CHANGED
package/public/admin.html
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="zh-CN">
|
|
3
3
|
<head>
|
|
4
|
-
<meta name="dsh-remote-build" content="
|
|
4
|
+
<meta name="dsh-remote-build" content="7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
5
5
|
<meta charset="utf-8">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
7
7
|
<meta name="theme-color" content="#0D1117">
|
|
8
8
|
<title>DSH Remote · 管理</title>
|
|
9
9
|
<script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'&&t!=='penguin'&&t!=='penguin-night'&&t!=='bocchi'&&t!=='nijika'&&t!=='ryo'&&t!=='kita'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
10
|
-
<link rel="stylesheet" href="../styles.css?dsr-build=
|
|
11
|
-
<link rel="stylesheet" href="../relay-settings.css?dsr-build=
|
|
12
|
-
<link rel="stylesheet" href="../insights.css?dsr-build=
|
|
13
|
-
<link rel="stylesheet" href="../setup.css?dsr-build=
|
|
14
|
-
<link rel="stylesheet" href="../doctor.css?dsr-build=
|
|
15
|
-
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=
|
|
16
|
-
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=
|
|
17
|
-
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=
|
|
18
|
-
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=
|
|
19
|
-
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=
|
|
20
|
-
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=
|
|
21
|
-
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=
|
|
10
|
+
<link rel="stylesheet" href="../styles.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
11
|
+
<link rel="stylesheet" href="../relay-settings.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
12
|
+
<link rel="stylesheet" href="../insights.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
13
|
+
<link rel="stylesheet" href="../setup.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
14
|
+
<link rel="stylesheet" href="../doctor.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
15
|
+
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
16
|
+
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
17
|
+
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
18
|
+
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
19
|
+
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
20
|
+
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
21
|
+
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
22
22
|
<style>
|
|
23
23
|
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 40px; }
|
|
24
24
|
.admin-title {
|
|
@@ -348,8 +348,8 @@
|
|
|
348
348
|
.admin-title .left { gap: 7px; }
|
|
349
349
|
}
|
|
350
350
|
</style>
|
|
351
|
-
<link rel="stylesheet" href="../remote-ui.css?dsr-build=
|
|
352
|
-
<link rel="stylesheet" href="../theme-picker.css?dsr-build=
|
|
351
|
+
<link rel="stylesheet" href="../remote-ui.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
352
|
+
<link rel="stylesheet" href="../theme-picker.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
353
353
|
</head>
|
|
354
354
|
<body>
|
|
355
355
|
<div class="admin-wrap">
|
|
@@ -801,20 +801,20 @@
|
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
</script>
|
|
804
|
-
<script src="../setup.js?dsr-build=
|
|
805
|
-
<script src="../qrcode.min.js?dsr-build=
|
|
806
|
-
<script src="../i18n.js?dsr-build=
|
|
807
|
-
<script src="../theme.js?dsr-build=
|
|
808
|
-
<script src="../vendor/gsap/gsap.min.js?dsr-build=
|
|
809
|
-
<script src="../motion.js?dsr-build=
|
|
810
|
-
<script src="../remote-state.js?dsr-build=
|
|
811
|
-
<script src="../remote-ui.js?dsr-build=
|
|
812
|
-
<script src="../admin.js?dsr-build=
|
|
813
|
-
<script src="../doctor.js?dsr-build=
|
|
814
|
-
<script src="../doctor-entry.js?dsr-build=
|
|
815
|
-
<script src="../sponsor-entry.js?dsr-build=
|
|
816
|
-
<script src="../relay-devices.js?dsr-build=
|
|
817
|
-
<script src="../relay-settings.js?dsr-build=
|
|
804
|
+
<script src="../setup.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
805
|
+
<script src="../qrcode.min.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
806
|
+
<script src="../i18n.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
807
|
+
<script src="../theme.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
808
|
+
<script src="../vendor/gsap/gsap.min.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
809
|
+
<script src="../motion.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
810
|
+
<script src="../remote-state.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
811
|
+
<script src="../remote-ui.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
812
|
+
<script src="../admin.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
813
|
+
<script src="../doctor.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
814
|
+
<script src="../doctor-entry.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
815
|
+
<script src="../sponsor-entry.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
816
|
+
<script src="../relay-devices.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
817
|
+
<script src="../relay-settings.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
818
818
|
<script>window.mountAdminRelaySettings?.()</script>
|
|
819
819
|
</body>
|
|
820
820
|
</html>
|
package/public/app.js
CHANGED
|
@@ -491,6 +491,22 @@ function fmtFullTime(ts) {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
/* ---------------- API ---------------- */
|
|
494
|
+
function saveAutoPairedRelay(origin, connection) {
|
|
495
|
+
if (!connection.valid()) return
|
|
496
|
+
const token=connection.headers.authorization.slice(7)
|
|
497
|
+
if (state.servers.some(s=>s.url===origin&&serverToken(s)===token&&s.group===state.activeGroup)) return
|
|
498
|
+
state.servers.push({id:newServerId(),url:origin,note:I18N.lang==='en'?'Cloud relay':'公网中转',group:state.activeGroup,token})
|
|
499
|
+
saveServers();renderServers();syncBgConfig()
|
|
500
|
+
toast(I18N.lang==='en'?'Relay pairing configured. LAN remains connected.':'公网配对已配置,局域网连接保留。','ok')
|
|
501
|
+
}
|
|
502
|
+
function offerLocalRelayPairing(connection=captureConnection(), force=false) {
|
|
503
|
+
if (!connection.token || !connection.valid()) return
|
|
504
|
+
return window.DshRelayAutoPair?.offer({
|
|
505
|
+
connection:()=>({valid:connection.valid,url:path=>connection.server+path,headers:{authorization:'Bearer '+connection.token}}),
|
|
506
|
+
onPaired:saveAutoPairedRelay,force,
|
|
507
|
+
onStatus:(message,error)=>{if(force&&error&&connection.valid())toast(message,'err')},
|
|
508
|
+
})
|
|
509
|
+
}
|
|
494
510
|
function apiUrl(path) {
|
|
495
511
|
return (state.server || '') + path
|
|
496
512
|
}
|
|
@@ -661,6 +677,7 @@ async function refreshHostDescription({ notify = false } = {}) {
|
|
|
661
677
|
const desc = $('host-desc')
|
|
662
678
|
if (desc && host) desc.textContent = hostDescriptionText(host)
|
|
663
679
|
renderOverview()
|
|
680
|
+
void offerLocalRelayPairing(connection)
|
|
664
681
|
return host
|
|
665
682
|
} catch (error) {
|
|
666
683
|
if (!connection.valid()) return null
|
|
@@ -8392,6 +8409,7 @@ function mountWorkflow() {
|
|
|
8392
8409
|
command: runSlashCommand, refresh: refreshAll, retry: () => { startOverviewDetection(true); void refreshAll() },
|
|
8393
8410
|
operations: () => { const connection=captureConnection(); return { url:apiUrl,headers:{authorization:'Bearer '+connection.token},valid:connection.valid } },
|
|
8394
8411
|
relay: () => { const connection=captureConnection(); return { url:()=>adminApiUrl('/admin/api/relay'),headers:{authorization:'Bearer '+connection.token},valid:connection.valid,connected:!!connection.token } },
|
|
8412
|
+
e2eeAutoPaired: saveAutoPairedRelay,
|
|
8395
8413
|
e2eeConnect: (origin, connection) => {
|
|
8396
8414
|
if (!connection.valid()) return
|
|
8397
8415
|
const token = connection.headers.authorization.slice(7)
|
package/public/build.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="zh-CN">
|
|
3
3
|
<head>
|
|
4
|
-
<meta name="dsh-remote-build" content="
|
|
4
|
+
<meta name="dsh-remote-build" content="7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
5
5
|
<meta charset="utf-8">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
7
|
<title>DSH Remote · 桌面</title>
|
|
8
8
|
<script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'&&t!=='penguin'&&t!=='penguin-night'&&t!=='bocchi'&&t!=='nijika'&&t!=='ryo'&&t!=='kita'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
9
|
-
<link rel="stylesheet" href="../theme-vars.css?dsr-build=
|
|
10
|
-
<link rel="stylesheet" href="desktop.css?dsr-build=
|
|
11
|
-
<link rel="stylesheet" href="../plugin-center.css?dsr-build=
|
|
12
|
-
<link rel="stylesheet" href="../skills.css?dsr-build=
|
|
13
|
-
<link rel="stylesheet" href="../doctor.css?dsr-build=
|
|
14
|
-
<link rel="stylesheet" href="../extensions.css?dsr-build=
|
|
15
|
-
<link rel="stylesheet" href="../insights.css?dsr-build=
|
|
16
|
-
<link rel="stylesheet" href="../workflow.css?dsr-build=
|
|
17
|
-
<link rel="stylesheet" href="../relay-settings.css?dsr-build=
|
|
18
|
-
<link rel="stylesheet" href="../subagents.css?dsr-build=
|
|
19
|
-
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=
|
|
20
|
-
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=
|
|
21
|
-
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=
|
|
22
|
-
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=
|
|
23
|
-
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=
|
|
24
|
-
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=
|
|
25
|
-
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=
|
|
26
|
-
<link rel="stylesheet" href="../theme-picker.css?dsr-build=
|
|
9
|
+
<link rel="stylesheet" href="../theme-vars.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
10
|
+
<link rel="stylesheet" href="desktop.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
11
|
+
<link rel="stylesheet" href="../plugin-center.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
12
|
+
<link rel="stylesheet" href="../skills.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
13
|
+
<link rel="stylesheet" href="../doctor.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
14
|
+
<link rel="stylesheet" href="../extensions.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
15
|
+
<link rel="stylesheet" href="../insights.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
16
|
+
<link rel="stylesheet" href="../workflow.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
17
|
+
<link rel="stylesheet" href="../relay-settings.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
18
|
+
<link rel="stylesheet" href="../subagents.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
19
|
+
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
20
|
+
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
21
|
+
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
22
|
+
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
23
|
+
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
24
|
+
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
25
|
+
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
26
|
+
<link rel="stylesheet" href="../theme-picker.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<div class="ds-app" id="ds-app">
|
|
@@ -822,48 +822,48 @@
|
|
|
822
822
|
</div>
|
|
823
823
|
<div class="image-lightbox-hint" data-image-lightbox-hint>双击放大 · 点空白处关闭</div>
|
|
824
824
|
</div>
|
|
825
|
-
<script src="i18n.js?dsr-build=
|
|
826
|
-
<link rel="stylesheet" href="../genui.css?dsr-build=
|
|
827
|
-
<script src="../genui.js?dsr-build=
|
|
828
|
-
<script src="../chat-files.js?dsr-build=
|
|
829
|
-
<script src="../md.js?dsr-build=
|
|
830
|
-
<script src="../vendor/gsap/gsap.min.js?dsr-build=
|
|
831
|
-
<script src="../motion.js?dsr-build=
|
|
832
|
-
<script type="module" src="../morphicons-init.js?dsr-build=
|
|
833
|
-
<script src="../plugin-center.js?dsr-build=
|
|
834
|
-
<script src="../skills.js?dsr-build=
|
|
835
|
-
<script src="../insights.js?dsr-build=
|
|
836
|
-
<script src="../teams.js?dsr-build=
|
|
837
|
-
<script src="../task-board.js?dsr-build=
|
|
838
|
-
<script src="../extensions.js?dsr-build=
|
|
839
|
-
<script src="../sha256.js?dsr-build=
|
|
840
|
-
<script src="../diagnostics.js?dsr-build=
|
|
841
|
-
<script src="../doctor.js?dsr-build=
|
|
842
|
-
<script src="../history.js?dsr-build=
|
|
843
|
-
<script src="../activity.js?dsr-build=
|
|
844
|
-
<script src="../turn-results.js?dsr-build=
|
|
845
|
-
<script src="../image-cache.js?dsr-build=
|
|
846
|
-
<script src="../chat-copy.js?dsr-build=
|
|
847
|
-
<script src="../image-preview.js?dsr-build=
|
|
848
|
-
<script src="../link-check.js?dsr-build=
|
|
849
|
-
<script src="../network.js?dsr-build=
|
|
850
|
-
<script src="../operations.js?dsr-build=
|
|
851
|
-
<script src="../workflow.js?dsr-build=
|
|
852
|
-
<script src="../sponsor-entry.js?dsr-build=
|
|
853
|
-
<script src="../relay-devices.js?dsr-build=
|
|
854
|
-
<script src="../relay-settings.js?dsr-build=
|
|
855
|
-
<script src="../subagents.js?dsr-build=
|
|
856
|
-
<script src="../session-presets.js?dsr-build=
|
|
857
|
-
<script src="../permission-presets.js?dsr-build=
|
|
858
|
-
<script src="../approval-records.js?dsr-build=
|
|
859
|
-
<script src="../approval-summary.js?dsr-build=
|
|
860
|
-
<script src="../doctor-entry.js?dsr-build=
|
|
861
|
-
<link rel="stylesheet" href="../file-inbox.css?dsr-build=
|
|
862
|
-
<script src="../file-inbox.js?dsr-build=
|
|
863
|
-
<link rel="stylesheet" href="../session-deck.css?dsr-build=
|
|
864
|
-
<script src="../session-deck.js?dsr-build=
|
|
865
|
-
<script src="../theme.js?dsr-build=
|
|
866
|
-
<script src="../cache-upgrade.js?dsr-build=
|
|
867
|
-
<script src="desktop.js?dsr-build=
|
|
825
|
+
<script src="i18n.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
826
|
+
<link rel="stylesheet" href="../genui.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
827
|
+
<script src="../genui.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
828
|
+
<script src="../chat-files.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
829
|
+
<script src="../md.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
830
|
+
<script src="../vendor/gsap/gsap.min.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
831
|
+
<script src="../motion.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
832
|
+
<script type="module" src="../morphicons-init.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
833
|
+
<script src="../plugin-center.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
834
|
+
<script src="../skills.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
835
|
+
<script src="../insights.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
836
|
+
<script src="../teams.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
837
|
+
<script src="../task-board.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
838
|
+
<script src="../extensions.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
839
|
+
<script src="../sha256.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
840
|
+
<script src="../diagnostics.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
841
|
+
<script src="../doctor.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
842
|
+
<script src="../history.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
843
|
+
<script src="../activity.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
844
|
+
<script src="../turn-results.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
845
|
+
<script src="../image-cache.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
846
|
+
<script src="../chat-copy.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
847
|
+
<script src="../image-preview.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
848
|
+
<script src="../link-check.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
849
|
+
<script src="../network.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
850
|
+
<script src="../operations.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
851
|
+
<script src="../workflow.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
852
|
+
<script src="../sponsor-entry.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
853
|
+
<script src="../relay-devices.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
854
|
+
<script src="../relay-settings.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
855
|
+
<script src="../subagents.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
856
|
+
<script src="../session-presets.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
857
|
+
<script src="../permission-presets.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
858
|
+
<script src="../approval-records.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
859
|
+
<script src="../approval-summary.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
860
|
+
<script src="../doctor-entry.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
861
|
+
<link rel="stylesheet" href="../file-inbox.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
862
|
+
<script src="../file-inbox.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
863
|
+
<link rel="stylesheet" href="../session-deck.css?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623">
|
|
864
|
+
<script src="../session-deck.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
865
|
+
<script src="../theme.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
866
|
+
<script src="../cache-upgrade.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
867
|
+
<script src="desktop.js?dsr-build=7006a2673f19f69788f5c533fbcf9ca1f077d0b4f3b92f4eb3b000ed4ee85623"></script>
|
|
868
868
|
</body>
|
|
869
869
|
</html>
|
package/public/e2ee-transport.js
CHANGED
|
@@ -60,24 +60,72 @@
|
|
|
60
60
|
const anchor = event.target?.closest?.('a[href]')
|
|
61
61
|
if (anchor && !externalAllowed(anchor.href)) { event.preventDefault(); event.stopImmediatePropagation(); externalNotice() }
|
|
62
62
|
}, true)
|
|
63
|
-
root.DshE2eeTransport = { resolve, mount(target, { connection, onConnect, onModeChange } = {}) {
|
|
63
|
+
root.DshE2eeTransport = { resolve, mount(target, { connection, onConnect, onModeChange, onAutoPaired } = {}) {
|
|
64
64
|
if (!target || target.dataset.e2eeMounted) return
|
|
65
65
|
target.dataset.e2eeMounted = 'true'
|
|
66
66
|
const en = () => root.I18N?.lang === 'en', text = (zh, english) => en() ? english : zh
|
|
67
67
|
const title = document.createElement('h3'), explanation = document.createElement('p'), button = document.createElement('button'), status = document.createElement('p')
|
|
68
68
|
const file = document.createElement('input'); file.type = 'file'; file.accept = '.json,application/json'; file.hidden = true
|
|
69
|
+
const autoPair = document.createElement('button'); autoPair.type = 'button'
|
|
70
|
+
autoPair.textContent = text('通过当前局域网连接自动配对', 'Pair automatically over the current LAN connection')
|
|
71
|
+
const logBox = document.createElement('details'), logSummary = document.createElement('summary')
|
|
72
|
+
const logPre = document.createElement('pre'), logActions = document.createElement('div'), logHint = document.createElement('p')
|
|
73
|
+
const logCopy = document.createElement('button'), logRefresh = document.createElement('button'), logClear = document.createElement('button')
|
|
74
|
+
logBox.className = 'relay-pair-log'; logSummary.textContent = text('配对日志(可复制反馈)', 'Pairing log (copy for support)')
|
|
75
|
+
logPre.className = 'relay-pair-log-text'; logPre.setAttribute('aria-live', 'polite')
|
|
76
|
+
logActions.className = 'relay-pair-log-actions'; logHint.className = 'relay-pair-log-hint'; logHint.setAttribute('role', 'status')
|
|
77
|
+
logCopy.type = 'button'; logCopy.textContent = text('复制日志', 'Copy log')
|
|
78
|
+
logRefresh.type = 'button'; logRefresh.textContent = text('刷新', 'Refresh')
|
|
79
|
+
logClear.type = 'button'; logClear.textContent = text('清空', 'Clear')
|
|
80
|
+
function renderLog() {
|
|
81
|
+
try {
|
|
82
|
+
const value = root.DshRelayAutoPair?.logText?.() || ''
|
|
83
|
+
logPre.textContent = value || text('暂无配对记录。', 'No pairing records yet.')
|
|
84
|
+
} catch { logPre.textContent = text('日志读取失败。', 'Could not read the log.') }
|
|
85
|
+
}
|
|
86
|
+
async function copyLog() {
|
|
87
|
+
const value = root.DshRelayAutoPair?.logText?.() || ''
|
|
88
|
+
let ok = false
|
|
89
|
+
try { if (root.navigator?.clipboard?.writeText) { await root.navigator.clipboard.writeText(value); ok = true } } catch {}
|
|
90
|
+
if (!ok) {
|
|
91
|
+
try {
|
|
92
|
+
const area = root.document.createElement('textarea')
|
|
93
|
+
area.value = value; area.setAttribute('readonly', ''); area.style.position = 'fixed'; area.style.top = '-1000px'
|
|
94
|
+
root.document.body.append(area); area.select(); ok = root.document.execCommand?.('copy') === true; area.remove()
|
|
95
|
+
} catch { ok = false }
|
|
96
|
+
}
|
|
97
|
+
logHint.textContent = ok ? text('已复制配对日志。', 'Pairing log copied.') : text('复制失败,请展开日志后手动选择复制。', 'Copy failed. Expand the log and copy it manually.')
|
|
98
|
+
}
|
|
99
|
+
logCopy.addEventListener('click', () => void copyLog())
|
|
100
|
+
logRefresh.addEventListener('click', renderLog)
|
|
101
|
+
logClear.addEventListener('click', () => { root.DshRelayAutoPair?.clearLog?.(); renderLog(); logHint.textContent = text('已清空配对日志。', 'Pairing log cleared.') })
|
|
102
|
+
logActions.append(logCopy, logRefresh, logClear); logBox.append(logSummary, logPre, logActions, logHint)
|
|
103
|
+
autoPair.addEventListener('click', () => {
|
|
104
|
+
const ctx = connection()
|
|
105
|
+
if (!root.DshRelayAutoPair?.localUrl(ctx.url('/relay'))) {
|
|
106
|
+
status.textContent = text('请先连接自己电脑的局域网地址,再配置公网配对。', 'Connect to your computer’s LAN address first, then configure relay pairing.')
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
renderLog()
|
|
110
|
+
void root.DshRelayAutoPair.offer({ connection, onPaired: onAutoPaired, force: true, onStatus: (value, error) => {
|
|
111
|
+
status.textContent = value
|
|
112
|
+
if (error) logBox.open = true
|
|
113
|
+
renderLog(); renderMode()
|
|
114
|
+
} })
|
|
115
|
+
})
|
|
69
116
|
const modeLabel = document.createElement('label'), modeSwitch = document.createElement('input'), modeText = document.createElement('span'), modeStatus = document.createElement('p')
|
|
70
117
|
modeLabel.className = 'relay-encryption-switch'; modeSwitch.type = 'checkbox'; modeSwitch.checked = true; modeSwitch.dataset.e2eeToggle = 'true'
|
|
71
118
|
modeText.textContent = text('端到端加密(默认开启)', 'End-to-end encryption (on by default)'); modeLabel.append(modeSwitch, modeText)
|
|
72
119
|
modeStatus.setAttribute('role', 'status'); modeStatus.className = 'relay-encryption-status'
|
|
73
120
|
title.textContent = text('端到端加密配对(试验)', 'End-to-end pairing (experimental)')
|
|
74
|
-
explanation.textContent = text('
|
|
121
|
+
explanation.textContent = text('先连接自己电脑的局域网地址,即可确认并自动配置这台手机的公网配对,无需传文件;也可手动导入。端到端加密默认开启,关闭前必须确认风险,连接失败不会自动切换模式。', 'Connect to your computer’s LAN address to confirm and automatically configure this phone’s relay pairing, without transferring files. Manual import is also available. Encryption defaults on; disabling requires confirmation and connection failures never change the mode.')
|
|
75
122
|
button.type = 'button'; button.textContent = text('导入本机配对文件', 'Import local pairing file')
|
|
76
|
-
status.setAttribute('role', 'status'); target.append(title, explanation, modeLabel, modeStatus, button, file, status)
|
|
123
|
+
status.setAttribute('role', 'status'); target.append(title, explanation, modeLabel, modeStatus, autoPair, button, file, status, logBox)
|
|
77
124
|
let selectedOrigin = '', identity = ''
|
|
78
125
|
function modeContext() {
|
|
79
126
|
const ctx = connection(), key = JSON.stringify([ctx.url('/relay'),ctx.headers?.authorization||''])
|
|
80
127
|
if (key !== identity) { identity = key; selectedOrigin = new URL(ctx.url('/relay'),root.location.href).origin }
|
|
128
|
+
selectedOrigin = root.DshRelayAutoPair?.pairedOrigin(ctx.url('/relay')) || selectedOrigin
|
|
81
129
|
return ctx
|
|
82
130
|
}
|
|
83
131
|
function renderMode() {
|
|
@@ -106,7 +154,7 @@
|
|
|
106
154
|
status.textContent = requested ? text('已开启;连接失败时不会自动降级。','Enabled. Connection failures never trigger fallback.') : text('已关闭端到端加密,HTTPS 仍保留。','End-to-end encryption disabled; HTTPS remains.')
|
|
107
155
|
} catch { renderMode(); status.textContent = text('模式未能切换,原设置保留。开启失败时请检查系统和证书,不能跳过校验。','Mode change failed; the previous setting is kept. Check system support and the certificate; verification cannot be skipped.') }
|
|
108
156
|
})
|
|
109
|
-
root.setInterval?.(renderMode, 1000); renderMode()
|
|
157
|
+
root.setInterval?.(renderMode, 1000); renderMode(); renderLog()
|
|
110
158
|
if (bridge.supported?.() === false) status.textContent = text('此系统不支持 TLS 1.3,加密模式无法连接。可升级系统;若选择关闭,须先确认风险。','This system lacks TLS 1.3. Upgrade Android, or explicitly acknowledge the risks before disabling encryption.')
|
|
111
159
|
button.addEventListener('click', () => file.click())
|
|
112
160
|
file.addEventListener('change', async () => {
|