Formatting
This commit is contained in:
parent
69823802f5
commit
8f531aff11
14 changed files with 568 additions and 541 deletions
|
|
@ -158,8 +158,7 @@ server.on("upgrade", (req: Request, socket: Socket, head: Head) => {
|
|||
bare.routeUpgrade(req, socket, head);
|
||||
} else if (shouldRouteRh(req)) {
|
||||
routeRhUpgrade(req, socket, head);
|
||||
}
|
||||
else if (req.url.endsWith("/wisp/")) {
|
||||
} else if (req.url.endsWith("/wisp/")) {
|
||||
wisp.routeRequest(req, socket, head);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ interface Option {
|
|||
const Dropdown = ({
|
||||
storageKey,
|
||||
options,
|
||||
refresh,
|
||||
refresh
|
||||
}: {
|
||||
storageKey: string;
|
||||
options: Option[];
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@ const Proxy = ({ id, active }) => {
|
|||
{ id: "https://bing.com/search?q=%s", label: "Bing" }
|
||||
];
|
||||
|
||||
const wispUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
const wispUrl =
|
||||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/";
|
||||
//libcurl can be added here when it's stable
|
||||
const transports = [
|
||||
{ id: "epoxy", label: "Epoxy" }
|
||||
];
|
||||
const transports = [{ id: "epoxy", label: "Epoxy" }];
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
|
|
@ -108,7 +109,12 @@ const Proxy = ({ id, active }) => {
|
|||
<div className="text-md p-4 font-bold text-input-text">
|
||||
Select the transport to use
|
||||
</div>
|
||||
<Dropdown storageKey="transport" options={transports} refresh={false} onChange={(value) => changeTransport(value, wispUrl)} />
|
||||
<Dropdown
|
||||
storageKey="transport"
|
||||
options={transports}
|
||||
refresh={false}
|
||||
onChange={(value) => changeTransport(value, wispUrl)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex h-96 w-96 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-2 text-center">
|
||||
<div className="p-2 text-3xl font-bold text-input-text">
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ interface WispInputProps {
|
|||
|
||||
function WispInput(props: WispInputProps) {
|
||||
const { t } = useTranslation();
|
||||
const value = localStorage.getItem("wispUrl") || (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
const value =
|
||||
localStorage.getItem("wispUrl") ||
|
||||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/";
|
||||
const [inputValue, setInputValue] = useState(value);
|
||||
function validateUrl(url: string) {
|
||||
let finalUrl = url;
|
||||
|
|
@ -17,14 +21,18 @@ function WispInput(props: WispInputProps) {
|
|||
finalUrl = finalUrl.replace("http://", "ws://");
|
||||
} else if (finalUrl.startsWith("https://")) {
|
||||
finalUrl = finalUrl.replace("https://", "wss://");
|
||||
}
|
||||
else if (finalUrl === "" || finalUrl === null || finalUrl === undefined) {
|
||||
finalUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
} else if (finalUrl === "" || finalUrl === null || finalUrl === undefined) {
|
||||
finalUrl =
|
||||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/";
|
||||
}
|
||||
return finalUrl;
|
||||
}
|
||||
function handleChange() {
|
||||
const url = validateUrl((document.getElementById("wispinput") as HTMLInputElement).value);
|
||||
const url = validateUrl(
|
||||
(document.getElementById("wispinput") as HTMLInputElement).value
|
||||
);
|
||||
localStorage.setItem("wispUrl", url);
|
||||
changeTransport(localStorage.getItem("transport") || "epoxy", url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { SetTransport, registerRemoteListener } from "@mercuryworkshop/bare-mux";
|
||||
|
||||
import {
|
||||
SetTransport,
|
||||
registerRemoteListener
|
||||
} from "@mercuryworkshop/bare-mux";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
|
@ -27,14 +29,26 @@ function getTransport() {
|
|||
}
|
||||
|
||||
function restartTransport() {
|
||||
changeTransport(getTransport(), localStorage.getItem("wispUrl") || (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/");
|
||||
changeTransport(
|
||||
getTransport(),
|
||||
localStorage.getItem("wispUrl") ||
|
||||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/"
|
||||
);
|
||||
}
|
||||
|
||||
//restart transport every minute
|
||||
setInterval(restartTransport, 60000); //60000ms = 60s = 1m
|
||||
|
||||
const wispUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
const wispUrl =
|
||||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/";
|
||||
registerRemoteListener(navigator.serviceWorker.controller!);
|
||||
changeTransport(localStorage.getItem("transport") || "epoxy", localStorage.getItem("wispUrl") || wispUrl);
|
||||
changeTransport(
|
||||
localStorage.getItem("transport") || "epoxy",
|
||||
localStorage.getItem("wispUrl") || wispUrl
|
||||
);
|
||||
|
||||
export { changeTransport, getTransport };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue