Skip to content

Commit

Permalink
TODO: SOCK5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiteAFancyEmerald committed Jul 18, 2024
1 parent 5a6a857 commit 9d5d904
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions views/assets/js/register-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const swAllowedHostnames = ["localhost", "127.0.0.1"];
const connection = new BareMux.BareMuxConnection("/baremux/worker.js");
const wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/";

// Proxy configuration
const proxyUrl = "socks5://localhost:9050"; // Replace with your proxy URL

async function registerSW() {
if (!navigator.serviceWorker) {
if (
Expand All @@ -14,14 +17,15 @@ async function registerSW() {
throw new Error("Your browser doesn't support service workers.");
}

await connection.setTransport("/libcurl/index.mjs", [{ wisp: wispUrl }]);
// Update the transport setup to include the proxy option
await connection.setTransport("/libcurl/index.mjs", [{ wisp: wispUrl, proxy: proxyUrl }]);
await navigator.serviceWorker.register(stockSW);
}

async function setupTransportOnLoad() {
const conn = new BareMux.BareMuxConnection("/baremux/worker.js");
if (await conn.getTransport() !== "/baremux/module.js") {
await conn.setTransport("/baremux/module.js", [{ wisp: wispUrl }]);
await conn.setTransport("/baremux/module.js", [{ wisp: wispUrl, proxy: proxyUrl }]);
}
}

Expand Down

0 comments on commit 9d5d904

Please sign in to comment.