Merge pull request #54 from Nebelung-Dev/main
Proxy switcher (uv, rammer, scram, and meteor), transport switcher (epoxy, libcurl), search engine switcher (a lot of options)
This commit is contained in:
commit
55c4a98846
8 changed files with 233 additions and 120 deletions
|
|
@ -5,7 +5,7 @@ const nextConfig = {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
source: '/settings',
|
source: '/settings',
|
||||||
destination: '/settings/appearance',
|
destination: '/settings/proxy',
|
||||||
permanent: false
|
permanent: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
|
|
@ -3402,7 +3402,7 @@ snapshots:
|
||||||
|
|
||||||
agent-base@6.0.2:
|
agent-base@6.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 4.3.1
|
debug: 4.3.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
optional: true
|
optional: true
|
||||||
|
|
@ -4076,7 +4076,7 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tootallnate/once': 1.1.2
|
'@tootallnate/once': 1.1.2
|
||||||
agent-base: 6.0.2
|
agent-base: 6.0.2
|
||||||
debug: 4.3.1
|
debug: 4.3.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
optional: true
|
optional: true
|
||||||
|
|
@ -4084,7 +4084,7 @@ snapshots:
|
||||||
https-proxy-agent@5.0.1:
|
https-proxy-agent@5.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 6.0.2
|
agent-base: 6.0.2
|
||||||
debug: 4.3.1
|
debug: 4.3.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
optional: true
|
optional: true
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ import next from "next";
|
||||||
const [app, listen] = new ChemicalServer({
|
const [app, listen] = new ChemicalServer({
|
||||||
default: "uv",
|
default: "uv",
|
||||||
uv: true,
|
uv: true,
|
||||||
rammerhead: false,
|
rammerhead: true,
|
||||||
|
experimental: {
|
||||||
|
scramjet: true,
|
||||||
|
meteor: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const port = process.env.PORT || 3000;
|
const port = process.env.PORT || 3000;
|
||||||
const dev = process.env.NODE_ENV !== "production";
|
const dev = process.env.NODE_ENV !== "production";
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,11 @@ export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
ref.current.src = await window.chemical.encode(
|
ref.current.src = await window.chemical.encode(
|
||||||
atob(decodeURIComponent(route)),
|
atob(decodeURIComponent(route)),
|
||||||
{
|
{
|
||||||
|
service: window.chemical.getStore("service"),
|
||||||
autoHttps: true,
|
autoHttps: true,
|
||||||
searchEngine: "https://www.google.com/search?q=%s",
|
searchEngine:
|
||||||
|
window.chemical.getStore("searchEngine") ||
|
||||||
|
"https://www.google.com/search?q=%s",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export default function RootLayout({
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<link rel="icon" href="/icon.png" />
|
<link rel="icon" href="/icon.png" />
|
||||||
<script data-wisp-store src="/chemical.js"></script>
|
<script data-wisp-store data-transport-store src="/chemical.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body className={inter.className}>
|
<body className={inter.className}>
|
||||||
<Themes>
|
<Themes>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Users, Link, Palette, ArrowRightLeft } from "lucide-react";
|
import { Users, Link, Palette, LockIcon } from "lucide-react";
|
||||||
import NextLink from "next/link";
|
import NextLink from "next/link";
|
||||||
|
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
|
|
@ -13,6 +13,16 @@ export default function SettingsLayout({
|
||||||
return (
|
return (
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div className="flex w-1/4 flex-col gap-2 p-4 pl-8 pt-8">
|
<div className="flex w-1/4 flex-col gap-2 p-4 pl-8 pt-8">
|
||||||
|
<NextLink href="/settings/proxy/">
|
||||||
|
<Button
|
||||||
|
variant={
|
||||||
|
pathname?.includes("/settings/proxy/") ? "secondary" : "ghost"
|
||||||
|
}
|
||||||
|
className="w-full items-center justify-start gap-2"
|
||||||
|
>
|
||||||
|
<LockIcon className="h-5 w-5" /> Proxy
|
||||||
|
</Button>
|
||||||
|
</NextLink>
|
||||||
<NextLink href="/settings/appearance/">
|
<NextLink href="/settings/appearance/">
|
||||||
<Button
|
<Button
|
||||||
variant={
|
variant={
|
||||||
|
|
@ -23,16 +33,6 @@ export default function SettingsLayout({
|
||||||
<Palette className="h-5 w-5" /> Appearance
|
<Palette className="h-5 w-5" /> Appearance
|
||||||
</Button>
|
</Button>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
<NextLink href="/settings/wisp/">
|
|
||||||
<Button
|
|
||||||
variant={
|
|
||||||
pathname?.includes("/settings/wisp/") ? "secondary" : "ghost"
|
|
||||||
}
|
|
||||||
className="w-full items-center justify-start gap-2"
|
|
||||||
>
|
|
||||||
<ArrowRightLeft className="h-5 w-5" /> Wisp
|
|
||||||
</Button>
|
|
||||||
</NextLink>
|
|
||||||
<NextLink href="/settings/credits/">
|
<NextLink href="/settings/credits/">
|
||||||
<Button
|
<Button
|
||||||
variant={
|
variant={
|
||||||
|
|
|
||||||
208
src/app/settings/proxy/page.tsx
Normal file
208
src/app/settings/proxy/page.tsx
Normal file
|
|
@ -0,0 +1,208 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/components/ui/form";
|
||||||
|
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
import { Save, RotateCcw } from "lucide-react";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
wispServer: z.string().url("Please provide a valid URL"),
|
||||||
|
description: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function ProxyOptions() {
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: {
|
||||||
|
wispServer: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const wispServer: string = window.chemical.getStore("wisp");
|
||||||
|
const defaultWisp: string =
|
||||||
|
(location.protocol === "https:" ? "wss" : "ws") +
|
||||||
|
"://" +
|
||||||
|
location.host +
|
||||||
|
"/wisp/";
|
||||||
|
form.setValue("wispServer", wispServer !== defaultWisp ? wispServer : "");
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||||
|
setSubmitting(true);
|
||||||
|
|
||||||
|
window.chemical.setStore("wisp", values.wispServer);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setSubmitting(false);
|
||||||
|
toast.success("Settings saved");
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onReset() {
|
||||||
|
form.reset();
|
||||||
|
window.chemical.setStore("wisp", "");
|
||||||
|
toast("Settings reset");
|
||||||
|
}
|
||||||
|
|
||||||
|
const [proxy, setProxy] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setProxy(window.chemical.getStore("service"));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const proxyChanged = (service: string) => {
|
||||||
|
setProxy(service);
|
||||||
|
window.chemical.setStore("service", service);
|
||||||
|
};
|
||||||
|
|
||||||
|
const [searchEngine, setSearchEngine] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSearchEngine(
|
||||||
|
window.chemical.getStore("searchEngine") ||
|
||||||
|
"https://www.google.com/search?q=%s"
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const searchEngineChanged = (service: string) => {
|
||||||
|
setSearchEngine(service);
|
||||||
|
window.chemical.setStore("searchEngine", service);
|
||||||
|
};
|
||||||
|
|
||||||
|
const [transport, setTransport] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTransport(window.chemical.getStore("transport"));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const transportChanged = (service: string) => {
|
||||||
|
setTransport(service);
|
||||||
|
window.chemical.setStore("transport", service);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1 className="text-4xl font-semibold">Proxy</h1>
|
||||||
|
<Separator />
|
||||||
|
<div className="mt-4">
|
||||||
|
<p>Proxy Switcher</p>
|
||||||
|
<Select value={proxy} onValueChange={proxyChanged}>
|
||||||
|
<SelectTrigger className="w-[180px]">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem value="uv">Ultraviolet</SelectItem>
|
||||||
|
<SelectItem value="rammerhead">Rammerhead</SelectItem>
|
||||||
|
<SelectItem value="scramjet">
|
||||||
|
Scramjet (old broken version)
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="meteor">Meteor</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<p>Transport</p>
|
||||||
|
<Select value={transport} onValueChange={transportChanged}>
|
||||||
|
<SelectTrigger className="w-[180px]">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem value="libcurl">Libcurl</SelectItem>
|
||||||
|
<SelectItem value="epoxy">Epoxy</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<p>Search Engine</p>
|
||||||
|
<Select value={searchEngine} onValueChange={searchEngineChanged}>
|
||||||
|
<SelectTrigger className="w-[180px]">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem value="https://www.google.com/search?q=%s">
|
||||||
|
Google
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://duckduckgo.com/?q=%s&ia=web">
|
||||||
|
DuckDuckGo
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://www.bing.com/search?q=%s">
|
||||||
|
Bing
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://search.yahoo.com/search?p=%s">
|
||||||
|
Yahoo
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://search.brave.com/search?q=%s">
|
||||||
|
Brave
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://www.qwant.com/?q=%s&t=web">
|
||||||
|
Qwant
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://searx.si/search?q=%s">
|
||||||
|
SearXNG
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="https://www.ecosia.org/search?method=index&q=%s">
|
||||||
|
Ecosia
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<Form {...form}>
|
||||||
|
<form
|
||||||
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
|
className="w-1/2 space-y-4"
|
||||||
|
>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="wispServer"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Wisp Server Switcher</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Wisp Server URL" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{}
|
||||||
|
<div className="flex space-x-4">
|
||||||
|
<Button type="submit" disabled={submitting}>
|
||||||
|
<Save className="mr-2 h-5 w-5" /> Save Changes
|
||||||
|
</Button>
|
||||||
|
<Button type="button" onClick={onReset}>
|
||||||
|
<RotateCcw className="mr-2 h-5 w-5" /> Reset
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Separator } from "@/components/ui/separator";
|
|
||||||
import { Save, RotateCcw } from "lucide-react";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
|
||||||
wispServer: z.string().url("Please provide a valid URL"),
|
|
||||||
description: z.string().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function WispSwitcher() {
|
|
||||||
const [submitting, setSubmitting] = useState(false);
|
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
|
||||||
resolver: zodResolver(formSchema),
|
|
||||||
defaultValues: {
|
|
||||||
wispServer: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const wispServer: string = window.chemical.getStore("wisp");
|
|
||||||
const defaultWisp: string =
|
|
||||||
(location.protocol === "https:" ? "wss" : "ws") +
|
|
||||||
"://" +
|
|
||||||
location.host +
|
|
||||||
"/wisp/";
|
|
||||||
form.setValue("wispServer", wispServer !== defaultWisp ? wispServer : "");
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
|
||||||
setSubmitting(true);
|
|
||||||
|
|
||||||
window.chemical.setStore("wisp", values.wispServer);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
setSubmitting(false);
|
|
||||||
toast.success("Settings saved");
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onReset() {
|
|
||||||
form.reset();
|
|
||||||
window.chemical.setStore("wisp", "");
|
|
||||||
toast("Settings reset");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1 className="text-4xl font-semibold">Wisp</h1>
|
|
||||||
<Separator />
|
|
||||||
<div className="mt-4">
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="w-1/2 space-y-4"
|
|
||||||
>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="wispServer"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Wisp Server Switcher</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="Wisp Server URL" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{}
|
|
||||||
<div className="flex space-x-4">
|
|
||||||
<Button type="submit" disabled={submitting}>
|
|
||||||
<Save className="mr-2 h-5 w-5" /> Save Changes
|
|
||||||
</Button>
|
|
||||||
<Button type="button" onClick={onReset}>
|
|
||||||
<RotateCcw className="mr-2 h-5 w-5" /> Reset
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue