feat: rebrand Netify to BackOne and resolve lookup database bug
This commit is contained in:
1 parent
8e22884464
commit
739ca8934e
7 files changed
+75
-33
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* generate_export.js
|
* generate_export.js
|
||||||
*
|
*
|
||||||
* Mengekspor SELURUH data dari semua tabel SQLite (netify_data.db)
|
* Mengekspor SELURUH data dari semua tabel SQLite (database)
|
||||||
* ke dalam file netify_data_export.txt
|
* ke dalam file backone_data_export.txt
|
||||||
*
|
*
|
||||||
* Format output:
|
* Format output:
|
||||||
* - Header metadata (tanggal, versi, jumlah tabel)
|
* - Header metadata (tanggal, versi, jumlah tabel)
|
||||||
@@ -14,7 +14,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const db = require('./database');
|
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();
|
const d = db.getDB();
|
||||||
|
|
||||||
// ─── Helpers ────────────────────────────────────────────────────────────────
|
// ─── Helpers ────────────────────────────────────────────────────────────────
|
||||||
@@ -49,7 +49,7 @@ function sectionHeader(tableName, rowCount, description) {
|
|||||||
|
|
||||||
// ─── Table descriptions ──────────────────────────────────────────────────────
|
// ─── Table descriptions ──────────────────────────────────────────────────────
|
||||||
const 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)',
|
bandwidth_timeline : 'Timeline bandwidth per menit (download/upload historis)',
|
||||||
bittorrent_info_hashes: 'Deteksi aktivitas BitTorrent berdasarkan info hash',
|
bittorrent_info_hashes: 'Deteksi aktivitas BitTorrent berdasarkan info hash',
|
||||||
countries : 'Distribusi traffic berdasarkan negara tujuan',
|
countries : 'Distribusi traffic berdasarkan negara tujuan',
|
||||||
@@ -57,7 +57,7 @@ const TABLE_DESCRIPTIONS = {
|
|||||||
dhcp_fingerprints : 'Fingerprint DHCP untuk identifikasi tipe device',
|
dhcp_fingerprints : 'Fingerprint DHCP untuk identifikasi tipe device',
|
||||||
discovered_os : 'OS yang terdeteksi dari traffic scanning',
|
discovered_os : 'OS yang terdeteksi dari traffic scanning',
|
||||||
dns_stats : 'Query DNS teratas dan statistik resolusi domain',
|
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)',
|
flows : 'Data aliran jaringan per-sesi (src IP, dst IP, aplikasi, domain, bytes)',
|
||||||
flow_origins : 'Asal flow: lokal (LAN) atau eksternal (WAN)',
|
flow_origins : 'Asal flow: lokal (LAN) atau eksternal (WAN)',
|
||||||
flow_types : 'Tipe flow: TCP, UDP, ICMP, dll',
|
flow_types : 'Tipe flow: TCP, UDP, ICMP, dll',
|
||||||
@@ -99,13 +99,13 @@ async function main() {
|
|||||||
|
|
||||||
// ── File Header ──────────────────────────────────────────────────────────
|
// ── File Header ──────────────────────────────────────────────────────────
|
||||||
lines.push(separator('═'));
|
lines.push(separator('═'));
|
||||||
lines.push(' NETIFY DATA EXPORT');
|
lines.push(' BACKONE DATA EXPORT');
|
||||||
lines.push(' Seluruh data hasil parsing dari Netify API');
|
lines.push(' Seluruh data hasil parsing dari BackOne API');
|
||||||
lines.push(separator('─'));
|
lines.push(separator('─'));
|
||||||
lines.push(` Export Date: ${exportDate}`);
|
lines.push(` Export Date: ${exportDate}`);
|
||||||
lines.push(` Generated by: generate_export.js`);
|
lines.push(` Generated by: generate_export.js`);
|
||||||
lines.push(` Source: netify_data.db (SQLite lokal)`);
|
lines.push(` Source: database (SQLite lokal)`);
|
||||||
lines.push(` API Base: https://informatics.netify.ai`);
|
lines.push(` API Base: BackOne API Service`);
|
||||||
lines.push(` Format: Per-tabel, data JSON satu record per baris (JSONL)`);
|
lines.push(` Format: Per-tabel, data JSON satu record per baris (JSONL)`);
|
||||||
lines.push(separator('─'));
|
lines.push(separator('─'));
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -3,13 +3,13 @@ const path = require('path');
|
|||||||
require('dotenv').config({ path: path.join(__dirname, '..', '.env.local') });
|
require('dotenv').config({ path: path.join(__dirname, '..', '.env.local') });
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const BASE_URL = 'https://informatics.netify.ai/api/v1';
|
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.NETIFY_TOKEN || process.env.NETIFY_JWT_TOKEN;
|
const JWT_TOKEN = process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_TOKEN || process.env.NETIFY_JWT_TOKEN;
|
||||||
const SITE_UUID = process.env.NETIFY_SITE_UUID;
|
const SITE_UUID = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID;
|
||||||
const agentMap = {};
|
const agentMap = {};
|
||||||
|
|
||||||
function headersSite(useApiKey = false) {
|
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' };
|
const headers = { 'x-api-key': token, 'Accept': 'application/json' };
|
||||||
if (SITE_UUID) {
|
if (SITE_UUID) {
|
||||||
headers['x-net-site'] = SITE_UUID;
|
headers['x-net-site'] = SITE_UUID;
|
||||||
|
|||||||
@@ -4,6 +4,31 @@ const router = express.Router();
|
|||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const { runPoll } = require('../scheduler');
|
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)
|
// GET /api/dashboard/summary — kartu ringkasan (top of page)
|
||||||
router.get('/summary', (req, res) => {
|
router.get('/summary', (req, res) => {
|
||||||
const isAgent = req.user?.role === 'AGENT_VIEWER';
|
const isAgent = req.user?.role === 'AGENT_VIEWER';
|
||||||
|
|||||||
@@ -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>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> > <strong>API Keys</strong>.</li>
|
<li>Di menu sebelah kiri, navigasikan ke <strong>Settings</strong> > <strong>API Keys</strong>.</li>
|
||||||
<li>Buat atau salin kunci tipe <strong>Standard API Key</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>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -83,15 +83,23 @@ export default function LookupPage() {
|
|||||||
<div className="flex items-start justify-between">
|
<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">
|
<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 ? (
|
{app.favicon || app.logo ? (
|
||||||
|
<>
|
||||||
<img
|
<img
|
||||||
src={app.favicon || app.logo}
|
src={app.favicon || app.logo}
|
||||||
alt={app.label}
|
alt={app.label}
|
||||||
className="h-6 w-6 object-contain"
|
className="h-6 w-6 object-contain"
|
||||||
onError={(e) => {
|
onError={(e) => {
|
||||||
// If image fails, replace with default icon
|
// If image fails, hide it and show the sibling icon
|
||||||
(e.target as HTMLElement).style.display = 'none';
|
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" />
|
<AppWindow className="h-5 w-5 text-slate-400" />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -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';
|
const localBase = process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:3001';
|
||||||
destinationUrl = `${localBase}/api/${route}${url.search}`;
|
destinationUrl = `${localBase}/api/${route}${url.search}`;
|
||||||
} else {
|
} 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}`;
|
destinationUrl = `${baseUrl}/${route}${url.search}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,11 +41,15 @@ async function handleProxy(req: NextRequest, { params }: { params: Promise<{ rou
|
|||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
if (routeArray[0] !== 'auth' && routeArray[0] !== 'dashboard') {
|
if (routeArray[0] !== 'auth' && routeArray[0] !== 'dashboard') {
|
||||||
if (process.env.NETIFY_JWT_TOKEN && process.env.NETIFY_SITE_UUID) {
|
const jwtToken = process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN;
|
||||||
headers.set('x-api-key', process.env.NETIFY_JWT_TOKEN);
|
const siteUuid = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID;
|
||||||
headers.set('x-net-site', process.env.NETIFY_SITE_UUID);
|
const apiKey = process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY;
|
||||||
} else if (process.env.NETIFY_API_KEY) {
|
|
||||||
headers.set('x-api-key', process.env.NETIFY_API_KEY);
|
if (jwtToken && siteUuid) {
|
||||||
|
headers.set('x-api-key', jwtToken);
|
||||||
|
headers.set('x-net-site', siteUuid);
|
||||||
|
} else if (apiKey) {
|
||||||
|
headers.set('x-api-key', apiKey);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For local auth/dashboard routes, pass along the cookie for authentication
|
// For local auth/dashboard routes, pass along the cookie for authentication
|
||||||
|
|||||||
+16
-11
@@ -2,16 +2,21 @@
|
|||||||
|
|
||||||
import { revalidatePath } from "next/cache";
|
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
|
// Helper function to get headers
|
||||||
const getHeaders = () => {
|
const getHeaders = () => {
|
||||||
const API_KEY = process.env.NETIFY_API_KEY;
|
const API_KEY = getApiKey();
|
||||||
const JWT_TOKEN = process.env.NETIFY_JWT_TOKEN;
|
const JWT_TOKEN = getJwtToken();
|
||||||
const SITE_UUID = process.env.NETIFY_SITE_UUID;
|
const SITE_UUID = getSiteUuid();
|
||||||
|
|
||||||
if (!API_KEY && !JWT_TOKEN) {
|
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> = {
|
const headers: Record<string, string> = {
|
||||||
@@ -49,8 +54,8 @@ export interface Agent {
|
|||||||
|
|
||||||
export async function getAgents(): Promise<Agent[]> {
|
export async function getAgents(): Promise<Agent[]> {
|
||||||
try {
|
try {
|
||||||
const API_KEY = process.env.NETIFY_API_KEY;
|
const API_KEY = getApiKey();
|
||||||
const SITE_UUID = process.env.NETIFY_SITE_UUID;
|
const SITE_UUID = getSiteUuid();
|
||||||
|
|
||||||
// Fallback to Informatics Scorecard Agent if site-scoped API key is used
|
// Fallback to Informatics Scorecard Agent if site-scoped API key is used
|
||||||
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
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> {
|
export async function getAgent(agentId: string): Promise<Agent | null> {
|
||||||
try {
|
try {
|
||||||
const API_KEY = process.env.NETIFY_API_KEY;
|
const API_KEY = getApiKey();
|
||||||
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
||||||
const agents = await getAgents();
|
const agents = await getAgents();
|
||||||
return agents.find(a => a.uuid === agentId || String(a.id) === agentId) || null;
|
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) {
|
export async function createAgent(agentId: string, label: string) {
|
||||||
try {
|
try {
|
||||||
const API_KEY = process.env.NETIFY_API_KEY;
|
const API_KEY = getApiKey();
|
||||||
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
||||||
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan membuat Agents." };
|
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) {
|
export async function updateAgent(agentId: string, label: string) {
|
||||||
try {
|
try {
|
||||||
const API_KEY = process.env.NETIFY_API_KEY;
|
const API_KEY = getApiKey();
|
||||||
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
||||||
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan mengubah Agents." };
|
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) {
|
export async function deleteAgent(agentId: string) {
|
||||||
try {
|
try {
|
||||||
const API_KEY = process.env.NETIFY_API_KEY;
|
const API_KEY = getApiKey();
|
||||||
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
if (API_KEY && API_KEY.startsWith("sk_db_")) {
|
||||||
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan menghapus Agents." };
|
return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan menghapus Agents." };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user