Feat: wisp server switcher
This commit is contained in:
+8
-3
@@ -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");
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user