Spaces:
Sleeping
Sleeping
Commit ·
ba888f3
1
Parent(s): 49f33b3
Local add
Browse files
frontend/src/components/FeatureGuard.jsx
CHANGED
|
@@ -1,114 +1,109 @@
|
|
| 1 |
import React, { useState, useEffect } from "react";
|
| 2 |
-
import { AlertTriangle, Github, Terminal, ShieldAlert,
|
| 3 |
import { motion, AnimatePresence } from "framer-motion";
|
| 4 |
|
| 5 |
const FeatureGuard = ({ children, requireLocal = false }) => {
|
| 6 |
const [isLocal, setIsLocal] = useState(true);
|
|
|
|
| 7 |
const [showPopup, setShowPopup] = useState(false);
|
|
|
|
| 8 |
|
| 9 |
useEffect(() => {
|
| 10 |
const local = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
|
| 11 |
setIsLocal(local);
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}, [requireLocal]);
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
if (isLocal || !requireLocal) return <>{children}</>;
|
| 16 |
|
| 17 |
return (
|
| 18 |
-
<div className="relative min-h-screen bg-[#020617]
|
| 19 |
-
|
| 20 |
-
<div className="blur-xl pointer-events-none opacity-20 grayscale">
|
| 21 |
-
{children}
|
| 22 |
-
</div>
|
| 23 |
|
| 24 |
-
<AnimatePresence>
|
| 25 |
-
{
|
|
|
|
| 26 |
<motion.div
|
| 27 |
-
|
| 28 |
-
animate={{ opacity: 1 }}
|
| 29 |
-
className="fixed inset-0 z-[9999] flex items-center justify-center bg-black/
|
| 30 |
>
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
{/* Header Bar */}
|
| 43 |
-
<div className="bg-cyan-900/20 border-b border-cyan-500/20 p-4 flex items-center justify-between">
|
| 44 |
-
<div className="flex items-center gap-3">
|
| 45 |
-
<ShieldAlert className="text-cyan-400 animate-pulse" size={24} />
|
| 46 |
-
<span className="text-cyan-100 font-mono tracking-widest text-sm uppercase">Access Restricted</span>
|
| 47 |
-
</div>
|
| 48 |
-
<div className="flex gap-1">
|
| 49 |
-
<div className="w-2 h-2 rounded-full bg-red-500/50" />
|
| 50 |
-
<div className="w-2 h-2 rounded-full bg-yellow-500/50" />
|
| 51 |
-
<div className="w-2 h-2 rounded-full bg-green-500/50" />
|
| 52 |
-
</div>
|
| 53 |
-
</div>
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
</div>
|
| 72 |
-
<div className="flex gap-2 text-emerald-400/80">
|
| 73 |
-
<ChevronRight size={14} />
|
| 74 |
-
<span>git clone https://github.com/ayu-yishu13/Astra_Gaurd.git</span>
|
| 75 |
-
</div>
|
| 76 |
-
<div className="flex gap-2 text-cyan-400/80">
|
| 77 |
-
<ChevronRight size={14} />
|
| 78 |
-
<span>python main.py --interface eth0</span>
|
| 79 |
-
</div>
|
| 80 |
-
</div>
|
| 81 |
-
</div>
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
<
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
Disconnect
|
| 98 |
-
</button>
|
| 99 |
-
</div>
|
| 100 |
</div>
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
/>
|
| 109 |
</div>
|
| 110 |
</div>
|
| 111 |
-
</
|
| 112 |
</motion.div>
|
| 113 |
)}
|
| 114 |
</AnimatePresence>
|
|
|
|
| 1 |
import React, { useState, useEffect } from "react";
|
| 2 |
+
import { AlertTriangle, Github, Terminal, ShieldAlert, Copy, Check, Search } from "lucide-react";
|
| 3 |
import { motion, AnimatePresence } from "framer-motion";
|
| 4 |
|
| 5 |
const FeatureGuard = ({ children, requireLocal = false }) => {
|
| 6 |
const [isLocal, setIsLocal] = useState(true);
|
| 7 |
+
const [isScanning, setIsScanning] = useState(false);
|
| 8 |
const [showPopup, setShowPopup] = useState(false);
|
| 9 |
+
const [copied, setCopied] = useState(false);
|
| 10 |
|
| 11 |
useEffect(() => {
|
| 12 |
const local = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
|
| 13 |
setIsLocal(local);
|
| 14 |
+
|
| 15 |
+
if (requireLocal && !local) {
|
| 16 |
+
// Feature 2: Simulated System Scan
|
| 17 |
+
setIsScanning(true);
|
| 18 |
+
const timer = setTimeout(() => {
|
| 19 |
+
setIsScanning(false);
|
| 20 |
+
setShowPopup(true);
|
| 21 |
+
}, 2000); // 2 second scan time
|
| 22 |
+
return () => clearTimeout(timer);
|
| 23 |
+
}
|
| 24 |
}, [requireLocal]);
|
| 25 |
|
| 26 |
+
// Feature 1: Copy to Clipboard Function
|
| 27 |
+
const copyToClipboard = (text) => {
|
| 28 |
+
navigator.clipboard.writeText(text);
|
| 29 |
+
setCopied(true);
|
| 30 |
+
setTimeout(() => setCopied(false), 2000);
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
if (isLocal || !requireLocal) return <>{children}</>;
|
| 34 |
|
| 35 |
return (
|
| 36 |
+
<div className="relative min-h-screen bg-[#020617]">
|
| 37 |
+
<div className="blur-xl pointer-events-none opacity-20 grayscale">{children}</div>
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
<AnimatePresence mode="wait">
|
| 40 |
+
{/* Feature 2: Scanning UI */}
|
| 41 |
+
{isScanning && (
|
| 42 |
<motion.div
|
| 43 |
+
key="scanner"
|
| 44 |
+
initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}
|
| 45 |
+
className="fixed inset-0 z-[9999] flex flex-col items-center justify-center bg-black/90 backdrop-blur-md"
|
| 46 |
>
|
| 47 |
+
<div className="relative w-24 h-24 mb-6">
|
| 48 |
+
<motion.div
|
| 49 |
+
animate={{ rotate: 360 }} transition={{ repeat: Infinity, duration: 2, ease: "linear" }}
|
| 50 |
+
className="absolute inset-0 border-t-2 border-b-2 border-cyan-500 rounded-full"
|
| 51 |
+
/>
|
| 52 |
+
<Search className="absolute inset-0 m-auto text-cyan-400 animate-pulse" size={32} />
|
| 53 |
+
</div>
|
| 54 |
+
<h2 className="text-cyan-100 font-mono tracking-widest uppercase text-sm">Initializing Hardware Probe...</h2>
|
| 55 |
+
<p className="text-cyan-800 font-mono text-xs mt-2">Checking local network interfaces (NICs)</p>
|
| 56 |
+
</motion.div>
|
| 57 |
+
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
{/* Feature 1: Restructured UI with Copy Buttons */}
|
| 60 |
+
{showPopup && !isScanning && (
|
| 61 |
+
<motion.div
|
| 62 |
+
key="popup"
|
| 63 |
+
initial={{ opacity: 0, scale: 0.9 }} animate={{ opacity: 1, scale: 1 }}
|
| 64 |
+
className="fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 p-4"
|
| 65 |
+
>
|
| 66 |
+
<div className="relative w-full max-w-lg bg-[#0b1120] border border-cyan-500/30 rounded-lg overflow-hidden shadow-[0_0_50px_rgba(6,182,212,0.2)]">
|
| 67 |
+
|
| 68 |
+
<div className="bg-cyan-900/20 p-4 flex items-center gap-3 border-b border-cyan-500/20">
|
| 69 |
+
<ShieldAlert className="text-cyan-400" size={20} />
|
| 70 |
+
<span className="text-cyan-100 font-mono text-[11px] uppercase tracking-widest">Hardware Exception</span>
|
| 71 |
+
</div>
|
| 72 |
|
| 73 |
+
<div className="p-8">
|
| 74 |
+
<h2 className="text-2xl font-black text-white mb-2 tracking-tighter uppercase italic">
|
| 75 |
+
Hardware <span className="text-cyan-400">Not Linked</span>
|
| 76 |
+
</h2>
|
| 77 |
+
<p className="text-slate-400 text-sm mb-6">
|
| 78 |
+
Remote deployment detected. To sniff live packets, the kernel requires direct access to your local hardware.
|
| 79 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
{/* Terminal with Copy Buttons */}
|
| 82 |
+
<div className="bg-black/60 rounded border border-cyan-500/10 p-5 mb-8 font-mono text-xs space-y-4">
|
| 83 |
+
<div className="flex items-center justify-between group">
|
| 84 |
+
<span className="text-emerald-400">$ git clone https://github.com/ayu-yishu13/Astra_Gaurd.git</span>
|
| 85 |
+
<button onClick={() => copyToClipboard("git clone https://github.com/ayu-yishu13/Astra_Gaurd.git")} className="text-cyan-600 hover:text-cyan-300">
|
| 86 |
+
{copied ? <Check size={14} /> : <Copy size={14} />}
|
| 87 |
+
</button>
|
| 88 |
+
</div>
|
| 89 |
+
<div className="flex items-center justify-between group">
|
| 90 |
+
<span className="text-cyan-400">$ python main.py --mode live</span>
|
| 91 |
+
<button onClick={() => copyToClipboard("python main.py --mode live")} className="text-cyan-600 hover:text-cyan-300">
|
| 92 |
+
<Copy size={14} />
|
| 93 |
+
</button>
|
| 94 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 95 |
</div>
|
| 96 |
|
| 97 |
+
<div className="grid grid-cols-2 gap-4">
|
| 98 |
+
<button onClick={() => window.open('https://github.com/ayu-yishu13/Astra_Gaurd.git', '_blank')} className="bg-cyan-500 text-black py-3 rounded font-black uppercase text-xs tracking-widest hover:bg-white transition-all">
|
| 99 |
+
Get Agent
|
| 100 |
+
</button>
|
| 101 |
+
<button onClick={() => window.history.back()} className="border border-slate-700 text-slate-400 py-3 rounded font-bold uppercase text-xs tracking-widest hover:bg-slate-800 transition-all">
|
| 102 |
+
Disconnect
|
| 103 |
+
</button>
|
| 104 |
</div>
|
| 105 |
</div>
|
| 106 |
+
</div>
|
| 107 |
</motion.div>
|
| 108 |
)}
|
| 109 |
</AnimatePresence>
|