This commit is contained in:
Rafif-Riqullah-Siregar committed 2026-07-06 09:29:01 +07:00
commit 0e1b774be9
9 files changed
+84 -40

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ backend/*.sqlite
*.db
*.db-shm
*.db-wal
!backend/netify_data.db
# reports and temporary docx folders
Laporan_*.docx
+9 -9
View File
@@ -1,8 +1,8 @@
/**
* generate_export.js
*
* Mengekspor SELURUH data dari semua tabel SQLite (netify_data.db)
* ke dalam file netify_data_export.txt
* Mengekspor SELURUH data dari semua tabel SQLite (database)
* ke dalam file backone_data_export.txt
*
* Format output:
* - Header metadata (tanggal, versi, jumlah tabel)
@@ -14,7 +14,7 @@ const fs = require('fs');
const path = require('path');
const db = require('./database');
const OUTPUT_FILE = path.join(__dirname, '../netify_data_export.txt');
const OUTPUT_FILE = path.join(__dirname, '../backone_data_export.txt');
const d = db.getDB();
// ─── Helpers ────────────────────────────────────────────────────────────────
@@ -49,7 +49,7 @@ function sectionHeader(tableName, rowCount, description) {
// ─── Table descriptions ──────────────────────────────────────────────────────
const TABLE_DESCRIPTIONS = {
bandwidth_apps : 'Bandwidth per aplikasi (YouTube, Facebook, dll) dari Netify DPI',
bandwidth_apps : 'Bandwidth per aplikasi (YouTube, Facebook, dll) dari BackOne DPI',
bandwidth_timeline : 'Timeline bandwidth per menit (download/upload historis)',
bittorrent_info_hashes: 'Deteksi aktivitas BitTorrent berdasarkan info hash',
countries : 'Distribusi traffic berdasarkan negara tujuan',
@@ -57,7 +57,7 @@ const TABLE_DESCRIPTIONS = {
dhcp_fingerprints : 'Fingerprint DHCP untuk identifikasi tipe device',
discovered_os : 'OS yang terdeteksi dari traffic scanning',
dns_stats : 'Query DNS teratas dan statistik resolusi domain',
events : 'Event log dari Netify agent (koneksi, peringatan, dll)',
events : 'Event log dari BackOne agent (koneksi, peringatan, dll)',
flows : 'Data aliran jaringan per-sesi (src IP, dst IP, aplikasi, domain, bytes)',
flow_origins : 'Asal flow: lokal (LAN) atau eksternal (WAN)',
flow_types : 'Tipe flow: TCP, UDP, ICMP, dll',
@@ -99,13 +99,13 @@ async function main() {
// ── File Header ──────────────────────────────────────────────────────────
lines.push(separator('═'));
lines.push(' NETIFY DATA EXPORT');
lines.push(' Seluruh data hasil parsing dari Netify API');
lines.push(' BACKONE DATA EXPORT');
lines.push(' Seluruh data hasil parsing dari BackOne API');
lines.push(separator('─'));
lines.push(` Export Date: ${exportDate}`);
lines.push(` Generated by: generate_export.js`);
lines.push(` Source: netify_data.db (SQLite lokal)`);
lines.push(` API Base: https://informatics.netify.ai`);
lines.push(` Source: database (SQLite lokal)`);
lines.push(` API Base: BackOne API Service`);
lines.push(` Format: Per-tabel, data JSON satu record per baris (JSONL)`);
lines.push(separator('─'));
+4 -4
View File
@@ -3,13 +3,13 @@ const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '..', '.env.local') });
const axios = require('axios');
const BASE_URL = 'https://informatics.netify.ai/api/v1';
const JWT_TOKEN = process.env.NETIFY_TOKEN || process.env.NETIFY_JWT_TOKEN;
const SITE_UUID = process.env.NETIFY_SITE_UUID;
const BASE_URL = process.env.BACKONE_INFORMATICS_BASE_URL || process.env.NETIFY_INFORMATICS_BASE_URL || 'https://informatics.netify.ai/api/v1';
const JWT_TOKEN = process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_TOKEN || process.env.NETIFY_JWT_TOKEN;
const SITE_UUID = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID;
const agentMap = {};
function headersSite(useApiKey = false) {
const token = process.env.NETIFY_API_KEY || JWT_TOKEN;
const token = process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY || JWT_TOKEN;
const headers = { 'x-api-key': token, 'Accept': 'application/json' };
if (SITE_UUID) {
headers['x-net-site'] = SITE_UUID;
Binary file not shown.
+25
View File
@@ -4,6 +4,31 @@ const router = express.Router();
const db = require('../database');
const { runPoll } = require('../scheduler');
// Rebrand Netify values dynamically in dashboard responses using safe JSON string serialization
router.use((req, res, next) => {
const originalJson = res.json;
res.json = function (body) {
if (body) {
try {
const jsonStr = JSON.stringify(body);
const sanitizedStr = jsonStr
.replace(/netify\.unclassified/gi, 'backone.unclassified')
.replace(/netify\.(?!ai)/gi, 'backone.')
.replace(/Netify's/g, "BackOne's")
.replace(/netify's/g, "backone's")
.replace(/Netify(?!(\.ai))/g, 'BackOne')
.replace(/netify(?!(\.ai))/g, 'backone');
body = JSON.parse(sanitizedStr);
} catch (err) {
console.error('Error rebranding JSON response:', err);
}
}
return originalJson.call(this, body);
};
next();
});
// GET /api/dashboard/summary — kartu ringkasan (top of page)
router.get('/summary', (req, res) => {
const isAgent = req.user?.role === 'AGENT_VIEWER';
+1 -1
View File
@@ -218,7 +218,7 @@ export default function AgentsPage() {
<li>Buka dan login ke portal <a href="https://portal.netify.ai" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline font-medium">BackOne Portal</a>.</li>
<li>Di menu sebelah kiri, navigasikan ke <strong>Settings</strong> &gt; <strong>API Keys</strong>.</li>
<li>Buat atau salin kunci tipe <strong>Standard API Key</strong>.</li>
<li>Buka file <code className="text-slate-200">.env.local</code> di proyek Anda, lalu ganti nilai <code className="text-slate-200">NETIFY_API_KEY</code> dengan kunci baru tersebut.</li>
<li>Buka file <code className="text-slate-200">.env.local</code> di proyek Anda, lalu ganti nilai <code className="text-slate-200">BACKONE_API_KEY</code> (atau <code className="text-slate-200">NETIFY_API_KEY</code>) dengan kunci baru tersebut.</li>
</ol>
</div>
</div>
+17 -9
View File
@@ -83,15 +83,23 @@ export default function LookupPage() {
<div className="flex items-start justify-between">
<div className="h-10 w-10 rounded-lg bg-secondary/80 flex items-center justify-center overflow-hidden border border-border/40 group-hover:border-primary/20 transition-all">
{app.favicon || app.logo ? (
<img
src={app.favicon || app.logo}
alt={app.label}
className="h-6 w-6 object-contain"
onError={(e) => {
// If image fails, replace with default icon
(e.target as HTMLElement).style.display = 'none';
}}
/>
<>
<img
src={app.favicon || app.logo}
alt={app.label}
className="h-6 w-6 object-contain"
onError={(e) => {
// If image fails, hide it and show the sibling icon
const img = e.target as HTMLElement;
img.style.display = 'none';
const sibling = img.nextSibling as HTMLElement;
if (sibling) {
sibling.style.display = 'block';
}
}}
/>
<AppWindow className="h-5 w-5 text-slate-400" style={{ display: 'none' }} />
</>
) : (
<AppWindow className="h-5 w-5 text-slate-400" />
)}
+11 -6
View File
@@ -32,7 +32,7 @@ async function handleProxy(req: NextRequest, { params }: { params: Promise<{ rou
const localBase = process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:3001';
destinationUrl = `${localBase}/api/${route}${url.search}`;
} else {
const baseUrl = process.env.NETIFY_BASE_URL || 'https://manager.netify.ai/api/v1';
const baseUrl = process.env.BACKONE_BASE_URL || process.env.NETIFY_BASE_URL || 'https://manager.netify.ai/api/v1';
destinationUrl = `${baseUrl}/${route}${url.search}`;
}
@@ -41,11 +41,16 @@ async function handleProxy(req: NextRequest, { params }: { params: Promise<{ rou
headers.set('Content-Type', 'application/json');
if (routeArray[0] !== 'auth' && routeArray[0] !== 'dashboard') {
if (process.env.NETIFY_JWT_TOKEN && process.env.NETIFY_SITE_UUID) {
headers.set('x-api-key', process.env.NETIFY_JWT_TOKEN);
headers.set('x-net-site', process.env.NETIFY_SITE_UUID);
} else if (process.env.NETIFY_API_KEY) {
headers.set('x-api-key', process.env.NETIFY_API_KEY);
const apiKey = process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY;
const jwtToken = process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN;
const siteUuid = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID;
const apiToken = apiKey || jwtToken;
if (apiToken) {
headers.set('x-api-key', apiToken);
}
if (siteUuid) {
headers.set('x-net-site', siteUuid);
}
} else {
// For local auth/dashboard routes, pass along the cookie for authentication
+16 -11
View File
@@ -2,16 +2,21 @@
import { revalidatePath } from "next/cache";
const API_URL = process.env.NETIFY_BASE_URL ? `${process.env.NETIFY_BASE_URL}/assets/agents` : "https://manager.netify.ai/api/v1/assets/agents";
const BASE_URL = process.env.BACKONE_BASE_URL || process.env.NETIFY_BASE_URL;
const API_URL = BASE_URL ? `${BASE_URL}/assets/agents` : "https://manager.netify.ai/api/v1/assets/agents";
const getApiKey = () => process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY;
const getJwtToken = () => process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN;
const getSiteUuid = () => process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID;
// Helper function to get headers
const getHeaders = () => {
const API_KEY = process.env.NETIFY_API_KEY;
const JWT_TOKEN = process.env.NETIFY_JWT_TOKEN;
const SITE_UUID = process.env.NETIFY_SITE_UUID;
const API_KEY = getApiKey();
const JWT_TOKEN = getJwtToken();
const SITE_UUID = getSiteUuid();
if (!API_KEY && !JWT_TOKEN) {
throw new Error("NETIFY_API_KEY or NETIFY_JWT_TOKEN is not set in environment variables");
throw new Error("BACKONE_API_KEY or BACKONE_JWT_TOKEN is not set in environment variables");
}
const headers: Record<string, string> = {
@@ -49,8 +54,8 @@ export interface Agent {
export async function getAgents(): Promise<Agent[]> {
try {
const API_KEY = process.env.NETIFY_API_KEY;
const SITE_UUID = process.env.NETIFY_SITE_UUID;
const API_KEY = getApiKey();
const SITE_UUID = getSiteUuid();
// Fallback to Informatics Scorecard Agent if site-scoped API key is used
if (API_KEY && API_KEY.startsWith("sk_db_")) {
@@ -182,7 +187,7 @@ export async function getAgents(): Promise<Agent[]> {
export async function getAgent(agentId: string): Promise<Agent | null> {
try {
const API_KEY = process.env.NETIFY_API_KEY;
const API_KEY = getApiKey();
if (API_KEY && API_KEY.startsWith("sk_db_")) {
const agents = await getAgents();
return agents.find(a => a.uuid === agentId || String(a.id) === agentId) || null;
@@ -208,7 +213,7 @@ export async function getAgent(agentId: string): Promise<Agent | null> {
export async function createAgent(agentId: string, label: string) {
try {
const API_KEY = process.env.NETIFY_API_KEY;
const API_KEY = getApiKey();
if (API_KEY && API_KEY.startsWith("sk_db_")) {
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan membuat Agents." };
}
@@ -236,7 +241,7 @@ export async function createAgent(agentId: string, label: string) {
export async function updateAgent(agentId: string, label: string) {
try {
const API_KEY = process.env.NETIFY_API_KEY;
const API_KEY = getApiKey();
if (API_KEY && API_KEY.startsWith("sk_db_")) {
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan mengubah Agents." };
}
@@ -260,7 +265,7 @@ export async function updateAgent(agentId: string, label: string) {
export async function deleteAgent(agentId: string) {
try {
const API_KEY = process.env.NETIFY_API_KEY;
const API_KEY = getApiKey();
if (API_KEY && API_KEY.startsWith("sk_db_")) {
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan menghapus Agents." };
}