mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
Fix : MITM
This commit is contained in:
@@ -55,7 +55,19 @@ export default function MitmServerCard({ apiKeys, cloudEnabled, onStatusChange }
|
||||
setLoading(true);
|
||||
setMessage(null);
|
||||
try {
|
||||
if (action === "start") {
|
||||
if (action === "trust-cert") {
|
||||
const res = await fetch("/api/cli-tools/antigravity-mitm", {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ action: "trust-cert", sudoPassword: password }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
setMessage({ type: "success", text: "Certificate trusted successfully" });
|
||||
} else {
|
||||
setMessage({ type: "error", text: data.error || "Failed to trust certificate" });
|
||||
}
|
||||
} else if (action === "start") {
|
||||
const keyToUse = selectedApiKey?.trim()
|
||||
|| (apiKeys?.length > 0 ? apiKeys[0].key : null)
|
||||
|| (!cloudEnabled ? "sk_9router" : null);
|
||||
@@ -120,14 +132,15 @@ export default function MitmServerCard({ apiKeys, cloudEnabled, onStatusChange }
|
||||
<Badge variant="default" size="sm">Stopped</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-1 text-xs text-text-muted">
|
||||
<div className="flex items-center gap-1 text-xs text-text-muted" data-i18n-skip="true">
|
||||
{[
|
||||
{ label: "Cert", ok: status?.certExists },
|
||||
{ label: "Trusted", ok: status?.certTrusted },
|
||||
{ label: "Server", ok: isRunning },
|
||||
].map(({ label, ok }) => (
|
||||
<span key={label} className={`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${ok ? "text-green-600" : "text-text-muted"}`}>
|
||||
<span className={`material-symbols-outlined text-[12px]`}>
|
||||
{ok ? "check_circle" : "radio_button_unchecked"}
|
||||
<span className="material-symbols-outlined text-[12px]">
|
||||
{ok ? "check_circle" : "cancel"}
|
||||
</span>
|
||||
{label}
|
||||
</span>
|
||||
@@ -173,7 +186,18 @@ export default function MitmServerCard({ apiKeys, cloudEnabled, onStatusChange }
|
||||
)}
|
||||
|
||||
{/* Action button */}
|
||||
<div className="flex items-center gap-2" data-i18n-skip="true">
|
||||
<div className="flex items-center gap-2 flex-wrap" data-i18n-skip="true">
|
||||
{/* Trust Cert button — only when cert exists but not trusted */}
|
||||
{status?.certExists && !status?.certTrusted && !isRunning && (
|
||||
<button
|
||||
onClick={() => handleAction("trust-cert")}
|
||||
disabled={loading}
|
||||
className="px-4 py-1.5 rounded-lg bg-yellow-500/10 border border-yellow-500/30 text-yellow-600 font-medium text-xs flex items-center gap-1.5 hover:bg-yellow-500/20 transition-colors disabled:opacity-50"
|
||||
>
|
||||
<span className="material-symbols-outlined text-[16px]">verified_user</span>
|
||||
Trust Cert
|
||||
</button>
|
||||
)}
|
||||
{isRunning ? (
|
||||
<button
|
||||
onClick={() => handleAction("stop")}
|
||||
|
||||
@@ -109,7 +109,8 @@ export default function MitmToolCard({
|
||||
if (action === "enable") {
|
||||
setMessage({
|
||||
type: "success",
|
||||
text: `DNS enabled successfully. Please restart ${tool.name} to apply changes.`,
|
||||
text: "DNS enabled successfully.",
|
||||
warning: `Please restart ${tool.name} to apply changes.`,
|
||||
});
|
||||
} else {
|
||||
setMessage({
|
||||
@@ -185,9 +186,17 @@ export default function MitmToolCard({
|
||||
</div>
|
||||
|
||||
{message && (
|
||||
<div className={`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${message.type === "success" ? "bg-green-500/10 text-green-600" : "bg-red-500/10 text-red-600"}`}>
|
||||
<span className="material-symbols-outlined text-[14px]">{message.type === "success" ? "check_circle" : "error"}</span>
|
||||
<span>{message.text}</span>
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className={`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${message.type === "success" ? "bg-green-500/10 text-green-600" : "bg-red-500/10 text-red-600"}`}>
|
||||
<span className="material-symbols-outlined text-[14px]">{message.type === "success" ? "check_circle" : "error"}</span>
|
||||
<span>{message.text}</span>
|
||||
</div>
|
||||
{message.warning && (
|
||||
<div className="flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20">
|
||||
<span className="material-symbols-outlined text-[14px]">warning</span>
|
||||
<span className="font-medium">{message.warning}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user