다운로드방식변경
This commit is contained in:
63
App.tsx
63
App.tsx
@@ -323,73 +323,16 @@ const App: React.FC = () => {
|
|||||||
|
|
||||||
// --- Backend Download Logic ---
|
// --- Backend Download Logic ---
|
||||||
const handleDownloadBackend = () => {
|
const handleDownloadBackend = () => {
|
||||||
const backendCode = `/**
|
addLog('info', '백엔드 실행 파일 다운로드를 시작합니다...');
|
||||||
* WebZilla 백엔드 프록시 서버 (Node.js) v1.2
|
|
||||||
*
|
|
||||||
* 기능:
|
|
||||||
* - WebSocket Proxy (Port: 8090)
|
|
||||||
* - FTP/SFTP 지원
|
|
||||||
* - 로컬 파일 시스템 탐색 (LOCAL_LIST)
|
|
||||||
* - 설정 저장 (AppData)
|
|
||||||
* - 포트 충돌 자동 감지
|
|
||||||
*/
|
|
||||||
|
|
||||||
const WebSocket = require('ws');
|
|
||||||
const ftp = require('basic-ftp');
|
|
||||||
const SftpClient = require('ssh2-sftp-client');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const os = require('os');
|
|
||||||
const { exec } = require('child_process');
|
|
||||||
const readline = require('readline');
|
|
||||||
|
|
||||||
function getConfigDir() {
|
|
||||||
const homedir = os.homedir();
|
|
||||||
if (process.platform === 'win32') return path.join(process.env.APPDATA || path.join(homedir, 'AppData', 'Roaming'), 'WebZilla');
|
|
||||||
else return path.join(homedir, '.config', 'webzilla');
|
|
||||||
}
|
|
||||||
const configDir = getConfigDir();
|
|
||||||
if (!fs.existsSync(configDir)) try { fs.mkdirSync(configDir, { recursive: true }); } catch (e) {}
|
|
||||||
|
|
||||||
const PORT = 8090;
|
|
||||||
|
|
||||||
function startServer() {
|
|
||||||
const wss = new WebSocket.Server({ port: PORT });
|
|
||||||
wss.on('error', (err) => {
|
|
||||||
if (err.code === 'EADDRINUSE') {
|
|
||||||
console.error(\`\\n❌ 포트 \${PORT} 사용 중. 자동 해결 시도...\`);
|
|
||||||
handlePortConflict();
|
|
||||||
} else process.exit(1);
|
|
||||||
});
|
|
||||||
wss.on('listening', () => console.log(\`🚀 Server running on ws://localhost:\${PORT}\`));
|
|
||||||
wss.on('connection', (ws) => {
|
|
||||||
let ftpClient = new ftp.Client();
|
|
||||||
let sftpClient = new SftpClient();
|
|
||||||
ws.on('message', async (message) => {
|
|
||||||
// ... (Full implementation logic assumed for brevity in this download snippet,
|
|
||||||
// but user executes the actual file on their disk usually.
|
|
||||||
// This download is for distribution.)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function handlePortConflict() {
|
|
||||||
// Simplified conflict handler for the downloadable single file
|
|
||||||
console.log("포트 충돌 감지됨. 기존 프로세스를 종료하세요.");
|
|
||||||
}
|
|
||||||
startServer();
|
|
||||||
`;
|
|
||||||
const blob = new Blob([backendCode], { type: 'text/javascript' });
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = './webftp-backend.exe';
|
||||||
a.download = 'webftp-backend.exe';
|
a.download = 'webftp-backend.exe';
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
addLog('info', '업데이트된 백엔드 코드가 다운로드되었습니다.');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// --- Connection Handlers ---
|
// --- Connection Handlers ---
|
||||||
const handleConnect = () => {
|
const handleConnect = () => {
|
||||||
if (connection.connected) {
|
if (connection.connected) {
|
||||||
|
|||||||
Reference in New Issue
Block a user