CodebaseAi commited on
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, Cpu, ChevronRight } 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 [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
- if (requireLocal && !local) setShowPopup(true);
 
 
 
 
 
 
 
 
 
13
  }, [requireLocal]);
14
 
 
 
 
 
 
 
 
15
  if (isLocal || !requireLocal) return <>{children}</>;
16
 
17
  return (
18
- <div className="relative min-h-screen bg-[#020617] overflow-hidden">
19
- {/* Blurred background content */}
20
- <div className="blur-xl pointer-events-none opacity-20 grayscale">
21
- {children}
22
- </div>
23
 
24
- <AnimatePresence>
25
- {showPopup && (
 
26
  <motion.div
27
- initial={{ opacity: 0 }}
28
- animate={{ opacity: 1 }}
29
- className="fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm p-4"
30
  >
31
- {/* Holographic Card */}
32
- <motion.div
33
- initial={{ scale: 0.9, y: 20, rotateX: 15 }}
34
- animate={{ scale: 1, y: 0, rotateX: 0 }}
35
- className="relative w-full max-w-lg overflow-hidden"
36
- >
37
- {/* Animated Border Glow */}
38
- <div className="absolute inset-0 bg-gradient-to-r from-cyan-500 via-transparent to-purple-500 opacity-20 animate-pulse" />
39
-
40
- <div className="relative bg-[#0b1120]/90 border border-cyan-500/30 rounded-lg p-1 shadow-[0_0_30px_rgba(6,182,212,0.15)]">
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
- <div className="p-8">
56
- <h2 className="text-3xl font-black text-white mb-2 italic tracking-tighter uppercase">
57
- Hardware <span className="text-cyan-400">Not Found</span>
58
- </h2>
59
- <p className="text-slate-400 text-sm mb-6 leading-relaxed">
60
- System detected <span className="text-cyan-300 font-mono">REMOTE_HOST_DEPLOYMENT</span>.
61
- Sniffing requires direct Kernel access to physical NICs. Browsers block low-level socket IO for security.
62
- </p>
 
 
 
 
 
63
 
64
- {/* Terminal Section */}
65
- <div className="relative bg-black/60 rounded border border-cyan-500/10 p-5 mb-8 font-mono text-[13px] group">
66
- <div className="absolute top-2 right-2 text-[10px] text-cyan-700 uppercase">Local Shell</div>
67
- <div className="space-y-2">
68
- <div className="flex gap-2">
69
- <span className="text-cyan-600">❯</span>
70
- <span className="text-slate-300 italic">deploy_agent --init</span>
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
- {/* Action Buttons */}
84
- <div className="grid grid-cols-2 gap-4">
85
- <button
86
- onClick={() => window.open('https://github.com/ayu-yishu13/NetraIDS', '_blank')}
87
- className="group relative flex items-center justify-center gap-2 bg-cyan-500 text-black py-3 rounded font-black uppercase text-xs tracking-widest hover:bg-white transition-all overflow-hidden"
88
- >
89
- <Github size={16} />
90
- Clone Agent
91
- </button>
92
-
93
- <button
94
- onClick={() => window.history.back()}
95
- className="border border-slate-700 text-slate-400 py-3 rounded font-bold uppercase text-xs tracking-widest hover:bg-slate-800 transition-all"
96
- >
97
- Disconnect
98
- </button>
99
- </div>
100
  </div>
101
 
102
- {/* Footer Scanning Animation */}
103
- <div className="h-1 w-full bg-cyan-900/30 relative overflow-hidden">
104
- <motion.div
105
- animate={{ x: ['-100%', '100%'] }}
106
- transition={{ duration: 2, repeat: Infinity, ease: "linear" }}
107
- className="absolute inset-0 bg-gradient-to-r from-transparent via-cyan-400 to-transparent w-1/2"
108
- />
109
  </div>
110
  </div>
111
- </motion.div>
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>