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