v1.1: Add CIDR subnet filtering and Agent filter in Devices page

This commit is contained in:
ypratama committed 2026-08-27 12:02:01 +07:00
commit 966058e2fe
422 files changed
+54656

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
// scripts/deploy-sftp.js
// ─────────────────────────────────────────────────────────────────────────────
// Next.js Production Build SFTP Deployment Script
// ─────────────────────────────────────────────────────────────────────────────
const path = require('path');
const fs = require('fs');
const Client = require('ssh2-sftp-client');
require('dotenv').config({ path: path.join(__dirname, '..', '.env.production') });
const UPLOAD_MANIFEST = [
{ local: '.next/static', remote: '/var/www/backone/frontend/.next/static' },
{ local: '.next/server', remote: '/var/www/backone/frontend/.next/server' },
{ local: 'public', remote: '/var/www/backone/frontend/public' }
];
async function deploy() {
const sftp = new Client();
try {
const config = {
host: process.env.SFTP_HOST || '127.0.0.1',
port: parseInt(process.env.SFTP_PORT || '22'),
username: process.env.SFTP_USERNAME || 'deploy',
password: process.env.SFTP_PASSWORD || 'password'
};
console.log(`Connecting to SFTP server ${config.host}...`);
await sftp.connect(config);
console.log('Connected! Starting upload...');
for (const item of UPLOAD_MANIFEST) {
const localPath = path.join(__dirname, '..', item.local);
if (fs.existsSync(localPath)) {
console.log(`Uploading ${item.local} to ${item.remote}...`);
await sftp.uploadDir(localPath, item.remote);
} else {
console.warn(`Local path ${item.local} does not exist. Skipping.`);
}
}
console.log('Deployment successful!');
} catch (err) {
console.error('Deployment failed:', err.message);
} finally {
await sftp.end();
}
}
if (require.main === module) {
deploy();
}
module.exports = { UPLOAD_MANIFEST, deploy };
+59
View File
@@ -0,0 +1,59 @@
const net = require('net');
const { MongoMemoryServer } = require('mongodb-memory-server');
function checkPort(port, host) {
return new Promise((resolve) => {
const socket = new net.Socket();
socket.setTimeout(1000);
socket.on('connect', () => {
socket.destroy();
resolve(true);
});
socket.on('timeout', () => {
socket.destroy();
resolve(false);
});
socket.on('error', () => {
socket.destroy();
resolve(false);
});
socket.connect(port, host);
});
}
async function start() {
try {
const isLocalMongoRunning = await checkPort(27017, '127.0.0.1') || await checkPort(27017, 'localhost');
if (isLocalMongoRunning) {
console.log('[MONGO] ℹ️ Local persistent MongoDB is already running on port 27017. Skipping in-memory MongoDB launch.');
// Keep process alive so concurrently doesn't show it as exited/failed
setInterval(() => {}, 100000);
return;
}
const mongod = await MongoMemoryServer.create({
instance: {
port: 27017,
dbName: 'backone_inspect_0'
}
});
console.log('[MONGO] 🚀 Local In-Memory MongoDB running at: mongodb://127.0.0.1:27017/backone_inspect_0');
const cleanup = async () => {
await mongod.stop();
process.exit(0);
};
process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup);
} catch (err) {
if (err.code === 'EADDRINUSE' || (err.message && err.message.includes('EADDRINUSE'))) {
console.log('[MONGO] ℹ️ Port 27017 is already in use. Skipping in-memory MongoDB launch.');
setInterval(() => {}, 100000);
} else {
console.error('[MONGO] ❌ Error starting MongoMemoryServer:', err.message);
}
}
}
start();