dsh-remote-plugin 0.8.7 → 0.9.0
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/README.en.md +16 -5
- package/README.md +15 -4
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +659 -130
- package/index.mjs +33 -1
- package/package.json +8 -3
- package/public/activity.js +196 -52
- package/public/admin.html +34 -32
- package/public/admin.js +11 -2
- package/public/app.js +1341 -223
- package/public/bc-integration.css +81 -0
- package/public/build.json +2 -2
- package/public/composer-tools.css +184 -0
- package/public/composer-tools.js +888 -0
- package/public/desktop/desktop.html +104 -76
- package/public/desktop/desktop.js +668 -101
- package/public/diagnostics.js +30 -4
- package/public/e2ee-transport.js +154 -7
- package/public/file-inbox.js +77 -18
- package/public/genui.css +10 -0
- package/public/genui.js +22 -4
- package/public/history.js +15 -2
- package/public/host-queue.js +232 -0
- package/public/host-schedule.js +301 -0
- package/public/host-state.css +19 -0
- package/public/index.html +347 -140
- package/public/md.js +21 -1
- package/public/network.js +33 -1
- package/public/onboarding.js +3 -3
- package/public/operations.js +26 -12
- package/public/plan-review.css +297 -0
- package/public/plan-review.js +621 -0
- package/public/plugin.html +29 -27
- package/public/relay-autopair.js +25 -10
- package/public/relay-settings.css +11 -0
- package/public/relay-settings.js +350 -28
- package/public/session-management.css +61 -0
- package/public/session-management.js +742 -0
- package/public/session-search.css +137 -0
- package/public/session-search.js +977 -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/miku/SOURCES.json +10 -0
- package/public/skins/miku/chibi.png +0 -0
- package/public/skins/miku/preview.html +33 -0
- package/public/skins/miku/skin.css +82 -0
- package/public/skins/nijika/preview.html +6 -6
- package/public/skins/penguin/preview.html +3 -3
- package/public/skins/penguin-logistics/cargo.svg +4 -0
- package/public/skins/penguin-logistics/console.svg +4 -0
- package/public/skins/penguin-logistics/mark.svg +4 -0
- package/public/skins/penguin-logistics/radio.svg +4 -0
- package/public/skins/penguin-logistics/skin.css +292 -0
- package/public/skins/penguin-logistics/standing.png +0 -0
- package/public/skins/ryo/preview.html +6 -6
- package/public/slash-suggestions.css +43 -0
- package/public/slash-suggestions.js +196 -0
- package/public/sponsor-entry.js +11 -3
- package/public/styles.css +141 -21
- package/public/subagents.css +7 -0
- package/public/subagents.js +83 -10
- package/public/theme-vars.css +102 -3
- package/public/theme.js +7 -4
- package/public/turn-diff.css +323 -0
- package/public/turn-diff.js +778 -0
- package/public/update.json +12 -12
- package/public/version.json +1 -1
- package/public/workflow.css +322 -43
- package/public/workflow.js +148 -44
package/public/relay-settings.js
CHANGED
|
@@ -13,23 +13,85 @@
|
|
|
13
13
|
unauthorized:['请先连接主机,再设置云服务器中转。','Connect to your host before configuring its relay.'],
|
|
14
14
|
INVALID_RESPONSE:['主机返回了无法识别的中转状态,请检查连接地址和主机 Remote 版本。','Unrecognized relay response. Check the host URL and Remote version.'],
|
|
15
15
|
UNSUPPORTED_GATEWAY:['此主机尚不支持云中转设置,请更新主机 Remote。','Update the host Remote to use cloud relay settings.'],
|
|
16
|
+
INVALID_ACTIVATION_FILE:['请选择办理页生成的中转激活文件。','Select an activation file from the relay portal.'],
|
|
17
|
+
ACTIVATION_FILE_EXPIRED:['激活文件已过期。可重新下载,或在办理页领取密钥手动配置。','The activation file expired. Download a new one or claim the key for manual setup.'],
|
|
18
|
+
LOCAL_PAIRING_REQUIRED:['请连接主机的局域网地址,或在主机本机管理页导入。','Connect over the LAN or import on the host’s local management page.'],
|
|
19
|
+
RELAY_ACTIVATION_PENDING:['主机已有待确认的导入。请先到电脑管理页处理。','An import is already waiting for confirmation on the host.'],
|
|
20
|
+
RELAY_ACTIVATION_NOT_PENDING:['这项导入已完成或超时,请刷新状态。','This import finished or timed out. Refresh the status.'],
|
|
21
|
+
HOST_ALREADY_CONFIGURED:['此主机已绑定其他中转资格。请核对主机或在管理页手动处理。','This host is bound to a different relay authorization. Check the host or configure it manually.'],
|
|
16
22
|
}
|
|
17
|
-
|
|
23
|
+
const registrationLabels={
|
|
24
|
+
idle:['登记状态未查询','Registration not checked'],loading:['正在查询登记进度…','Checking application status…'],
|
|
25
|
+
none:['本设备没有已保存的登记','No application saved on this device'],
|
|
26
|
+
unavailable:['暂时无法确认登记进度','Could not verify application status'],
|
|
27
|
+
draft:['已登记 · 待提交','Registered · Not submitted'],submitted:['已提交 · 等待审核','Submitted · In review'],
|
|
28
|
+
approved:['审核通过','Approved'],renewable:['审核通过 · 可续费','Approved · Renewal available'],
|
|
29
|
+
expired:['登记或资格已到期','Application or eligibility expired'],rejected:['审核未通过','Not approved'],revoked:['资格已撤销','Eligibility revoked']
|
|
30
|
+
}
|
|
31
|
+
function mount(target, { connection, path = '/relay', credentials, phonePairingCode, syncActivation, deviceManagement = true, service = false } = {}) {
|
|
18
32
|
if (!target || target.dataset.relayMounted) return
|
|
19
33
|
target.dataset.relayMounted='true';target.classList.add('relay-settings')
|
|
20
34
|
const heading=el('div','relay-heading'),title=el('h3'),badge=el('span','relay-badge')
|
|
21
35
|
heading.append(title,badge)
|
|
22
36
|
const intro=el('p','relay-muted'),status=el('p','relay-status');status.setAttribute('aria-live','polite')
|
|
23
|
-
const sponsor=el('div','relay-sponsor')
|
|
37
|
+
const sponsor=el('div','relay-sponsor')
|
|
38
|
+
const registration=el('section','relay-registration'),registrationTitle=el('h3'),registrationStatus=el('p','relay-status'),registrationHint=el('p','relay-muted')
|
|
39
|
+
registrationStatus.setAttribute('role','status')
|
|
40
|
+
const registrationActions=el('div','relay-actions'),registrationLink=el('a','mini-btn relay-primary'),registrationRecover=el('a','mini-btn'),registrationRefresh=el('button'),registrationInbox=el('button')
|
|
41
|
+
registrationLink.target='_blank';registrationLink.rel='noopener noreferrer';registrationRefresh.type='button'
|
|
42
|
+
registrationInbox.type='button';registrationInbox.hidden=true
|
|
43
|
+
registrationRecover.target='_blank';registrationRecover.rel='noopener noreferrer';registrationRecover.hidden=true
|
|
44
|
+
registrationActions.append(registrationLink,registrationRecover,registrationInbox,registrationRefresh);registration.append(registrationTitle,registrationActions,registrationStatus,registrationHint)
|
|
45
|
+
let hostConnected=false
|
|
46
|
+
const bridge=root.NativeBackground
|
|
47
|
+
const automaticKey='dsh-relay-automatic-checkout-v1'
|
|
48
|
+
const automaticSupported=service&&typeof bridge?.openCloudRelayAutomaticCheckout==='function'&&
|
|
49
|
+
typeof bridge.cloudRelayAutomaticActivation==='function'&&typeof bridge.refreshCloudRelayAutomaticActivation==='function'&&!!root.crypto?.subtle
|
|
50
|
+
let automaticCheckout=null, checkingAutomatic=false, nextAutomaticCheck=0
|
|
51
|
+
if(automaticSupported){try{automaticCheckout=JSON.parse(root.localStorage.getItem(automaticKey))}catch{}}
|
|
52
|
+
const checkRegistration=typeof bridge?.cloudRelayRegistration==='function'&&typeof bridge?.refreshCloudRelayRegistration==='function'
|
|
53
|
+
const checkInbox=typeof bridge?.cloudRelayUnreadMessages==='function'&&typeof bridge?.openCloudRelayInbox==='function'
|
|
54
|
+
registrationRefresh.addEventListener('click',()=>bridge.refreshCloudRelayRegistration())
|
|
55
|
+
registrationInbox.addEventListener('click',()=>bridge.openCloudRelayInbox())
|
|
56
|
+
registrationLink.addEventListener('click',event=>{
|
|
57
|
+
if(registrationLink.dataset.automatic==='true'){
|
|
58
|
+
event.preventDefault()
|
|
59
|
+
void openAutomaticCheckout()
|
|
60
|
+
}else if(root.DshSponsor?.openPortal())event.preventDefault()
|
|
61
|
+
})
|
|
62
|
+
registrationRecover.addEventListener('click',event=>{if(root.DshSponsor?.openPortal())event.preventDefault()})
|
|
24
63
|
const address=el('div','relay-address'),link=el('a'),copy=el('button');copy.type='button';link.target='_blank';link.rel='noopener noreferrer';address.append(link,copy)
|
|
25
64
|
const quota=el('div','relay-quota'),meter=el('progress'),usage=el('p'),reset=el('p','relay-muted');meter.max=100;quota.append(usage,meter,reset)
|
|
26
65
|
const plan=el('p','relay-muted'),binding=el('p','relay-muted'),form=el('form','relay-form'),keyLabel=el('label'),keyInput=el('input')
|
|
27
66
|
keyInput.type='password';keyInput.autocomplete='off';keyInput.spellcheck=false;keyInput.maxLength=128;keyInput.name='relay-key'
|
|
28
67
|
keyLabel.append(el('span'),keyInput)
|
|
29
68
|
const adminLabel=el('label'),adminInput=el('input');adminInput.type='password';adminInput.autocomplete='off';adminInput.name='relay-admin';adminLabel.append(el('span'),adminInput)
|
|
30
|
-
const submit=el('button','relay-primary');submit.type='submit';form.append(keyLabel
|
|
69
|
+
const submit=el('button','relay-primary');submit.type='submit';form.append(keyLabel)
|
|
70
|
+
if(!service)form.append(adminLabel)
|
|
71
|
+
form.append(submit)
|
|
31
72
|
const actions=el('div','relay-actions'),toggle=el('button'),refresh=el('button'),takeover=el('button');toggle.type=refresh.type=takeover.type='button';actions.append(takeover,toggle,refresh)
|
|
32
73
|
const hint=el('p','relay-muted'),notice=el('p','relay-notice');notice.setAttribute('role','status')
|
|
74
|
+
const activation = el('section', 'relay-activation')
|
|
75
|
+
const importButton = el('button', 'relay-primary', text('导入中转激活文件', 'Import relay activation file'))
|
|
76
|
+
const importFile = el('input')
|
|
77
|
+
importButton.type = 'button'; importFile.type = 'file'; importFile.name = 'relay-activation'
|
|
78
|
+
importFile.accept = '.json,application/json'; importFile.hidden = true
|
|
79
|
+
const activationNotice = el('p', 'relay-notice'); activationNotice.setAttribute('role', 'status')
|
|
80
|
+
const approve = el('button', 'relay-primary', text('确认并绑定', 'Approve and bind'))
|
|
81
|
+
const reject = el('button', '', text('拒绝导入', 'Reject import'))
|
|
82
|
+
const retrySync = el('button', '', text('重试配置此手机', 'Retry setup on this phone'))
|
|
83
|
+
const inboxOffer = el('div', 'relay-inbox-offer')
|
|
84
|
+
const inboxTarget = el('p', 'relay-muted')
|
|
85
|
+
const applyInbox = el('button', 'relay-primary', text('应用到此主机', 'Apply to this host'))
|
|
86
|
+
const dismissInbox = el('button', '', text('稍后配置', 'Set up later'))
|
|
87
|
+
applyInbox.type = dismissInbox.type = 'button'
|
|
88
|
+
const inboxActions = el('div', 'relay-actions')
|
|
89
|
+
inboxActions.append(applyInbox, dismissInbox)
|
|
90
|
+
inboxOffer.append(inboxTarget, inboxActions)
|
|
91
|
+
approve.type = reject.type = retrySync.type = 'button'
|
|
92
|
+
const activationActions = el('div', 'relay-actions')
|
|
93
|
+
activationActions.append(importButton, approve, reject, retrySync)
|
|
94
|
+
activation.append(inboxOffer, activationActions, importFile, activationNotice)
|
|
33
95
|
const phoneGuide=el('section','relay-pair-guide'),phoneTitle=el('h3'),phoneHint=el('p','relay-muted')
|
|
34
96
|
const showCode=el('button','relay-primary'),hideCode=el('button'),code=el('div','relay-phone-code'),phoneStatus=el('p','relay-pair-progress')
|
|
35
97
|
showCode.type=hideCode.type='button';phoneStatus.setAttribute('role','status')
|
|
@@ -39,10 +101,20 @@
|
|
|
39
101
|
hideCode.textContent=text('关闭连接码','Close connection code')
|
|
40
102
|
const recentPair=el('p','relay-muted')
|
|
41
103
|
phoneGuide.append(phoneTitle,phoneHint,showCode,hideCode,code,phoneStatus,recentPair)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
104
|
+
const hostPanel = service ? el('section', 'relay-host-panel') : target
|
|
105
|
+
hostPanel.append(heading,intro,status)
|
|
106
|
+
hostPanel.append(activation)
|
|
107
|
+
if(phonePairingCode)hostPanel.append(phoneGuide)
|
|
108
|
+
if(!service)hostPanel.append(sponsor)
|
|
109
|
+
const bindOptions=el('details','relay-bind-options')
|
|
110
|
+
const bindSummary=el('summary')
|
|
111
|
+
bindOptions.append(bindSummary,form)
|
|
112
|
+
if(service)hostPanel.append(plan,binding,quota,address,bindOptions)
|
|
113
|
+
else hostPanel.append(address,plan,quota,binding,bindOptions)
|
|
114
|
+
if(service){adminLabel.className='relay-operation-auth';hostPanel.append(adminLabel)}
|
|
115
|
+
hostPanel.append(actions,hint,notice)
|
|
116
|
+
if(service)target.append(registration,hostPanel)
|
|
117
|
+
const deviceTarget=el('div','relay-device-panel')
|
|
46
118
|
if(deviceManagement)target.append(deviceTarget)
|
|
47
119
|
const devices=deviceManagement?root.DshRelayDevices?.mount(deviceTarget,{connection,path:path+'/e2ee',credentials}):null
|
|
48
120
|
let activeSetup='',pendingSetup=''
|
|
@@ -71,11 +143,14 @@
|
|
|
71
143
|
}finally{if(current(ctx)&&pendingSetup===setup){pendingSetup='';showCode.disabled=!!activeSetup}}
|
|
72
144
|
})
|
|
73
145
|
let identity='',value=null,lastRead=0,busy=false,loading=false,controller=null,destroyed=false,readError=false,failures=0
|
|
146
|
+
let importReading=false, awaitingActivation='', syncedActivation='', syncing=false, activationMessage='', inboxActivation=null, automaticBinding=false
|
|
74
147
|
function context() { const ctx=connection();return { ...ctx, endpoint:ctx.url(path) } }
|
|
75
148
|
function current(ctx) { return !destroyed && ctx.valid() && identity===JSON.stringify([ctx.endpoint,ctx.headers?.authorization||'']) }
|
|
76
149
|
function syncIdentity() {
|
|
77
150
|
const ctx=context(),next=JSON.stringify([ctx.endpoint,ctx.headers?.authorization||''])
|
|
78
|
-
|
|
151
|
+
hostConnected=ctx.connected!==false
|
|
152
|
+
if(next!==identity){identity=next;controller?.abort();controller=null;keyInput.value='';adminInput.value='';bindOptions.open=false;value=null;notice.textContent='';lastRead=0;loading=false;busy=false;readError=false;failures=0;closeCode()
|
|
153
|
+
importReading=false;awaitingActivation='';syncedActivation='';syncing=false;automaticBinding=false;activationMessage='';importFile.value='';render()}
|
|
79
154
|
return ctx
|
|
80
155
|
}
|
|
81
156
|
function render() {
|
|
@@ -101,19 +176,25 @@
|
|
|
101
176
|
if(recentPair.textContent!==message)recentPair.textContent=message
|
|
102
177
|
}
|
|
103
178
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
179
|
+
if(service)renderRegistration()
|
|
180
|
+
else root.DshSponsor?.mount(sponsor)
|
|
181
|
+
title.textContent=service?text('这台主机的中转','Relay for this host'):text('云服务器中转','Cloud relay')
|
|
182
|
+
intro.textContent=service?'':text('让手机通过公网连接这台主机。每位用户使用自己的中转密钥,首次开通会绑定此主机。','Connect to this host over the internet. Your personal relay key binds to this host when activated.')
|
|
183
|
+
const phase=service&&!hostConnected?'disconnected':service&&value?.legacyAvailable?'legacy':service&&value?.phase!=='quota-exceeded'&&value?.configured===false?'unconfigured':value?.phase||(readError?'unavailable':loading||service?'loading':'unconfigured')
|
|
108
184
|
const names={loading:['正在读取','Loading'],unavailable:['状态读取失败','Status unavailable'],unconfigured:['尚未开通','Not configured'],disabled:['已停用','Disabled'],connecting:['正在连接','Connecting'],online:['主机中转在线','Host relay online'],reconnecting:['正在重连','Reconnecting'],expired:['授权已到期','Expired'],'authorization-inactive':['授权已撤销或到期','Authorization inactive'],'quota-exceeded':['今日流量已用完','Daily quota reached'],'quota-unavailable':['流量服务暂不可用','Quota service unavailable'],error:['连接异常','Connection error']}
|
|
185
|
+
names.disconnected=['尚未连接主机','No host connected'];names.legacy=['已有登记的试用连接','Existing trial connection']
|
|
186
|
+
if(service)names.unconfigured=['此主机未绑定','Host not bound']
|
|
109
187
|
badge.textContent=phase==='quota-exceeded'&&value?.daily?.period==='month'?text('本月流量已用完','Monthly quota reached'):text(...(names[phase]||names.error));badge.dataset.phase=phase
|
|
110
|
-
status.textContent=busy?text('正在保存并绑定,请稍候…','Saving and binding…'):value?.error?text('请检查主机配置或刷新状态。','Check the host configuration or refresh.'):text('开通后会随 Remote 网关启动,无需单独运行工具。','Starts with the Remote gateway after activation.')
|
|
188
|
+
status.textContent=busy?text('正在保存并绑定,请稍候…','Saving and binding…'):value?.error?text('请检查主机配置或刷新状态。','Check the host configuration or refresh.'):service?'':text('开通后会随 Remote 网关启动,无需单独运行工具。','Starts with the Remote gateway after activation.')
|
|
111
189
|
let safeUrl=''
|
|
112
190
|
try { const url=new URL(value?.publicUrl);if(url.protocol==='https:'&&!url.username&&!url.password)safeUrl=url.origin } catch {}
|
|
113
191
|
address.hidden=!safeUrl;link.textContent=safeUrl;link.href=safeUrl||'#';copy.textContent=text('复制地址','Copy URL')
|
|
114
192
|
const daily=value?.daily
|
|
115
|
-
|
|
116
|
-
plan.
|
|
193
|
+
const planType = relayPlan(value)
|
|
194
|
+
plan.hidden = !planType
|
|
195
|
+
const hasPacks=Number(daily?.fallbackLimitBytes)>0 || Number(value?.monthlyLimitBytes)>5e9
|
|
196
|
+
const fileEnabled=value?.fileTransfer===true && hasPacks
|
|
197
|
+
plan.textContent=planType==='early-test'?text('特殊先行测试用户','Special early tester'):plan.hidden?'':fileEnabled?text('流量包已生效 · 支持文件传输','Data pack active · File transfer enabled'):text('基础中转 · 一个服务月 5GB · 单网关绑定 · 支持对话图片,不含文件传输。','Basic relay · 5GB per service month · One gateway · Chat images supported; file transfer excluded.')
|
|
117
198
|
quota.hidden=!daily
|
|
118
199
|
if(daily?.unavailable){usage.textContent=text('无法确认流量额度,云端暂停传输。','Quota unavailable; cloud transfer is paused.');meter.hidden=true;reset.textContent=''}
|
|
119
200
|
else if(daily){
|
|
@@ -121,21 +202,178 @@
|
|
|
121
202
|
const gb=bytes=>(Math.max(0,Number(bytes)||0)/1e9).toFixed(2)
|
|
122
203
|
const monthly=daily.period==='month'
|
|
123
204
|
usage.textContent=text(`${monthly?'本月':'今日'}已用 ${gb(daily.usedBytes)} / ${gb(daily.limitBytes)} GB · 剩余 ${gb(daily.remainingBytes)} GB`,`${monthly?'This month':'Today'} ${gb(daily.usedBytes)} / ${gb(daily.limitBytes)} GB · ${gb(daily.remainingBytes)} GB left`)
|
|
124
|
-
reset.textContent=monthly?text('
|
|
205
|
+
reset.textContent=monthly?(fileEnabled?text('对话、图片和文件共用本期额度。','Chat, images and files share this service month quota.'):hasPacks&&daily.exhausted?text('文件流量额度已用完。直接 HTTPS 连接可继续使用剩余的文本和图片兜底额度。','File quota reached. Direct HTTPS can use any remaining allowance for chat and images.'):text('上传与下载及对话图片合计;额度覆盖本次开通的服务月。','Uploads, downloads and chat images share this service month quota.')):text('上传与下载合计;北京时间每天 00:00 重置。','Uploads + downloads; resets daily at 00:00 Beijing time.')
|
|
125
206
|
}
|
|
126
207
|
const expires=value?.expiresAt?new Date(value.expiresAt).toLocaleString():''
|
|
127
|
-
binding.textContent=value?.
|
|
208
|
+
binding.textContent=value?.configured?text(`已绑定此主机${expires?' · 有效期至 '+expires:''}`,`Bound to this host${expires?' · Until '+expires:''}`):''
|
|
209
|
+
bindSummary.textContent=text('手动配置中转密钥','Configure relay key manually')
|
|
210
|
+
renderActivation()
|
|
211
|
+
adminLabel.hidden=value?.canManage!==false
|
|
128
212
|
keyLabel.firstChild.textContent=text(value?.configured?'更换个人中转密钥':'个人中转密钥',value?.configured?'Replace personal relay key':'Personal relay key')
|
|
129
213
|
keyInput.placeholder='dsrp_…';keyInput.setAttribute('aria-label',keyLabel.firstChild.textContent)
|
|
130
|
-
adminLabel.hidden=value?.canManage!==false
|
|
131
214
|
adminLabel.firstChild.textContent=text('主机管理令牌(仅本次操作)','Host admin token (this operation only)')
|
|
132
215
|
adminInput.setAttribute('aria-label',adminLabel.firstChild.textContent)
|
|
133
216
|
submit.textContent=busy?text('正在处理…','Working…'):text(value?.configured?'绑定新密钥':'绑定并开启',value?.configured?'Bind new key':'Bind and enable')
|
|
134
217
|
submit.disabled=busy||!value;keyInput.disabled=busy;adminInput.disabled=busy
|
|
135
|
-
toggle.hidden=!value?.configured;toggle.disabled=busy;toggle.textContent=text(value?.enabled?'停用中转':'开启中转',value?.enabled?'Disable relay':'Enable relay')
|
|
218
|
+
toggle.hidden=!value?.configured;toggle.disabled=busy||service&&readError;toggle.textContent=text(value?.enabled?'停用中转':'开启中转',value?.enabled?'Disable relay':'Enable relay')
|
|
136
219
|
refresh.textContent=text('刷新状态','Refresh');refresh.disabled=busy||loading
|
|
137
220
|
takeover.hidden=!value?.legacyAvailable;takeover.disabled=busy;takeover.textContent=text('接管已有试用连接','Take over existing trial')
|
|
138
|
-
hint.textContent=value?.quotaPending?text('等待云端确认流量额度…','Waiting for cloud quota…'):value?.e2ee?.configured?text('Android 可从局域网扫码配对。配对文件可在设备管理中手动创建。','Pair Android over the LAN using a connection code. Manual pairing files are available in device management.'):text('手机使用此公网地址和原 Remote 访问令牌。停用会断开通过此入口的连接;授权到期或用满后,请通过本地地址管理。','Use this URL and your existing Remote access token. Disabling disconnects this route; use a local address after expiry or quota exhaustion.')
|
|
221
|
+
hint.textContent=value?.quotaPending?text('等待云端确认流量额度…','Waiting for cloud quota…'):service?(value?.enabled?text('停用会断开此公网入口。','Disabling disconnects this public route.'):''):value?.e2ee?.configured?text('Android 可从局域网扫码配对。配对文件可在设备管理中手动创建。','Pair Android over the LAN using a connection code. Manual pairing files are available in device management.'):text('手机使用此公网地址和原 Remote 访问令牌。停用会断开通过此入口的连接;授权到期或用满后,请通过本地地址管理。','Use this URL and your existing Remote access token. Disabling disconnects this route; use a local address after expiry or quota exhaustion.')
|
|
222
|
+
}
|
|
223
|
+
function renderActivation() {
|
|
224
|
+
const request = value?.activationRequest
|
|
225
|
+
const canApprove = !service && value?.canManageDevices === true && request?.phase === 'pending'
|
|
226
|
+
inboxOffer.hidden = !inboxActivation
|
|
227
|
+
if (inboxActivation) {
|
|
228
|
+
const endpoint = context().endpoint
|
|
229
|
+
let host = ''
|
|
230
|
+
if (hostConnected) { try { host = new URL(endpoint).host } catch {} }
|
|
231
|
+
const description = host
|
|
232
|
+
? text('收到站内激活。将应用到当前主机:', 'Activation received. Apply it to the current host: ') + host
|
|
233
|
+
: text('收到站内激活。请先通过局域网连接要绑定的主机。', 'Activation received. Connect to the intended host over the LAN first.')
|
|
234
|
+
if (inboxTarget.textContent !== description) inboxTarget.textContent = description
|
|
235
|
+
}
|
|
236
|
+
applyInbox.disabled = busy || loading || syncing
|
|
237
|
+
dismissInbox.disabled = busy
|
|
238
|
+
importButton.disabled = busy || importReading || syncing
|
|
239
|
+
approve.hidden = reject.hidden = !canApprove
|
|
240
|
+
approve.disabled = reject.disabled = busy
|
|
241
|
+
retrySync.hidden = !syncActivation || !value?.enabled || !value.activationId || !value.canPairLocally
|
|
242
|
+
retrySync.disabled = syncing || busy
|
|
243
|
+
const message = canApprove
|
|
244
|
+
? text('有一台已认证的手机请求绑定中转。确认后将绑定到这台电脑。','An authenticated phone requested relay activation. Approval binds it to this computer.')
|
|
245
|
+
: activationMessage
|
|
246
|
+
if (activationNotice.textContent !== message) activationNotice.textContent = message
|
|
247
|
+
}
|
|
248
|
+
function manualActivation(message) {
|
|
249
|
+
activationMessage = message + ' ' + text('仍可展开「手动配置中转密钥」。','Manual relay-key setup is still available.')
|
|
250
|
+
bindOptions.open = true
|
|
251
|
+
renderActivation()
|
|
252
|
+
}
|
|
253
|
+
function updateActivation(ctx) {
|
|
254
|
+
const request = value?.activationRequest
|
|
255
|
+
if (awaitingActivation) {
|
|
256
|
+
if (request?.id === awaitingActivation && (request.phase === 'pending' || request.phase === 'binding')) return
|
|
257
|
+
const bound = value?.activationId === awaitingActivation || request?.id === awaitingActivation && request.phase === 'bound'
|
|
258
|
+
awaitingActivation = ''
|
|
259
|
+
if (!bound) {
|
|
260
|
+
automaticBinding = false
|
|
261
|
+
manualActivation(request?.error && messages[request.error] ? text(...messages[request.error]) : text('手机发起的导入未完成。请在电脑检查确认结果。','The import from this phone did not complete. Check its confirmation on the host.'))
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
activationMessage = text('主机已绑定。','Host bound.')
|
|
265
|
+
}
|
|
266
|
+
if (!document.hidden && (automaticBinding || target.getClientRects().length)) void syncImportedActivation(ctx)
|
|
267
|
+
}
|
|
268
|
+
async function syncImportedActivation(ctx, retry = false) {
|
|
269
|
+
const id = value?.activationId
|
|
270
|
+
if (!syncActivation || !value?.enabled || !value.canPairLocally || !id || syncing || !retry && syncedActivation === id) return
|
|
271
|
+
syncedActivation = id; syncing = true
|
|
272
|
+
activationMessage = text('主机已绑定,正在配置此手机…','Host bound. Setting up this phone…')
|
|
273
|
+
renderActivation()
|
|
274
|
+
let result
|
|
275
|
+
try { result = await syncActivation(value) } catch {}
|
|
276
|
+
if (!current(ctx)) return
|
|
277
|
+
syncing = false
|
|
278
|
+
automaticBinding = false
|
|
279
|
+
if (result?.ok) {
|
|
280
|
+
activationMessage = text('主机已绑定,手机已配置,公网连接已验证。','Host bound. Phone configured and relay connection verified.')
|
|
281
|
+
renderActivation()
|
|
282
|
+
} else {
|
|
283
|
+
manualActivation(text('主机已绑定,手机配置未完成。可重试,也可用下方配对入口或手动添加公网地址。','The host is bound. Retry setup, use pairing below or add the public address manually.'))
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function parseActivation(contents) {
|
|
287
|
+
if (typeof contents !== 'string' || contents.length > 4096) throw Object.assign(Error('INVALID_ACTIVATION_FILE'), { code: 'INVALID_ACTIVATION_FILE' })
|
|
288
|
+
const data = JSON.parse(contents)
|
|
289
|
+
if (!data || data.type !== 'dsh-remote-relay-activation' || data.version !== 1 ||
|
|
290
|
+
typeof data.code !== 'string' || !/^dsra_[a-f0-9]{16}\.[A-Za-z0-9_-]{43}$/.test(data.code) ||
|
|
291
|
+
!Number.isSafeInteger(data.expiresAt) || Object.keys(data).length !== 4) {
|
|
292
|
+
throw Object.assign(Error('INVALID_ACTIVATION_FILE'), { code: 'INVALID_ACTIVATION_FILE' })
|
|
293
|
+
}
|
|
294
|
+
if (data.expiresAt <= Date.now()) throw Object.assign(Error('ACTIVATION_FILE_EXPIRED'), { code: 'ACTIVATION_FILE_EXPIRED' })
|
|
295
|
+
return data
|
|
296
|
+
}
|
|
297
|
+
function receiveActivation(raw) {
|
|
298
|
+
const ctx = syncIdentity()
|
|
299
|
+
try {
|
|
300
|
+
inboxActivation = parseActivation(raw)
|
|
301
|
+
activationMessage = ''
|
|
302
|
+
renderActivation()
|
|
303
|
+
if (ctx.connected !== false && !busy) void load(true)
|
|
304
|
+
} catch (error) {
|
|
305
|
+
inboxActivation = null
|
|
306
|
+
manualActivation(text(...(messages[error.code] || messages.INVALID_ACTIVATION_FILE)))
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
async function hostFingerprint(ctx) {
|
|
310
|
+
const authorization=ctx.headers?.authorization
|
|
311
|
+
if(!authorization)return ''
|
|
312
|
+
const digest=await root.crypto.subtle.digest('SHA-256',new TextEncoder().encode(JSON.stringify([ctx.endpoint,authorization])))
|
|
313
|
+
return Array.from(new Uint8Array(digest),byte=>byte.toString(16).padStart(2,'0')).join('')
|
|
314
|
+
}
|
|
315
|
+
async function openAutomaticCheckout() {
|
|
316
|
+
const ctx=syncIdentity()
|
|
317
|
+
try {
|
|
318
|
+
const host=await hostFingerprint(ctx)
|
|
319
|
+
if(!host||!current(ctx)||value?.canPairLocally!==true||value.configured!==false)return
|
|
320
|
+
const ticket=root.crypto.randomUUID().replaceAll('-','')
|
|
321
|
+
const selection={ticket,host}
|
|
322
|
+
root.localStorage.setItem(automaticKey,JSON.stringify(selection))
|
|
323
|
+
automaticCheckout=selection;nextAutomaticCheck=0
|
|
324
|
+
bridge.openCloudRelayAutomaticCheckout(ticket)
|
|
325
|
+
}catch{root.DshSponsor?.openPortal()}
|
|
326
|
+
}
|
|
327
|
+
async function checkAutomaticCheckout() {
|
|
328
|
+
const selection=automaticCheckout
|
|
329
|
+
if(!selection||checkingAutomatic||document.hidden||Date.now()<nextAutomaticCheck||busy||loading)return
|
|
330
|
+
const state=bridge.cloudRelayRegistration()
|
|
331
|
+
if(state!=='submitted'&&state!=='approved'&&state!=='renewable')return
|
|
332
|
+
nextAutomaticCheck=Date.now()+12000;checkingAutomatic=true
|
|
333
|
+
try {
|
|
334
|
+
const ctx=syncIdentity()
|
|
335
|
+
if(ctx.connected===false||await hostFingerprint(ctx)!==selection.host||!current(ctx)||automaticCheckout!==selection)return
|
|
336
|
+
await load(true)
|
|
337
|
+
if(!current(ctx)||readError||value?.activationImport!==true||value.canPairLocally!==true||value.configured!==false||value.legacyAvailable)return
|
|
338
|
+
const raw=bridge.cloudRelayAutomaticActivation(selection.ticket)
|
|
339
|
+
if(!raw){bridge.refreshCloudRelayAutomaticActivation(selection.ticket);return}
|
|
340
|
+
const data=parseActivation(raw)
|
|
341
|
+
root.localStorage.removeItem(automaticKey)
|
|
342
|
+
automaticCheckout=null;automaticBinding=true
|
|
343
|
+
if(!await change('activate-file',{activation:data},ctx)&¤t(ctx)){
|
|
344
|
+
automaticBinding=false;inboxActivation=data;renderActivation()
|
|
345
|
+
}
|
|
346
|
+
}catch{}finally{checkingAutomatic=false}
|
|
347
|
+
}
|
|
348
|
+
function renderRegistration() {
|
|
349
|
+
const raw=checkRegistration?bridge.cloudRelayRegistration():'unavailable'
|
|
350
|
+
const state=Object.hasOwn(registrationLabels,raw)?raw:'unavailable'
|
|
351
|
+
const verifiedUnbound=hostConnected&&!readError&&value?.configured===false&&!value.legacyAvailable&&value.phase!=='quota-exceeded'
|
|
352
|
+
const canStart=verifiedUnbound&&(state==='none'||!bridge)
|
|
353
|
+
const automatic=automaticSupported&&canStart&&value.activationImport===true&&value.canPairLocally===true
|
|
354
|
+
const canRestart=verifiedUnbound&&['expired','rejected','revoked'].includes(state)
|
|
355
|
+
const manageRegistration=!(canStart||canRestart||state==='none'&&!hostConnected||!bridge&&!hostConnected)
|
|
356
|
+
registrationTitle.textContent=text('云中转套餐','Cloud relay plans')
|
|
357
|
+
const label=text(...registrationLabels[state])
|
|
358
|
+
if(registrationStatus.textContent!==label)registrationStatus.textContent=label
|
|
359
|
+
registrationHint.textContent=state==='none'?text('在别处登记过?用原查询凭证恢复后,这台 App 就能收到该编号的运营消息。','Applied elsewhere? Recover your application to receive messages for its number in this app.'):state==='unavailable'?text('可用原查询凭证核对,确认前请勿重复付款。','Verify with your recovery code before paying again.'):''
|
|
360
|
+
if(automatic)registrationHint.textContent=text('申请编号自动保存。审核通过后,App 会尝试配置当前选定的局域网主机。','The application is saved here. After approval, the app will try to configure the selected host over the LAN.')
|
|
361
|
+
registrationLink.dataset.automatic=String(automatic)
|
|
362
|
+
if(root.DshSponsor)registrationLink.href=registrationRecover.href=root.DshSponsor.applicationUrl
|
|
363
|
+
registrationLink.textContent=state==='draft'?text('继续办理','Continue application')
|
|
364
|
+
:state==='submitted'?text('查看审核进度','Check review status')
|
|
365
|
+
:manageRegistration?text('续费 / 购买流量包','Renew or buy data packs')
|
|
366
|
+
:automatic?text('开通并自动配置此主机','Apply and set up this host automatically')
|
|
367
|
+
:text('查看套餐并开通','View plans and activate')
|
|
368
|
+
registrationRecover.textContent=text('续费 / 购买流量包','Renew or buy data packs')
|
|
369
|
+
registrationRecover.hidden=manageRegistration
|
|
370
|
+
registrationRefresh.hidden=!checkRegistration
|
|
371
|
+
registrationRefresh.disabled=state==='loading'
|
|
372
|
+
registrationRefresh.textContent=text('刷新登记','Refresh application')
|
|
373
|
+
const unread=checkInbox?bridge.cloudRelayUnreadMessages():-1
|
|
374
|
+
registrationInbox.hidden=!checkInbox||unread<0&&['idle','none','loading'].includes(state)
|
|
375
|
+
registrationInbox.textContent=unread>0?text(`站内消息 · ${unread} 条未读`,`Inbox · ${unread} unread`):text('站内消息','Inbox')
|
|
376
|
+
if(state==='idle'&&!document.hidden&&target.getClientRects().length)bridge.refreshCloudRelayRegistration()
|
|
139
377
|
}
|
|
140
378
|
async function load(force=false) {
|
|
141
379
|
const ctx=syncIdentity()
|
|
@@ -150,10 +388,11 @@
|
|
|
150
388
|
let data
|
|
151
389
|
try{data=await response.json()}catch{throw Object.assign(Error('INVALID_RESPONSE'),{code:'INVALID_RESPONSE',status:response.status})}
|
|
152
390
|
if(!current(ctx))return
|
|
153
|
-
if(response.status===429&&data.daily){value={phase:'quota-exceeded',daily:data.daily,configured:false};notice.textContent=data.daily.period==='month'?text('
|
|
391
|
+
if(response.status===429&&data.daily){value={phase:'quota-exceeded',daily:data.daily,configured:false};notice.textContent=data.daily.period==='month'?text('本月额度已用完。可从上方查看续费和购买流量包的选项,或用主机本地地址管理。','Monthly quota reached. See the options above for renewal and data packs, or manage through the local host.'):text('今日额度已用完。请用主机本地地址进入设置,或等待零点恢复。','Daily quota reached. Use the local host address or wait until reset.');return}
|
|
154
392
|
if(!response.ok)throw Object.assign(Error(data.error||'HTTP_'+response.status),{code:data.error,status:response.status})
|
|
155
393
|
if(data.supported!==true)throw Object.assign(Error('UNSUPPORTED_GATEWAY'),{code:'UNSUPPORTED_GATEWAY'})
|
|
156
394
|
value=data;notice.textContent='';readError=false;failures=0
|
|
395
|
+
updateActivation(ctx)
|
|
157
396
|
}catch(error){
|
|
158
397
|
if(current(ctx)&&!busy&&controller===abort){
|
|
159
398
|
readError=true;failures++
|
|
@@ -161,8 +400,10 @@
|
|
|
161
400
|
}
|
|
162
401
|
}finally{clearTimeout(timer);if(current(ctx)&&controller===abort){loading=false;render()}}
|
|
163
402
|
}
|
|
164
|
-
async function change(action) {
|
|
403
|
+
async function change(action, parameters = {}, captured = null) {
|
|
165
404
|
const ctx=syncIdentity();if(busy)return
|
|
405
|
+
if (captured && (!current(captured) || captured.endpoint !== ctx.endpoint)) return
|
|
406
|
+
const activationAction = ['activate-file', 'approve-activation', 'reject-activation'].includes(action)
|
|
166
407
|
const key=keyInput.value.trim(),admin=adminInput.value.trim()
|
|
167
408
|
if(action==='enroll'&&!/^dsrp_[a-f0-9]{16}\.[A-Za-z0-9_-]{43}$/.test(key)){notice.textContent=text('请填写完整的个人中转密钥。','Enter the complete personal relay key.');return}
|
|
168
409
|
busy=true;controller?.abort();loading=false;notice.textContent='';render()
|
|
@@ -170,13 +411,71 @@
|
|
|
170
411
|
// Clear immediately, including ambiguous network outcomes. Never store the key.
|
|
171
412
|
keyInput.value='';adminInput.value=''
|
|
172
413
|
try {
|
|
173
|
-
const response=await root.fetch(ctx.endpoint,{method:'POST',headers:{...ctx.headers,...(admin?{authorization:'Bearer '+admin}:{}),'content-type':'application/json'},credentials,body:JSON.stringify({action,...(action==='enroll'?{key}:{})}),signal:abort.signal})
|
|
414
|
+
const response=await root.fetch(ctx.endpoint,{method:'POST',headers:{...ctx.headers,...(admin?{authorization:'Bearer '+admin}:{}),'content-type':'application/json'},credentials,redirect:'error',body:JSON.stringify({action,...parameters,...(action==='enroll'?{key}:{})}),signal:abort.signal})
|
|
174
415
|
const data=await response.json();if(!current(ctx))return
|
|
175
416
|
if(!response.ok)throw Object.assign(Error(data.error),{code:data.error})
|
|
176
|
-
value={...data,canManageDevices:value?.canManageDevices};notice.textContent=text(action==='disable'?'中转已停用。':'设置已保存,正在确认云端连接。',action==='disable'?'Relay disabled.':'Saved. Confirming the cloud connection.')
|
|
177
|
-
|
|
417
|
+
value={...data,canManageDevices:data.canManageDevices ?? value?.canManageDevices};notice.textContent=text(action==='disable'?'中转已停用。':'设置已保存,正在确认云端连接。',action==='disable'?'Relay disabled.':'Saved. Confirming the cloud connection.')
|
|
418
|
+
if (activationAction) {
|
|
419
|
+
const request = data.activationRequest
|
|
420
|
+
if (action === 'activate-file' && request?.phase === 'pending') {
|
|
421
|
+
awaitingActivation = request.id
|
|
422
|
+
activationMessage = text('请在主机本机的 Remote 管理页确认这项导入。','Approve this import on the host’s local Remote management page.')
|
|
423
|
+
} else if (action === 'reject-activation') {
|
|
424
|
+
activationMessage = text('已拒绝这项导入。','Import rejected.')
|
|
425
|
+
} else if (request?.phase === 'failed') {
|
|
426
|
+
manualActivation(messages[request.error] ? text(...messages[request.error]) : text('绑定失败。','Binding failed.'))
|
|
427
|
+
return false
|
|
428
|
+
} else {
|
|
429
|
+
activationMessage = text('主机已绑定,正在确认云端连接。','Host bound. Confirming the relay connection.')
|
|
430
|
+
updateActivation(ctx)
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return true
|
|
434
|
+
}catch(error){if(current(ctx)){
|
|
435
|
+
const detail = messages[error.code]?text(...messages[error.code]):text('暂时无法确认操作结果。请刷新状态后再决定是否重试。','Result unconfirmed. Refresh status before deciding whether to retry.')
|
|
436
|
+
if(activationAction)manualActivation(detail);else notice.textContent=detail
|
|
437
|
+
}}
|
|
178
438
|
finally{clearTimeout(timer);if(current(ctx)){busy=false;lastRead=0;render()}}
|
|
179
439
|
}
|
|
440
|
+
importButton.addEventListener('click', () => importFile.click())
|
|
441
|
+
importFile.addEventListener('change', async () => {
|
|
442
|
+
const ctx = syncIdentity(), file = importFile.files?.[0]
|
|
443
|
+
importFile.value = ''
|
|
444
|
+
if (!file || busy || importReading) return
|
|
445
|
+
if (ctx.connected === false || value?.activationImport !== true) {
|
|
446
|
+
manualActivation(text('请先连接支持导入的主机,或在主机本机导入。','Connect to a compatible host or import on the host itself.'))
|
|
447
|
+
return
|
|
448
|
+
}
|
|
449
|
+
importReading = true; activationMessage = ''; renderActivation()
|
|
450
|
+
try {
|
|
451
|
+
if (file.size > 4096) throw Object.assign(Error('INVALID_ACTIVATION_FILE'), { code: 'INVALID_ACTIVATION_FILE' })
|
|
452
|
+
const data = parseActivation(await file.text())
|
|
453
|
+
if (current(ctx)) await change('activate-file', { activation: data }, ctx)
|
|
454
|
+
} catch (error) {
|
|
455
|
+
if (current(ctx)) manualActivation(text(...(messages[error.code] || messages.INVALID_ACTIVATION_FILE)))
|
|
456
|
+
} finally { if (current(ctx)) { importReading = false; renderActivation() } }
|
|
457
|
+
})
|
|
458
|
+
applyInbox.addEventListener('click', async () => {
|
|
459
|
+
const ctx = syncIdentity(), data = inboxActivation
|
|
460
|
+
if (!data || busy || loading || syncing) return
|
|
461
|
+
if (data.expiresAt <= Date.now()) {
|
|
462
|
+
inboxActivation = null
|
|
463
|
+
manualActivation(text(...messages.ACTIVATION_FILE_EXPIRED))
|
|
464
|
+
return
|
|
465
|
+
}
|
|
466
|
+
if (ctx.connected === false || value?.activationImport !== true || value.canPairLocally !== true) {
|
|
467
|
+
manualActivation(text('请先通过局域网连接支持激活的主机。', 'Connect over the LAN to a host that supports activation.'))
|
|
468
|
+
return
|
|
469
|
+
}
|
|
470
|
+
if (await change('activate-file', { activation: data }, ctx) && inboxActivation === data) {
|
|
471
|
+
inboxActivation = null
|
|
472
|
+
renderActivation()
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
dismissInbox.addEventListener('click', () => { inboxActivation = null; renderActivation() })
|
|
476
|
+
approve.addEventListener('click', () => void change('approve-activation', { requestId: value?.activationRequest?.id }))
|
|
477
|
+
reject.addEventListener('click', () => void change('reject-activation', { requestId: value?.activationRequest?.id }))
|
|
478
|
+
retrySync.addEventListener('click', () => void syncImportedActivation(syncIdentity(), true))
|
|
180
479
|
form.addEventListener('submit',event=>{event.preventDefault();void change('enroll')})
|
|
181
480
|
toggle.addEventListener('click',()=>void change(value?.enabled?'disable':'enable'))
|
|
182
481
|
takeover.addEventListener('click',()=>void change('import'))
|
|
@@ -186,9 +485,32 @@
|
|
|
186
485
|
try{await root.navigator.clipboard.writeText(url);if(current(ctx))notice.textContent=text('地址已复制。','URL copied.')}
|
|
187
486
|
catch{if(current(ctx))notice.textContent=text('请选中上方地址复制。','Select the URL above to copy it.')}
|
|
188
487
|
})
|
|
189
|
-
function tick(){if(destroyed)return;syncIdentity();render();void load()}
|
|
488
|
+
function tick(){if(destroyed)return;syncIdentity();render();void load(automaticBinding&&!!awaitingActivation&&Date.now()-lastRead>=5000);void checkAutomaticCheckout()}
|
|
190
489
|
const timer=setInterval(tick,1000);tick()
|
|
191
|
-
return { refresh:()=>load(true),destroy:()=>{destroyed=true;clearInterval(timer);controller?.abort();closeCode();devices?.destroy();keyInput.value='';adminInput.value=''} }
|
|
490
|
+
return { receiveActivation, refresh:()=>load(true),destroy:()=>{destroyed=true;inboxActivation=null;clearInterval(timer);controller?.abort();closeCode();devices?.destroy();keyInput.value='';adminInput.value=''} }
|
|
491
|
+
}
|
|
492
|
+
function relayPlan(status) {
|
|
493
|
+
if (status?.quotaPeriod === 'month' || status?.daily?.period === 'month') return 'basic'
|
|
494
|
+
return status?.displayPlan === 'early-test' ? 'early-test' : ''
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function connectionCategory(status, base) {
|
|
498
|
+
if (status?.supported !== true) return 'unknown'
|
|
499
|
+
if (status.canPairLocally === true) return 'direct'
|
|
500
|
+
try {
|
|
501
|
+
const address = new URL(status.publicUrl)
|
|
502
|
+
if (address.protocol !== 'https:' || address.origin !== new URL(base).origin) return 'unknown'
|
|
503
|
+
} catch {
|
|
504
|
+
return 'unknown'
|
|
505
|
+
}
|
|
506
|
+
const plan = relayPlan(status)
|
|
507
|
+
if (plan) return plan
|
|
508
|
+
try {
|
|
509
|
+
return new URL(status.server).origin !== new URL(root.DshSponsor?.applicationUrl).origin ? 'self-hosted' : 'relay'
|
|
510
|
+
} catch {
|
|
511
|
+
return 'relay'
|
|
512
|
+
}
|
|
192
513
|
}
|
|
193
|
-
|
|
514
|
+
|
|
515
|
+
root.DshRelaySettings={mount,connectionCategory}
|
|
194
516
|
})(typeof window!=='undefined'?window:globalThis)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* dsh-remote session management (C3). Prefix: dr-session-admin- */
|
|
2
|
+
.dr-session-admin {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 10px;
|
|
6
|
+
padding: 12px;
|
|
7
|
+
border: 1px solid var(--border, rgba(127, 127, 127, .28));
|
|
8
|
+
border-radius: 14px;
|
|
9
|
+
background: var(--panel, transparent);
|
|
10
|
+
color: inherit;
|
|
11
|
+
}
|
|
12
|
+
.dr-session-admin-head { display: flex; flex-direction: column; gap: 4px; }
|
|
13
|
+
.dr-session-admin-title { font-size: 14px; }
|
|
14
|
+
.dr-session-admin-hint { font-size: 12px; line-height: 1.5; opacity: .68; }
|
|
15
|
+
.dr-session-admin-readonly {
|
|
16
|
+
padding: 8px 10px;
|
|
17
|
+
border-radius: 10px;
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
background: rgba(234, 179, 8, .16);
|
|
21
|
+
}
|
|
22
|
+
.dr-session-admin-empty { font-size: 13px; opacity: .68; }
|
|
23
|
+
.dr-session-admin-workspaces { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
|
|
24
|
+
.dr-session-admin-workspace {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
padding: 10px;
|
|
31
|
+
border: 1px solid var(--border, rgba(127, 127, 127, .28));
|
|
32
|
+
border-radius: 12px;
|
|
33
|
+
}
|
|
34
|
+
.dr-session-admin-workspace-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 220px; }
|
|
35
|
+
.dr-session-admin-workspace-name { font-weight: 600; word-break: break-word; }
|
|
36
|
+
.dr-session-admin-workspace-path { font-size: 12px; opacity: .72; word-break: break-all; }
|
|
37
|
+
.dr-session-admin-workspace-count { font-size: 11px; opacity: .62; }
|
|
38
|
+
.dr-session-admin-workspace-actions,
|
|
39
|
+
.dr-session-admin-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
|
|
40
|
+
.dr-session-admin-btn {
|
|
41
|
+
padding: 6px 10px;
|
|
42
|
+
border: 1px solid var(--border, rgba(127, 127, 127, .4));
|
|
43
|
+
border-radius: 9px;
|
|
44
|
+
background: transparent;
|
|
45
|
+
color: inherit;
|
|
46
|
+
font: inherit;
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
}
|
|
51
|
+
.dr-session-admin-btn:hover { border-color: var(--accent, #3b82f6); }
|
|
52
|
+
.dr-session-admin-btn:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
|
|
53
|
+
.dr-session-admin-btn.is-active { border-color: var(--accent, #3b82f6); background: rgba(59, 130, 246, .12); }
|
|
54
|
+
.dr-session-admin-btn-danger { border-color: rgba(220, 38, 38, .45); color: rgb(220, 38, 38); }
|
|
55
|
+
.dr-session-admin-btn:disabled { opacity: .5; cursor: default; }
|
|
56
|
+
.dr-session-admin-actions { padding: 2px 0; }
|
|
57
|
+
@media (max-width: 640px) {
|
|
58
|
+
.dr-session-admin { padding: 10px; border-radius: 12px; }
|
|
59
|
+
.dr-session-admin-workspace { align-items: stretch; }
|
|
60
|
+
.dr-session-admin-workspace-actions { justify-content: flex-end; }
|
|
61
|
+
}
|