백엔드 버젼표시
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,3 +22,4 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
public/webftp-backend.exe
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
* - **NEW**: 포트 충돌 자동 감지 및 프로세스 종료 기능
|
||||
*/
|
||||
|
||||
const APP_VERSION = "0.0.1";
|
||||
|
||||
const WebSocket = require('ws');
|
||||
const ftp = require('basic-ftp');
|
||||
const fs = require('fs');
|
||||
@@ -51,7 +53,7 @@ function startServer() {
|
||||
});
|
||||
|
||||
wss.on('listening', () => {
|
||||
console.log(`\n🚀 WebZilla FTP Proxy Server가 ws://localhost:${PORT} 에서 실행 중입니다.`);
|
||||
console.log(`\n🚀 WebZilla FTP Proxy Server [v${APP_VERSION}] 가 ws://localhost:${PORT} 에서 실행 중입니다.`);
|
||||
console.log(`📂 설정 폴더: ${configDir}`);
|
||||
});
|
||||
|
||||
@@ -239,12 +241,12 @@ function startServer() {
|
||||
|
||||
case 'DOWNLOAD':
|
||||
if (client.closed) {
|
||||
ws.send(JSON.stringify({ type: 'error', message: 'FTP 연결이 끊어져 있습니다.' }));
|
||||
return;
|
||||
ws.send(JSON.stringify({ type: 'error', message: 'FTP 연결이 끊어져 있습니다.' }));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { remotePath, localPath, transferId } = data;
|
||||
|
||||
|
||||
// Progress Handler
|
||||
client.trackProgress(info => {
|
||||
ws.send(JSON.stringify({
|
||||
@@ -257,32 +259,32 @@ function startServer() {
|
||||
});
|
||||
|
||||
await client.downloadTo(localPath, remotePath);
|
||||
|
||||
|
||||
client.trackProgress(); // Stop tracking
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_success',
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_success',
|
||||
id: transferId,
|
||||
message: '다운로드 완료',
|
||||
path: localPath
|
||||
path: localPath
|
||||
}));
|
||||
} catch (err) {
|
||||
client.trackProgress(); // Stop tracking
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_error',
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_error',
|
||||
id: data.transferId,
|
||||
message: `다운로드 실패: ${err.message}`
|
||||
message: `다운로드 실패: ${err.message}`
|
||||
}));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'UPLOAD':
|
||||
if (client.closed) {
|
||||
ws.send(JSON.stringify({ type: 'error', message: 'FTP 연결이 끊어져 있습니다.' }));
|
||||
return;
|
||||
ws.send(JSON.stringify({ type: 'error', message: 'FTP 연결이 끊어져 있습니다.' }));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { remotePath, localPath, transferId } = data;
|
||||
|
||||
|
||||
// Progress Handler
|
||||
client.trackProgress(info => {
|
||||
ws.send(JSON.stringify({
|
||||
@@ -295,20 +297,20 @@ function startServer() {
|
||||
});
|
||||
|
||||
await client.uploadFrom(localPath, remotePath);
|
||||
|
||||
|
||||
client.trackProgress();
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_success',
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_success',
|
||||
id: transferId,
|
||||
message: '업로드 완료',
|
||||
path: remotePath
|
||||
}));
|
||||
} catch (err) {
|
||||
client.trackProgress();
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_error',
|
||||
ws.send(JSON.stringify({
|
||||
type: 'transfer_error',
|
||||
id: data.transferId,
|
||||
message: `업로드 실패: ${err.message}`
|
||||
message: `업로드 실패: ${err.message}`
|
||||
}));
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user