Feat: wisp server switcher

This commit is contained in:
MotorTruck1221
2025-05-03 18:33:50 -06:00
parent ab6f588fb1
commit a2c497363e
7 changed files with 102 additions and 11 deletions
+8 -3
View File
@@ -60,17 +60,22 @@ class SW {
this.#storageManager.setVal("transport", transport || this.#storageManager.getVal("transport") || 'epoxy');
switch(transport) {
case 'epoxy': {
await this.#baremuxConn!.setTransport("/epoxy/index.mjs", [ { wisp: 'ws://localhost:4321/wisp/' }]);
await this.#baremuxConn!.setTransport("/epoxy/index.mjs", [ { wisp: this.#storageManager.getVal('wispServer') }]);
}
case 'libcurl': {
await this.#baremuxConn!.setTransport("/libcurl/index.mjs", [ { wisp: 'ws://localhost:4321/wisp/' }]);
await this.#baremuxConn!.setTransport("/libcurl/index.mjs", [ { wisp: this.#storageManager.getVal('wispServer') }]);
}
default: {
await this.#baremuxConn!.setTransport("/epoxy/index.mjs", [ { wisp: 'ws://localhost:4321/wisp/' }]);
await this.#baremuxConn!.setTransport("/epoxy/index.mjs", [ { wisp: this.#storageManager.getVal('wispServer') }]);
}
}
}
async wispServer(wispServer?: string, set?: true) {
this.#storageManager.setVal("wispServer", wispServer || this.#storageManager.getVal('wispServer') || (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/");
if (set) await this.setTransport();
}
constructor() {
SW.#instance.add(this);
this.#storageManager = new StoreManager("radius||settings");
+3 -2
View File
@@ -1,6 +1,7 @@
import { StoreManager } from "./storage";
import { BareMuxConnection } from "@mercuryworkshop/bare-mux";
import { SW } from "@utils/proxy.ts";
import { SearchEngines } from "./types";
/**
* The settings class
* Initializes it's own StorageManager, and handles everything within the class itself
@@ -75,8 +76,8 @@ class Settings {
this.#storageManager.setVal('proxy', prox);
}
searchEngine(engine: string) {
this.#storageManager.setVal('searchEngine', engine);
searchEngine(engine?: string) {
this.#storageManager.setVal('searchEngine', engine || SearchEngines.DuckDuckGo);
}
async *#init() {