1. 修复 WebSocket 认证漏洞:WebSocket 连接现在需要认证(支持 URL 参数 password 或 Cookie token) 2. 支持 URL 参数自动登录:HTTP 请求带 ?password=xxx 参数时会自动验证并设置 cookie 3. 主程序添加密码配置: - RemoteDevice 类型添加 password 字段 - ConfigDialog 添加密码输入框 - 打开远程桌面时传递 password 参数 4. 修复 remote/public/js/app.js: - 从 URL 参数获取 password 并传递给 WebSocket 连接 - 移除错误的 token 当作 password 的代码 5. 添加密码变化检测:修改密码后自动刷新页面重新认证,无需重启 remote 服务 6. 文件传输 API 支持 password 参数
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
(function() {
|
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
const wsHost = window.location.hostname;
|
|
const wsPort = window.location.port;
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const password = urlParams.get('password');
|
|
const wsUrlBase = wsPort ? `${wsProtocol}//${wsHost}:${wsPort}/ws` : `${wsProtocol}//${wsHost}/ws`;
|
|
const WS_URL = password ? `${wsUrlBase}?password=${encodeURIComponent(password)}` : wsUrlBase;
|
|
|
|
let videoPlayer = null;
|
|
let inputHandler = null;
|
|
|
|
function init() {
|
|
videoPlayer = new VideoPlayer('video-canvas', WS_URL);
|
|
videoPlayer.init();
|
|
|
|
inputHandler = new InputHandler(videoPlayer.getCanvas(), {
|
|
wsUrl: WS_URL
|
|
});
|
|
inputHandler.init();
|
|
|
|
console.log('xc-remote initialized');
|
|
}
|
|
|
|
function destroy() {
|
|
if (inputHandler) {
|
|
inputHandler.destroy();
|
|
inputHandler = null;
|
|
}
|
|
if (videoPlayer) {
|
|
videoPlayer.destroy();
|
|
videoPlayer = null;
|
|
}
|
|
}
|
|
|
|
window.addEventListener('beforeunload', destroy);
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
})();
|