From d559f00b8a7caeb497cf052e6e5de60eb7974b2e Mon Sep 17 00:00:00 2001 From: Rafif-Riqullah-Siregar Date: Tue, 7 Jul 2026 23:40:46 +0700 Subject: [PATCH] chore: super deep cleaning of temp scripts and mock data --- backend/netify.js | 350 +------------------------------------- deploy_to_server.js | 91 ---------- diff.patch | Bin 48018 -> 0 bytes fix_db.js | 47 ----- fix_db_v2.js | 43 ----- remove_headers.js | 39 ----- restore_headers.js | 48 ------ src/app/api/wipe/route.ts | 24 --- temp_check_db.js | 28 --- temp_check_mongo.js | 8 - temp_fetch.js | 4 - temp_fix_cors.js | 26 --- temp_fix_next.js | 33 ---- temp_fix_pm2.js | 47 ----- temp_fix_port.js | 28 --- temp_fix_prod.js | 44 ----- temp_restore_db.js | 46 ----- temp_ssh.js | 11 -- temp_symlink.js | 28 --- temp_test.js | 24 --- temp_test_api.js | 24 --- temp_test_next.js | 27 --- temp_test_next_post.js | 24 --- temp_test_origin.js | 24 --- test_api.js | 25 --- test_fetch.js | 15 -- test_flows.js | 20 --- test_ip.js | 21 --- verify_backend.js | 81 --------- 29 files changed, 6 insertions(+), 1224 deletions(-) delete mode 100644 deploy_to_server.js delete mode 100644 diff.patch delete mode 100644 fix_db.js delete mode 100644 fix_db_v2.js delete mode 100644 remove_headers.js delete mode 100644 restore_headers.js delete mode 100644 src/app/api/wipe/route.ts delete mode 100644 temp_check_db.js delete mode 100644 temp_check_mongo.js delete mode 100644 temp_fetch.js delete mode 100644 temp_fix_cors.js delete mode 100644 temp_fix_next.js delete mode 100644 temp_fix_pm2.js delete mode 100644 temp_fix_port.js delete mode 100644 temp_fix_prod.js delete mode 100644 temp_restore_db.js delete mode 100644 temp_ssh.js delete mode 100644 temp_symlink.js delete mode 100644 temp_test.js delete mode 100644 temp_test_api.js delete mode 100644 temp_test_next.js delete mode 100644 temp_test_next_post.js delete mode 100644 temp_test_origin.js delete mode 100644 test_api.js delete mode 100644 test_fetch.js delete mode 100644 test_flows.js delete mode 100644 test_ip.js delete mode 100644 verify_backend.js diff --git a/backend/netify.js b/backend/netify.js index e33ccbd..0916d83 100644 --- a/backend/netify.js +++ b/backend/netify.js @@ -17,343 +17,7 @@ function headersSite(useApiKey = false) { return headers; } -function getMockDataForPath(path, params = {}) { - return null; - if (path.includes('/data/stats/summary')) { - return { - download: 218648938113, - upload: 33551656812, - flow_hourly_count: 2970165, - download_speed: 2530000, - upload_speed: 390000, - flow_speed: 123756 - }; - } - if (path.includes('/data/stats/top/application/download')) { - return [ - { application: { id: 1, label: 'YouTube', tag: 'video', category: { label: 'Streaming' } }, download: Math.floor(Math.random() * 50000000) + 10000000, flows: Math.floor(Math.random() * 200) + 50 }, - { application: { id: 2, label: 'Netflix', tag: 'video', category: { label: 'Streaming' } }, download: Math.floor(Math.random() * 40000000) + 8000000, flows: Math.floor(Math.random() * 100) + 30 }, - { application: { id: 3, label: 'Web Browsing', tag: 'web', category: { label: 'General' } }, download: Math.floor(Math.random() * 30000000) + 5000000, flows: Math.floor(Math.random() * 500) + 200 }, - { application: { id: 4, label: 'Google Services', tag: 'google', category: { label: 'Tech' } }, download: Math.floor(Math.random() * 25000000) + 4000000, flows: Math.floor(Math.random() * 400) + 150 }, - { application: { id: 5, label: 'WhatsApp', tag: 'im', category: { label: 'Chat' } }, download: Math.floor(Math.random() * 15000000) + 2000000, flows: Math.floor(Math.random() * 300) + 100 }, - { application: { id: 6, label: 'Spotify', tag: 'music', category: { label: 'Streaming' } }, download: Math.floor(Math.random() * 12000000) + 1000000, flows: Math.floor(Math.random() * 80) + 20 }, - { application: { id: 7, label: 'GitHub', tag: 'developer', category: { label: 'General' } }, download: Math.floor(Math.random() * 8000000) + 500000, flows: Math.floor(Math.random() * 120) + 40 }, - { application: { id: 8, label: 'OpenVPN', tag: 'vpn', category: { label: 'Security' } }, download: Math.floor(Math.random() * 5000000) + 300000, flows: Math.floor(Math.random() * 50) + 10 }, - { application: { id: 9, label: 'BitTorrent', tag: 'p2p', category: { label: 'File Sharing' } }, download: Math.floor(Math.random() * 20000000) + 500000, flows: Math.floor(Math.random() * 300) + 50 } - ]; - } - if (path.includes('/data/stats/top/application/upload')) { - return [ - { application: { id: 1 }, upload: Math.floor(Math.random() * 5000000) + 1000000 }, - { application: { id: 2 }, upload: Math.floor(Math.random() * 2000000) + 500000 }, - { application: { id: 3 }, upload: Math.floor(Math.random() * 6000000) + 2000000 }, - { application: { id: 4 }, upload: Math.floor(Math.random() * 4000000) + 1000000 }, - { application: { id: 5 }, upload: Math.floor(Math.random() * 8000000) + 3000000 }, - { application: { id: 6 }, upload: Math.floor(Math.random() * 1000000) + 200000 }, - { application: { id: 7 }, upload: Math.floor(Math.random() * 3000000) + 800000 }, - { application: { id: 8 }, upload: Math.floor(Math.random() * 4000000) + 1000000 }, - { application: { id: 9 }, upload: Math.floor(Math.random() * 18000000) + 2000000 } - ]; - } - if (path.includes('/intelligence/discovery/devices')) { - return [ - { ip: { address: '192.168.1.10' }, mac_address: 'E4:5F:01:23:45:67', mac_vendor: 'Raspberry Pi', device: { label: 'Home Server' }, discovery_type: { label: 'Server' }, discovery_os: { label: 'Linux' }, last_seen_at: { date: new Date().toISOString() } }, - { ip: { address: '192.168.1.25' }, mac_address: 'B4:FB:E4:88:99:AA', mac_vendor: 'Samsung', device: { label: 'Smart TV' }, discovery_type: { label: 'TV' }, discovery_os: { label: 'Tizen' }, last_seen_at: { date: new Date().toISOString() } }, - { ip: { address: '192.168.1.100' }, mac_address: '3C:28:6D:AA:BB:CC', mac_vendor: 'Apple', device: { label: 'iPhone User' }, discovery_type: { label: 'Mobile' }, discovery_os: { label: 'iOS' }, last_seen_at: { date: new Date().toISOString() } }, - { ip: { address: '192.168.1.101' }, mac_address: '28:31:52:DD:EE:FF', mac_vendor: 'Xiaomi', device: { label: 'Redmi Phone' }, discovery_type: { label: 'Mobile' }, discovery_os: { label: 'Android' }, last_seen_at: { date: new Date().toISOString() } }, - { ip: { address: '192.168.1.102' }, mac_address: '00:15:5D:11:22:33', mac_vendor: 'Microsoft Hyper-V', device: { label: 'Windows PC' }, discovery_type: { label: 'Desktop' }, discovery_os: { label: 'Windows' }, last_seen_at: { date: new Date().toISOString() } } - ]; - } - if (path.includes('/data/stats/top/local_ip/download')) { - return [ - { local_ip: { address: '192.168.1.100' }, download: Math.floor(Math.random() * 40000000) + 10000000 }, - { local_ip: { address: '192.168.1.102' }, download: Math.floor(Math.random() * 30000000) + 8000000 }, - { local_ip: { address: '192.168.1.101' }, download: Math.floor(Math.random() * 15000000) + 3000000 }, - { local_ip: { address: '192.168.1.25' }, download: Math.floor(Math.random() * 25000000) + 5000000 }, - { local_ip: { address: '192.168.1.10' }, download: Math.floor(Math.random() * 8000000) + 2000000 } - ]; - } - if (path.includes('/data/stats/top/local_ip/upload')) { - return [ - { local_ip: { address: '192.168.1.100' }, upload: Math.floor(Math.random() * 5000000) + 1000000 }, - { local_ip: { address: '192.168.1.102' }, upload: Math.floor(Math.random() * 8000000) + 2000000 }, - { local_ip: { address: '192.168.1.101' }, upload: Math.floor(Math.random() * 2000000) + 500000 }, - { local_ip: { address: '192.168.1.25' }, upload: Math.floor(Math.random() * 1000000) + 100000 }, - { local_ip: { address: '192.168.1.10' }, upload: Math.floor(Math.random() * 4000000) + 1000000 } - ]; - } - if (path.includes('/data/stats/top/protocol/download')) { - return [ - { protocol: { id: 6, label: 'TCP' }, download: Math.floor(Math.random() * 100000000) + 40000000, flows: Math.floor(Math.random() * 1000) + 400 }, - { protocol: { id: 17, label: 'UDP' }, download: Math.floor(Math.random() * 30000000) + 10000000, flows: Math.floor(Math.random() * 800) + 200 } - ]; - } - if (path.includes('/data/stats/top/protocol/upload')) { - return [ - { protocol: { id: 6 }, upload: Math.floor(Math.random() * 20000000) + 5000000 }, - { protocol: { id: 17 }, upload: Math.floor(Math.random() * 10000000) + 2000000 } - ]; - } - if (path.includes('/data/stats/top/country/download')) { - return [ - { country: { code: 'US', label: 'United States' }, download: Math.floor(Math.random() * 60000000) + 20000000, flows: Math.floor(Math.random() * 500) + 200 }, - { country: { code: 'SG', label: 'Singapore' }, download: Math.floor(Math.random() * 40000000) + 10000000, flows: Math.floor(Math.random() * 300) + 100 }, - { country: { code: 'ID', label: 'Indonesia' }, download: Math.floor(Math.random() * 20000000) + 5000000, flows: Math.floor(Math.random() * 400) + 150 }, - { country: { code: 'NL', label: 'Netherlands' }, download: Math.floor(Math.random() * 10000000) + 2000000, flows: Math.floor(Math.random() * 100) + 30 } - ]; - } - if (path.includes('/data/stats/top/country/upload')) { - return [ - { country: { code: 'US' }, upload: Math.floor(Math.random() * 12000000) + 3000000 }, - { country: { code: 'SG' }, upload: Math.floor(Math.random() * 8000000) + 2000000 }, - { country: { code: 'ID' }, upload: Math.floor(Math.random() * 4000000) + 1000000 }, - { country: { code: 'NL' }, upload: Math.floor(Math.random() * 2000000) + 500000 } - ]; - } - if (path.includes('/data/stats/top/hostname/download')) { - return [ - { hostname: { name: 'youtube.com', application_name: 'YouTube', application_category_label: 'Streaming' }, download: Math.floor(Math.random() * 30000000) + 10000000, flows: Math.floor(Math.random() * 100) + 20 }, - { hostname: { name: 'netflix.com', application_name: 'Netflix', application_category_label: 'Streaming' }, download: Math.floor(Math.random() * 20000000) + 5000000, flows: Math.floor(Math.random() * 50) + 10 }, - { hostname: { name: 'google.com', application_name: 'Google', application_category_label: 'Web' }, download: Math.floor(Math.random() * 15000000) + 3000000, flows: Math.floor(Math.random() * 400) + 100 }, - { hostname: { name: 'github.com', application_name: 'GitHub', application_category_label: 'Web' }, download: Math.floor(Math.random() * 8000000) + 2000000, flows: Math.floor(Math.random() * 150) + 30 } - ]; - } - if (path.includes('/data/stats/top/hostname/upload')) { - return [ - { hostname: { name: 'youtube.com' }, upload: Math.floor(Math.random() * 2000000) + 500000 }, - { hostname: { name: 'netflix.com' }, upload: Math.floor(Math.random() * 1000000) + 200000 }, - { hostname: { name: 'google.com' }, upload: Math.floor(Math.random() * 3000000) + 500000 }, - { hostname: { name: 'github.com' }, upload: Math.floor(Math.random() * 2000000) + 400000 } - ]; - } - if (path.includes('/data/flows')) { - return [ - { flow_id: 'flow_1', local_ip: { address: '192.168.1.100' }, local_mac: '3C:28:6D:AA:BB:CC', remote_ip: { address: '172.217.194.95' }, remote_port: 443, ip_protocol: { label: 'TCP' }, download: Math.floor(Math.random() * 50000) + 5000, upload: Math.floor(Math.random() * 5000) + 500, first_seen_at: { date: new Date(Date.now() - 300000).toISOString() }, last_seen_at: { date: new Date().toISOString() } }, - { flow_id: 'flow_2', local_ip: { address: '192.168.1.102' }, local_mac: '00:15:5D:11:22:33', remote_ip: { address: '140.82.112.4' }, remote_port: 443, ip_protocol: { label: 'TCP' }, download: Math.floor(Math.random() * 20000) + 2000, upload: Math.floor(Math.random() * 10000) + 1000, first_seen_at: { date: new Date(Date.now() - 600000).toISOString() }, last_seen_at: { date: new Date().toISOString() } }, - { flow_id: 'flow_3', local_ip: { address: '192.168.1.101' }, local_mac: '28:31:52:DD:EE:FF', remote_ip: { address: '31.13.78.35' }, remote_port: 443, ip_protocol: { label: 'TCP' }, download: Math.floor(Math.random() * 15000) + 1000, upload: Math.floor(Math.random() * 2000) + 200, first_seen_at: { date: new Date(Date.now() - 120000).toISOString() }, last_seen_at: { date: new Date().toISOString() } }, - { flow_id: 'flow_4', local_ip: { address: '192.168.1.10' }, local_mac: 'E4:5F:01:23:45:67', remote_ip: { address: '8.8.8.8' }, remote_port: 53, ip_protocol: { label: 'UDP' }, download: Math.floor(Math.random() * 2000) + 200, upload: Math.floor(Math.random() * 2000) + 200, first_seen_at: { date: new Date(Date.now() - 50000).toISOString() }, last_seen_at: { date: new Date().toISOString() } } - ]; - } - if (path.includes('/event/events')) { - return [ - { id: Math.floor(Math.random() * 10000), basename: 'threat.cryptomining', severity: 30, label: 'Suspicious Cryptomining Activity', description: JSON.stringify({ default: 'Connection to mining pool detected from {{ device_ip }}', tags: { device_ip: '192.168.1.10' } }), created_at: { date: new Date().toISOString() } }, - { id: Math.floor(Math.random() * 10000), basename: 'threat.insecure', severity: 20, label: 'Insecure Cleartext Transmission', description: JSON.stringify({ default: 'Cleartext credentials transmitted by {{ device_ip }}', tags: { device_ip: '192.168.1.102' } }), created_at: { date: new Date(Date.now() - 300000).toISOString() } }, - { id: Math.floor(Math.random() * 10000), basename: 'new.device', severity: 10, label: 'New Device Discovered', description: JSON.stringify({ default: 'New device {{ device_label }} discovered at {{ device_ip }}', tags: { device_label: 'Redmi Phone', device_ip: '192.168.1.101' } }), created_at: { date: new Date(Date.now() - 600000).toISOString() } } - ]; - } - - if (path.includes('/data/stats/top/')) { - const segments = path.split('/'); - const fieldName = segments[segments.length - 2]; - const direction = segments[segments.length - 1]; - - if (fieldName === 'application_category') { - const cats = ['Streaming', 'Social Media', 'Web Browsing', 'File Sharing', 'Communication', 'Collaboration', 'Security']; - return cats.map((c) => ({ - application_category: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 40000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'continent') { - const conts = ['North America', 'Asia', 'Europe', 'Oceania']; - return conts.map((c) => ({ - continent: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 50000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 15000000) + 2000000 : 0 - })); - } - if (fieldName === 'region') { - const regs = ['California', 'Singapore Region', 'Jakarta Region', 'Frankfurt Region']; - return regs.map((c) => ({ - region: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'city') { - const cities = ['San Francisco', 'Singapore', 'Jakarta', 'Frankfurt']; - return cities.map((c) => ({ - city: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'vlan') { - const vlans = ['VLAN 1 (Default)', 'VLAN 10 (IoT)', 'VLAN 20 (Guest)']; - return vlans.map((c) => ({ - vlan: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 50000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 15000000) + 2000000 : 0 - })); - } - if (fieldName === 'interface') { - const ifaces = ['eth0 (WAN)', 'eth1 (LAN)', 'wlan0 (WiFi)']; - return ifaces.map((c) => ({ - interface: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 60000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 20000000) + 2000000 : 0 - })); - } - if (fieldName === 'flow_type') { - const types = ['HTTP/HTTPS', 'DNS', 'SSH', 'VPN', 'P2P']; - return types.map((c) => ({ - flow_type: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 40000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'flow_origin') { - const origs = ['Local LAN', 'Inbound WAN']; - return origs.map((c) => ({ - flow_origin: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 50000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 15000000) + 2000000 : 0 - })); - } - if (fieldName === 'ip_version') { - const versions = ['IPv4', 'IPv6']; - return versions.map((c) => ({ - ip_version: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 80000000) + 20000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 25000000) + 5000000 : 0 - })); - } - if (fieldName === 'remote_ip') { - const ips = ['8.8.8.8', '1.1.1.1', '140.82.112.4', '172.217.194.95']; - return ips.map((c) => ({ - remote_ip: { address: c, version: 4 }, - download: direction === 'download' ? Math.floor(Math.random() * 20000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 5000000) + 500000 : 0 - })); - } - if (fieldName === 'local_mac') { - const macs = ['3C:28:6D:AA:BB:CC', '00:15:5D:11:22:33', '28:31:52:DD:EE:FF', 'E4:5F:01:23:45:67']; - return macs.map((c) => ({ - local_mac: c, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'discovery_os') { - const oss = ['iOS', 'Android', 'Windows', 'Linux', 'macOS']; - return oss.map((c) => ({ - discovery_os: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'tls_version') { - const vers = ['TLS 1.3', 'TLS 1.2', 'TLS 1.1']; - return vers.map((c) => ({ - tls_version: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 50000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 15000000) + 2000000 : 0 - })); - } - if (fieldName === 'tls_cipher') { - const ciphers = ['TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256', 'ECDHE-RSA-AES128-GCM-SHA256']; - return ciphers.map((c) => ({ - tls_cipher: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 40000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 12000000) + 2000000 : 0 - })); - } - if (fieldName === 'tls_security') { - const secs = ['Modern (TLS 1.3)', 'Secure (TLS 1.2)', 'Weak']; - return secs.map((c) => ({ - tls_security: { name: c, label: c, color: c === 'Weak' ? 'red' : 'green' }, - download: direction === 'download' ? Math.floor(Math.random() * 40000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 12000000) + 2000000 : 0 - })); - } - if (fieldName === 'netbios_hostname') { - const hosts = ['DESKTOP-PC', 'NAS-SERVER', 'PRINTER-OFFICE']; - return hosts.map((c) => ({ - netbios_hostname: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 10000000) + 2000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 4000000) + 500000 : 0 - })); - } - if (fieldName === 'dhcp_class') { - const classes = ['dhcpcd-9.4.1', 'MSFT 5.0', 'android-dhcp-10']; - return classes.map((c) => ({ - dhcp_class: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 20000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 5000000) + 1000000 : 0 - })); - } - if (fieldName === 'http_useragent') { - const uas = [ - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', - 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1', - 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36' - ]; - return uas.map((c) => ({ - http_useragent: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'https_sni_hostname') { - const snis = ['*.google.com', '*.netflix.com', 'github.com', '*.facebook.com']; - return snis.map((c) => ({ - https_sni_hostname: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'ssl_server_cn') { - const cns = ['Google Internet Authority', 'DigiCert TLS RSA SHA256 2020 CA1', 'Let\'s Encrypt Authority X3']; - return cns.map((c) => ({ - ssl_server_cn: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 40000000) + 10000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 12000000) + 2000000 : 0 - })); - } - if (fieldName === 'quic_hostname') { - const quics = ['*.google.com', '*.youtube.com', 'instagram.com']; - return quics.map((c) => ({ - quic_hostname: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 30000000) + 5000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 1000000 : 0 - })); - } - if (fieldName === 'bittorrent_info_hash') { - const hashes = ['8f9e1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f', '1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9e1a']; - return hashes.map((c, i) => ({ - bittorrent_info_hash: { hash: c, label: `Torrent_${i+1}` }, - download: direction === 'download' ? Math.floor(Math.random() * 10000000) + 2000000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 10000000) + 2000000 : 0 - })); - } - if (fieldName === 'ssh_client') { - const clients = ['SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5', 'SSH-2.0-PuTTY_Release_0.76']; - return clients.map((c) => ({ - ssh_client: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 1000000) + 100000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 500000) + 50000 : 0 - })); - } - if (fieldName === 'ssh_server') { - const servers = ['SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5', 'SSH-2.0-dropbear_2019.78']; - return servers.map((c) => ({ - ssh_server: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 1000000) + 100000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 500000) + 50000 : 0 - })); - } - if (fieldName === 'mdns_hostname') { - const mdns = ['apple-tv.local', 'printer-office.local', 'nas-home.local']; - return mdns.map((c) => ({ - mdns_hostname: { name: c, label: c }, - download: direction === 'download' ? Math.floor(Math.random() * 5000000) + 500000 : 0, - upload: direction === 'upload' ? Math.floor(Math.random() * 2000000) + 200000 : 0 - })); - } - } - return []; -} + function fixDates(obj) { if (Array.isArray(obj)) { @@ -384,8 +48,8 @@ async function netifyFetch(path, params = {}, useApiKey = false, agentUuid = nul } } if (!JWT_TOKEN || !SITE_UUID || JWT_TOKEN === 'YOUR_JWT_TOKEN' || SITE_UUID === 'YOUR_SITE_UUID' || JWT_TOKEN.startsWith('change_me') || JWT_TOKEN.startsWith('YOUR_')) { - console.log('[DEBUG] FALLBACK due to invalid config', {hasToken: !!JWT_TOKEN, SITE_UUID}); - return getMockDataForPath(path, params); + console.error('[Netify] Failed due to invalid config', {hasToken: !!JWT_TOKEN, SITE_UUID}); + return null; } try { const res = await axios.get(`${BASE_URL}${path}`, { @@ -394,17 +58,15 @@ async function netifyFetch(path, params = {}, useApiKey = false, agentUuid = nul const json = res.data; if (json?.status_code !== 0) { console.error(`[Netify] API Error ${json?.status_code} pada ${path}: ${json?.status_message}`); - console.log('[DEBUG] FALLBACK due to API error', json); - return getMockDataForPath(path, params); + return null; } if (json && json.data) fixDates(json.data); return json?.data ?? null; } catch (err) { const s = err.response?.status; const msg = JSON.stringify(err.response?.data ?? err.message); - console.error(`[Netify] ${s ?? 'ERR'} ${path}: ${msg}. Falling back to mock data.`); - console.log('[DEBUG] FALLBACK due to catch error'); - return getMockDataForPath(path, params); + console.error(`[Netify] ${s ?? 'ERR'} ${path}: ${msg}`); + return null; } } diff --git a/deploy_to_server.js b/deploy_to_server.js deleted file mode 100644 index 9adbda5..0000000 --- a/deploy_to_server.js +++ /dev/null @@ -1,91 +0,0 @@ -const { Client } = require('ssh2'); -const fs = require('fs'); - -const conn = new Client(); - -const script = ` -set -e -export PATH=/home/adminbackend/node20/bin:$PATH - -echo "=== 1. STOPPING PM2 PROCESSES ===" -npx pm2 delete all || true - -echo "=== 2. BACKING UP DB & ENV ===" -mkdir -p /home/adminbackend/deploy_backup -cp /home/adminbackend/web/demoplace.my.id/public_html/.env.local /home/adminbackend/deploy_backup/.env.local || echo "No .env.local found" -cp /home/adminbackend/web/demoplace.my.id/public_html/backend/netify_data.db /home/adminbackend/deploy_backup/netify_data.db || echo "No DB found" -cp -r /home/adminbackend/web/demoplace.my.id/public_html/backend/uploads /home/adminbackend/deploy_backup/uploads || echo "No uploads found" - -echo "=== 3. CLEARING TARGET DIRECTORY ===" -cd /home/adminbackend/web/demoplace.my.id/public_html -mkdir -p /home/adminbackend/trash -mv * /home/adminbackend/trash/ 2>/dev/null || true -mv .[^.]* /home/adminbackend/trash/ 2>/dev/null || true - -echo "=== 4. EXTRACTING UPLOADED TARBALL ===" -tar -xzf /home/adminbackend/deploy.tar.gz -C . -rm -f /home/adminbackend/deploy.tar.gz - -echo "=== 5. RESTORING BACKUP ===" -cp /home/adminbackend/deploy_backup/.env.local ./.env.local || true -mkdir -p backend -cp /home/adminbackend/deploy_backup/netify_data.db ./backend/netify_data.db || true -rm -rf ./backend/uploads || true -cp -r /home/adminbackend/deploy_backup/uploads ./backend/uploads || true - -echo "=== 6. INSTALLING DEPS & BUILDING ===" -npm install --legacy-peer-deps -npm run build - -echo "=== 6.5. CREATING NGINX SYMLINKS ===" -ln -sfn .next _next -ln -sfn public/backone-logo.png backone-logo.png -ln -sfn public/favicon.ico favicon.ico - -echo "=== 7. STARTING PM2 ===" -PORT=10000 npx pm2 start npm --name "dpi-web" -- start -npx pm2 start backend/server.js --name "dpi-api" -npx pm2 save - -echo "=== DEPLOYMENT SUCCESSFUL ===" -npx pm2 status -`; - -conn.on('ready', () => { - console.log('Connected to server. Uploading tarball...'); - conn.sftp((err, sftp) => { - if (err) throw err; - const readStream = fs.createReadStream('deploy.tar.gz'); - const writeStream = sftp.createWriteStream('/home/adminbackend/deploy.tar.gz'); - - writeStream.on('close', () => { - console.log('Upload complete. Executing deploy script...'); - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code, signal) => { - console.log('Deployment script finished with code ' + code); - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); - }); - - writeStream.on('error', (err) => { - console.error('SFTP Error:', err); - conn.end(); - }); - - readStream.pipe(writeStream); - }); -}).on('error', (err) => { - console.error('SSH Error:', err); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH', - readyTimeout: 99999 -}); diff --git a/diff.patch b/diff.patch deleted file mode 100644 index 968d9e7292386c31d6ffe5a1d01f64ccd9fe778d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 48018 zcmeI5-EvjQb;oyZQXhKvL<50gQPV z=Qh--=_x|f&wu`;uxjutpQJ-D? zI@a-Kv0My`qhd?no5i6%%f&*mt>aC4bAdp%|CdG$99!|;^?5B z=j!Q=FvbX;>u5hfY&{Q(JAs0Yq93Xy^t>Qi2Q%P(kbM}tk76l|AAIZtPT?+_i~OFq zBRW1P-ilLRsfVp(Y}N~BH$}&FeSmelV@v!vP@5e+^Qibr$D10>`vh9(J$^RzG}<2P zo{PozVRW1uX#U{tH^s|vd=R*7Q2ZuP)mxprqpS3PQGb{8XHQ(xeT;P&dfGV|FD>FH zf9iK?yBFZtR-0pulit8LeU_gIWCl(Dr^hE7eIhl0;gv8`KZ|hD@yTcz>klLRbMLOO zwI3+v)yW9cXFwHBi7P?sI4!2XPJ%&-LygW{LM;Q9%6n6VX| zLHX|4%_H$GHUlI0bIS8;JIgzKv$48pieT^3z!bZ0!+#F~; zXqI7^Wv(2D5kepTtUC@h7hJP>$mK?L7NCxF_Ri=y{=hlnInp=4E zMQ=Ia99z|;)&809I)1Hd8P9Q#(NmPlE8>I8lFe5|yO#v3{l;RLr(A{yk451};tce3 zKIV0C&YpO(Nq!<9v8Hy!h41xu8$ zXFUs$ztw+QIaTD=ggv`$=A$%PkyOIYcrIzcQy0a@$c898kfWw;7j+$b?}ffoiS|}! zYy|X!oNONx79+B8wFQ0~!-o1g8cD~d*+84!5IkrzzT?;qb+75QBjGNk?<&4{UTR?u ziu=L`av7{3Dc`qfB-78iZ89i+rVmu$=exBsnu2lg-K3S%5xx!@)AR{52wm^$KejKj z$H#11xH@V$5;|#;@;P6CBb%38*4MY9B{Y?5W7nv61FU9owAl#t7R)$Qh8<)YGpC1K z^VYRkmbZ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W>`n9-eOZI$q=cqTD=@@g3 zJ2H`9Jk%YmNVQs=dx82km5uY7YI}OD2O9sm)jl19I3ug#?^vC4S*vrL*Q+qH3W~e~ zc|0Uo6(Zvz_HgnidEHa>oidLzuFGeny0QxV`f8FV!J9Jg39lAR0nc%WpTzUj#t?Tc zuZCGrwFWs&?s1u7+BimtQsy}L(`gUiXm+*(KgIck@6t9@ z;`pjG=O$Y(;QNDJ54L8k2AzhVV%8HK)LcQ>l`|{n)z<yJJ3gA-mR58_ zNl^~69tU60BNNpaOW9MbYcYMz=XCpjQT1!9CE*ocGm2NqYU1)$k0f{R1=e)uJa+_R zeQV)Z~LMOmhaa;17_*swp7j~|LD`_XAeJbEGN+s^+F$wgCE diff --git a/fix_db.js b/fix_db.js deleted file mode 100644 index 1dc3884..0000000 --- a/fix_db.js +++ /dev/null @@ -1,47 +0,0 @@ -const { Client } = require('ssh2'); - -const conn = new Client(); - -const script = ` -set -e -export PATH=/home/adminbackend/node20/bin:$PATH - -echo "Stopping PM2" -npx pm2 stop dpi-api || true - -echo "Deleting corrupted database" -cd /home/adminbackend/web/demoplace.my.id/public_html/backend -rm -f netify_data.db netify_data.db-wal netify_data.db-shm - -echo "Running scheduler to recreate DB" -node scheduler.js & -SCHED_PID=$! -sleep 15 -kill $SCHED_PID || true - -echo "Restarting PM2" -npx pm2 restart dpi-api -`; - -conn.on('ready', () => { - console.log('Connected to server. Executing script...'); - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code, signal) => { - console.log('Script finished with code ' + code); - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).on('error', (err) => { - console.error('SSH Error:', err); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH', - readyTimeout: 99999 -}); diff --git a/fix_db_v2.js b/fix_db_v2.js deleted file mode 100644 index 7707355..0000000 --- a/fix_db_v2.js +++ /dev/null @@ -1,43 +0,0 @@ -const { Client } = require('ssh2'); - -const conn = new Client(); - -const script = ` -set -e -export PATH=/home/adminbackend/node20/bin:$PATH - -echo "Stopping PM2" -npx pm2 stop dpi-api || true - -echo "Deleting database to force recreation" -cd /home/adminbackend/web/demoplace.my.id/public_html/backend -rm -f netify_data.db netify_data.db-wal netify_data.db-shm - -echo "Restarting PM2" -npx pm2 restart dpi-api - -echo "Done" -`; - -conn.on('ready', () => { - console.log('Connected to server. Executing script...'); - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code, signal) => { - console.log('Script finished with code ' + code); - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).on('error', (err) => { - console.error('SSH Error:', err); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH', - readyTimeout: 99999 -}); diff --git a/remove_headers.js b/remove_headers.js deleted file mode 100644 index 1182b32..0000000 --- a/remove_headers.js +++ /dev/null @@ -1,39 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -function walk(dir) { - let results = []; - const list = fs.readdirSync(dir); - list.forEach(function(file) { - file = path.join(dir, file); - const stat = fs.statSync(file); - if (stat && stat.isDirectory()) { - results = results.concat(walk(file)); - } else { - if (file.endsWith('.tsx')) results.push(file); - } - }); - return results; -} - -const files = walk('src/app/(dashboard)'); - -for (const file of files) { - let content = fs.readFileSync(file, 'utf8'); - - let regex1 = /
\s*
\s*

\s*

]*>[\s\S]*?<\/h2>/g; - - let newContent = content.replace(regex1, '').replace(regex2, ''); - - // Also clean up stray headers that might not have the div wrapper - if(newContent.match(regex3)) { - newContent = newContent.replace(regex3, ''); - } - - if (content !== newContent) { - fs.writeFileSync(file, newContent); - console.log('Updated ' + file); - } -} diff --git a/restore_headers.js b/restore_headers.js deleted file mode 100644 index 6cecfaf..0000000 --- a/restore_headers.js +++ /dev/null @@ -1,48 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const execSync = require('child_process').execSync; - -function walk(dir) { - let results = []; - const list = fs.readdirSync(dir); - list.forEach(function(file) { - file = path.join(dir, file); - const stat = fs.statSync(file); - if (stat && stat.isDirectory()) { - results = results.concat(walk(file)); - } else { - if (file.endsWith('.tsx')) results.push(file); - } - }); - return results; -} - -const files = walk('src/app/(dashboard)'); - -for (const file of files) { - try { - const gitFile = file.replace(/\\/g, '/'); - const original = execSync('git show HEAD:"' + gitFile + '"').toString(); - const current = fs.readFileSync(file, 'utf8'); - - let regex1 = /
\s*(
\s*)?

\s*

]*>[\s\S]*?<\/h2>/; - - let match = original.match(regex1) || original.match(regex2) || original.match(regex3); - - if (match && !current.includes('

', insertPos); - let newContent = current.slice(0, closingBracket + 1) + '\n' + match[0] + current.slice(closingBracket + 1); - fs.writeFileSync(file, newContent); - console.log('Restored header in ' + file); - } - } - } catch(e) { - console.log("Error processing " + file + ": " + e.message); - } -} diff --git a/src/app/api/wipe/route.ts b/src/app/api/wipe/route.ts deleted file mode 100644 index 85ad23c..0000000 --- a/src/app/api/wipe/route.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { NextResponse } from 'next/server'; -import mongoose from 'mongoose'; -import { DeviceStat, Summary, AppStat, ProtocolStat, Flow, Threat } from '../../../../backend/models/Schemas'; - -export async function GET() { - try { - // Check if mongoose is connected - if (mongoose.connection.readyState !== 1) { - return NextResponse.json({ error: 'MongoDB not connected on frontend route' }, { status: 500 }); - } - - await DeviceStat.deleteMany({}); - await Summary.deleteMany({}); - await AppStat.deleteMany({}); - await ProtocolStat.deleteMany({}); - await Flow.deleteMany({}); - await Threat.deleteMany({}); - - return NextResponse.json({ message: 'All dummy data wiped from in-memory database successfully!' }); - } catch (err: any) { - console.error(err); - return NextResponse.json({ error: err.message }, { status: 500 }); - } -} diff --git a/temp_check_db.js b/temp_check_db.js deleted file mode 100644 index e8eb68d..0000000 --- a/temp_check_db.js +++ /dev/null @@ -1,28 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -sqlite3 /home/adminbackend/web/backend.demoplace.my.id/public_html/backend/netify_data.db "PRAGMA integrity_check;" -echo "Backup DB Check:" -sqlite3 /home/adminbackend/deploy_backup/netify_data.db "PRAGMA integrity_check;" -echo "Current DB Check:" -sqlite3 /home/adminbackend/web/demoplace.my.id/public_html/backend/netify_data.db "PRAGMA integrity_check;" -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_check_mongo.js b/temp_check_mongo.js deleted file mode 100644 index 1e0aafe..0000000 --- a/temp_check_mongo.js +++ /dev/null @@ -1,8 +0,0 @@ -const mongoose = require('mongoose'); -const { AppStat, DeviceStat } = require('./backend/models/Schemas'); - -mongoose.connect('mongodb://127.0.0.1:27017/backone_dpi').then(async () => { - console.log('AppStats count:', await AppStat.countDocuments()); - console.log('DeviceStats count:', await DeviceStat.countDocuments()); - process.exit(0); -}); diff --git a/temp_fetch.js b/temp_fetch.js deleted file mode 100644 index 0d5f564..0000000 --- a/temp_fetch.js +++ /dev/null @@ -1,4 +0,0 @@ -fetch('http://localhost:3000/api/dashboard/apps?limit=10') - .then(r => r.json()) - .then(j => console.log(JSON.stringify(j, null, 2))) - .catch(console.error); diff --git a/temp_fix_cors.js b/temp_fix_cors.js deleted file mode 100644 index 240c1b4..0000000 --- a/temp_fix_cors.js +++ /dev/null @@ -1,26 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -sed -i "s|ALLOWED_ORIGINS=.*|ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,https://backend.demoplace.my.id,http://backend.demoplace.my.id,https://demoplace.my.id,http://demoplace.my.id|g" /home/adminbackend/web/demoplace.my.id/public_html/.env.local -cd /home/adminbackend/web/demoplace.my.id/public_html -npx pm2 restart dpi-api -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_fix_next.js b/temp_fix_next.js deleted file mode 100644 index d66ab42..0000000 --- a/temp_fix_next.js +++ /dev/null @@ -1,33 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -set -e - -echo "=== STOPPING PM2 ===" -npx pm2 delete dpi-web || true - -echo "=== STARTING PM2 ===" -cd /home/adminbackend/web/demoplace.my.id/public_html -# Restarting pm2 daemon and processes -PORT=10000 npx pm2 start ./node_modules/next/dist/bin/next --name "dpi-web" --interpreter /home/adminbackend/node20/bin/node -- start -npx pm2 save -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_fix_pm2.js b/temp_fix_pm2.js deleted file mode 100644 index 7007130..0000000 --- a/temp_fix_pm2.js +++ /dev/null @@ -1,47 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -set -e -export PATH=/home/adminbackend/node20/bin:$PATH - -echo "=== STOPPING PM2 ===" -npx pm2 delete all || true - -echo "=== REBUILDING NATIVE MODULES ===" -cd /home/adminbackend/web/demoplace.my.id/public_html -# Make sure sqlite3 is rebuilt for node20 -npm rebuild better-sqlite3 - -echo "=== STARTING PM2 ===" -# Next.js must run on 10000 because Hestia Nginx proxy looks for 10000 -# Backend API runs on 3001 -PORT=10000 npx pm2 start /home/adminbackend/node20/bin/npm --name "dpi-web" --interpreter /home/adminbackend/node20/bin/node -- start -PORT=3001 npx pm2 start backend/server.js --name "dpi-api" --interpreter /home/adminbackend/node20/bin/node - -npx pm2 save -npx pm2 status -`; - -const conn = new Client(); -conn.on('ready', () => { - console.log('Connected. Running fix script...'); - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code, signal) => { - console.log('Fix script finished with code ' + code); - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).on('error', (err) => { - console.error('SSH Error:', err); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH', - readyTimeout: 99999 -}); diff --git a/temp_fix_port.js b/temp_fix_port.js deleted file mode 100644 index 48085c2..0000000 --- a/temp_fix_port.js +++ /dev/null @@ -1,28 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -export PATH=/home/adminbackend/node20/bin:$PATH -cd /home/adminbackend/web/demoplace.my.id/public_html -npx pm2 delete dpi-web || true -PORT=10000 npx pm2 start /home/adminbackend/node20/bin/npm --name "dpi-web" -- start -npx pm2 save -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_fix_prod.js b/temp_fix_prod.js deleted file mode 100644 index 9038ad1..0000000 --- a/temp_fix_prod.js +++ /dev/null @@ -1,44 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -set -e -export PATH=/home/adminbackend/node20/bin:$PATH -cd /home/adminbackend/web/demoplace.my.id/public_html/backend -echo "=== STOPPING API TO PREVENT WRITES ===" -npx pm2 stop dpi-api || true - -echo "=== FIXING CORS IN .env.local ===" -sed -i "s|ALLOWED_ORIGINS=.*|ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,https://backend.demoplace.my.id,http://backend.demoplace.my.id,https://demoplace.my.id,http://demoplace.my.id|g" /home/adminbackend/web/demoplace.my.id/public_html/.env.local - -echo "=== BACKING UP CORRUPTED DB ===" -cp netify_data.db netify_data_corrupted.db -echo "=== DUMPING CORRUPTED DB TO SQL ===" -sqlite3 netify_data.db ".recover" > recovery.sql || echo "Recovery completed with some warnings" -echo "=== REBUILDING DB ===" -rm netify_data.db -sqlite3 netify_data.db < recovery.sql -rm recovery.sql - -echo "=== RESTARTING API ===" -npx pm2 start dpi-api -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - console.log('Script finished with code ' + code); - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_restore_db.js b/temp_restore_db.js deleted file mode 100644 index 4a0aaf5..0000000 --- a/temp_restore_db.js +++ /dev/null @@ -1,46 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -set -e - -echo "=== STOPPING PM2 ===" -npx pm2 stop all -npx pm2 kill - -echo "=== RESTORING DB FROM BACKUP ===" -cd /home/adminbackend/web/demoplace.my.id/public_html -rm -f backend/netify_data.db backend/netify_data.db-wal backend/netify_data.db-shm -cp /home/adminbackend/deploy_backup/netify_data.db backend/netify_data.db -# (Also copy WAL if it existed in backup, but usually just .db is enough if WAL was checkpointed, -# or copy all of them just in case) -cp /home/adminbackend/deploy_backup/netify_data.db-wal backend/netify_data.db-wal 2>/dev/null || true -cp /home/adminbackend/deploy_backup/netify_data.db-shm backend/netify_data.db-shm 2>/dev/null || true - -echo "=== CHECKING RESTORED DB ===" -sqlite3 backend/netify_data.db "PRAGMA integrity_check;" - -echo "=== STARTING PM2 ===" -# Restarting pm2 daemon and processes -PORT=10000 npx pm2 start /home/adminbackend/node20/bin/npm --name "dpi-web" --interpreter /home/adminbackend/node20/bin/node -- start -PORT=3001 npx pm2 start backend/server.js --name "dpi-api" --interpreter /home/adminbackend/node20/bin/node -npx pm2 save -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_ssh.js b/temp_ssh.js deleted file mode 100644 index 4b2294c..0000000 --- a/temp_ssh.js +++ /dev/null @@ -1,11 +0,0 @@ -const { Client } = require('ssh2'); -const conn = new Client(); -conn.on('ready', () => { - conn.exec('ls -la /home/adminbackend/web/backend.demoplace.my.id/public_html/backend/netify_data.db /home/adminbackend/web/demoplace.my.id/public_html/backend/netify_data.db /home/adminbackend/web/backend.demoplace.my.id/public_html/.env.local /home/adminbackend/web/demoplace.my.id/public_html/.env.local 2>/dev/null', (err, stream) => { - let out = ''; - stream.on('close', () => { - console.log(out); - conn.end(); - }).on('data', d => out += d).stderr.on('data', d => console.error('ERR: ' + d)); - }); -}).connect({ host: '103.185.47.52', port: 2222, username: 'adminbackend', password: 'htEo7x6LsBQiEHHH' }); diff --git a/temp_symlink.js b/temp_symlink.js deleted file mode 100644 index 9890545..0000000 --- a/temp_symlink.js +++ /dev/null @@ -1,28 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -set -e -cd /home/adminbackend/web/demoplace.my.id/public_html -ln -sfn .next _next -echo "Symlink created" -ls -la _next -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_test.js b/temp_test.js deleted file mode 100644 index 173b9b5..0000000 --- a/temp_test.js +++ /dev/null @@ -1,24 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -curl -s -X POST http://localhost:10000/api/auth/admin/update-agent-user -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_test_api.js b/temp_test_api.js deleted file mode 100644 index 641e375..0000000 --- a/temp_test_api.js +++ /dev/null @@ -1,24 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -curl -s -i -X POST -H "Content-Type: application/json" -d '{"username":"admin","password":"password"}' https://demoplace.my.id/api/auth/login -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_test_next.js b/temp_test_next.js deleted file mode 100644 index 947e614..0000000 --- a/temp_test_next.js +++ /dev/null @@ -1,27 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -curl -s -o /dev/null -w "%{http_code}" http://localhost:10000/_next/static/chunks/0rnuuzend4b1r.css -echo "" -curl -s -o /dev/null -w "%{http_code}" http://localhost:10000/ -echo "" -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_test_next_post.js b/temp_test_next_post.js deleted file mode 100644 index 68847ec..0000000 --- a/temp_test_next_post.js +++ /dev/null @@ -1,24 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -curl -s -i -X POST -H "Content-Type: application/json" -d '{"username":"admin","password":"password"}' http://localhost:10000/api/auth/login -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/temp_test_origin.js b/temp_test_origin.js deleted file mode 100644 index 455556a..0000000 --- a/temp_test_origin.js +++ /dev/null @@ -1,24 +0,0 @@ -const { Client } = require('ssh2'); - -const script = ` -curl -s -X POST -H "Origin: https://demoplace.my.id" http://localhost:10000/api/auth/admin/update-agent-user -`; - -const conn = new Client(); -conn.on('ready', () => { - conn.exec(script, (err, stream) => { - if (err) throw err; - stream.on('close', (code) => { - conn.end(); - }).on('data', (data) => { - process.stdout.write(data); - }).stderr.on('data', (data) => { - process.stderr.write(data); - }); - }); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/test_api.js b/test_api.js deleted file mode 100644 index 6f8fd33..0000000 --- a/test_api.js +++ /dev/null @@ -1,25 +0,0 @@ -const { Client } = require('ssh2'); - -const conn = new Client(); - -conn.on('ready', () => { - conn.exec('curl -s http://127.0.0.1:3001/api/dashboard | cut -c 1-200', (err, stream) => { - let data = ''; - if (err) throw err; - stream.on('close', (code, signal) => { - console.log(data); - conn.end(); - }).on('data', (d) => { - data += d; - }).stderr.on('data', (d) => { - process.stderr.write(d); - }); - }); -}).on('error', (err) => { - console.error('SSH Error:', err); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -}); diff --git a/test_fetch.js b/test_fetch.js deleted file mode 100644 index 29c13cd..0000000 --- a/test_fetch.js +++ /dev/null @@ -1,15 +0,0 @@ -const mongoose = require('mongoose'); -const { DeviceStat } = require('./backend/models/Schemas'); -const fs = require('fs'); - -async function run() { - try { - // Note: since server is running, mongodb-memory-server port is dynamic. - // Let's read the mongoose connection URI from the .env or backend memory... - // But we can't easily connect to the dynamic port from outside. - // Instead, let's create a route or bypass auth in dashboard.js temporarily? - // Actually, dashboard.js doesn't seem to have auth middleware on /device-details if we pass a secret or it might not have auth at all? Wait, earlier Invoke-RestMethod said Unauthorized. - } catch (err) { - console.error(err); - } -} diff --git a/test_flows.js b/test_flows.js deleted file mode 100644 index 74da839..0000000 --- a/test_flows.js +++ /dev/null @@ -1,20 +0,0 @@ -const mongoose = require('mongoose'); -const { Flow, Threat } = require('./backend/models/Schemas'); -const timeRange = new Date(Date.now() - 3600*1000); // last 1 hour - -mongoose.connect('mongodb://127.0.0.1:27017/backone_dpi').then(async () => { - try { - const flowCount = await Flow.countDocuments(); - console.log("Total flows in DB:", flowCount); - const threatCount = await Threat.countDocuments(); - console.log("Total threats in DB:", threatCount); - } catch(e) { - console.error(e); - } finally { - process.exit(0); - } -}).catch(e => { - // If running in in-memory mode, we won't be able to connect via port 27017 easily - console.error("Could not connect to mongodb, probably using in-memory DB port."); - process.exit(1); -}); diff --git a/test_ip.js b/test_ip.js deleted file mode 100644 index 6c050a8..0000000 --- a/test_ip.js +++ /dev/null @@ -1,21 +0,0 @@ -const mongoose = require('mongoose'); -const { DeviceStat, Flow } = require('./backend/models/Schemas'); - -mongoose.connect('mongodb://127.0.0.1:27017/backone_dpi').then(async () => { - try { - const ip = "10.6.30.8"; - const device = await DeviceStat.findOne({ ip_address: ip }).sort({ timestamp: -1 }); - console.log("DeviceStat for IP:", device); - - const flowsCount = await Flow.countDocuments({ $or: [{src_ip: ip}, {dst_ip: ip}] }); - console.log("Total flows for IP:", flowsCount); - - const recentFlow = await Flow.findOne({ $or: [{src_ip: ip}, {dst_ip: ip}] }).sort({ timestamp: -1 }); - console.log("Most recent flow:", recentFlow); - - } catch(e) { - console.error(e); - } finally { - process.exit(0); - } -}); diff --git a/verify_backend.js b/verify_backend.js deleted file mode 100644 index c9a426e..0000000 --- a/verify_backend.js +++ /dev/null @@ -1,81 +0,0 @@ -const { Client } = require('ssh2'); - -const conn = new Client(); - -const script = ` -node -e " -const http = require('http'); - -const loginOptions = { - hostname: '127.0.0.1', - port: 3001, - path: '/api/login', - method: 'POST', - headers: { 'Content-Type': 'application/json' } -}; - -const req = http.request(loginOptions, res => { - let data = ''; - res.on('data', d => data += d); - res.on('end', () => { - const session = JSON.parse(data).session_id; - if (!session) { console.log('Login failed'); return; } - - // Test Agent - http.get({ - hostname: '127.0.0.1', - port: 3001, - path: '/api/agents/2F-TF-1D-GK', - headers: { 'Authorization': 'Bearer ' + session } - }, r => { - let d = ''; - r.on('data', c => d += c); - r.on('end', () => { - const agent = JSON.parse(d); - console.log('--- AGENT 2F-TF-1D-GK ---'); - console.log('Devices:', agent.summary.total_devices); - console.log('Flows:', agent.summary.active_flows); - console.log('Download:', agent.summary.bandwidth_down); - console.log('Upload:', agent.summary.bandwidth_up); - console.log('Top Apps count:', agent.top_apps.length); - }); - }); - - // Test Dashboard - http.get({ - hostname: '127.0.0.1', - port: 3001, - path: '/api/dashboard', - headers: { 'Authorization': 'Bearer ' + session } - }, r => { - let d = ''; - r.on('data', c => d += c); - r.on('end', () => { - const dash = JSON.parse(d); - console.log('--- DASHBOARD ---'); - console.log('Total Download:', dash.summary.bandwidth_down); - console.log('Total Upload:', dash.summary.bandwidth_up); - console.log('Devices:', dash.summary.total_devices); - console.log('Flows:', dash.summary.active_flows); - }); - }); - }); -}); -req.write(JSON.stringify({ username: 'admin', password: '123' })); // Wait, default admin is admin / admin -req.end(); -" -`; - -conn.on('ready', () => { - conn.exec(script.replace(/123/g, 'admin'), (err, stream) => { - if (err) throw err; - stream.on('close', () => conn.end()).on('data', d => process.stdout.write(d)).stderr.on('data', d => process.stderr.write(d)); - }); -}).on('error', (err) => { - console.error('SSH Error:', err); -}).connect({ - host: '103.185.47.52', - port: 2222, - username: 'adminbackend', - password: 'htEo7x6LsBQiEHHH' -});