From 43dee863cd5b9d43d79c603021b747ef290ab544 Mon Sep 17 00:00:00 2001
From: Sefa Eyeoglu <contact@scrumplex.net>
Date: Thu, 18 Aug 2022 23:50:59 +0200
Subject: Add CEF Remote Debugging toggle (#129)

* feat: add CEF Remote Debugging toggle

* feat: disable remote debugger on startup

* refactor: stop debugger instead of disable

* feat: add option to allow remote debugging by default

Co-authored-by: TrainDoctor <traindoctor@protonmail.com>
---
 .../settings/pages/general/RemoteDebugging.tsx     | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 frontend/src/components/settings/pages/general/RemoteDebugging.tsx

(limited to 'frontend/src/components/settings/pages/general/RemoteDebugging.tsx')

diff --git a/frontend/src/components/settings/pages/general/RemoteDebugging.tsx b/frontend/src/components/settings/pages/general/RemoteDebugging.tsx
new file mode 100644
index 00000000..1310263f
--- /dev/null
+++ b/frontend/src/components/settings/pages/general/RemoteDebugging.tsx
@@ -0,0 +1,34 @@
+import { Field, ToggleField } from 'decky-frontend-lib';
+import { useEffect, useState } from 'react';
+import { FaBug } from 'react-icons/fa';
+
+export default function RemoteDebuggingSettings() {
+  const [allowRemoteDebugging, setAllowRemoteDebugging] = useState<boolean>(false);
+  useEffect(() => {
+    (async () => {
+      const res = (await window.DeckyPluginLoader.callServerMethod('remote_debugging_allowed')) as { result: boolean };
+      setAllowRemoteDebugging(res.result);
+    })();
+  }, []);
+
+  return (
+    <Field
+      label="Allow Remote CEF Debugging"
+      description={
+        <span style={{ whiteSpace: 'pre-line' }}>
+          Allow unauthenticated access to the CEF debugger to anyone in your network
+        </span>
+      }
+      icon={<FaBug style={{ display: 'block' }} />}
+    >
+      <ToggleField
+        checked={allowRemoteDebugging}
+        onChange={(toggleValue) => {
+          setAllowRemoteDebugging(toggleValue);
+          if (toggleValue) window.DeckyPluginLoader.callServerMethod('allow_remote_debugging');
+          else window.DeckyPluginLoader.callServerMethod('disallow_remote_debugging');
+        }}
+      />
+    </Field>
+  );
+}
-- 
cgit v1.2.3

