From 7c9605474d787b31bea12e82bdf4f66d26431ef2 Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Wed, 9 Oct 2024 22:18:04 -0700 Subject: [PATCH] bypatrol wisp detector bypass 9000 working 2024 --- client/src/lib.rs | 5 +-- client/src/utils.rs | 92 ++++++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index fbec07c..c77debf 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -78,10 +78,7 @@ pub enum EpoxyError { #[error("Webpki: {0:?} ({0})")] Webpki(#[from] webpki::Error), - #[error("Wisp WebSocket failed to connect")] - WebSocketConnectFailed, - - #[error("Custom wisp transport: {0}")] + #[error("Wisp transport: {0}")] WispTransport(String), #[error("Invalid Wisp transport")] InvalidWispTransport, diff --git a/client/src/utils.rs b/client/src/utils.rs index 5102de3..52bbb16 100644 --- a/client/src/utils.rs +++ b/client/src/utils.rs @@ -373,52 +373,52 @@ pub fn is_null_body(code: u16) -> bool { #[wasm_bindgen(inline_js = r#" class WebSocketStreamPonyfill { - url; - opened; - closed; - close; - constructor(url, options = {}) { - if (options.signal?.aborted) { - throw new DOMException('This operation was aborted', 'AbortError'); - } - this.url = url; - const ws = new WebSocket(url, options.protocols ?? []); + url; + opened; + closed; + close; + constructor(url, options = {}) { + if (options.signal?.aborted) { + throw new DOMException('This operation was aborted', 'AbortError'); + } + this.url = url; + const ws = new WebSocket(url, options.protocols ?? []); ws.binaryType = "arraybuffer"; - const closeWithInfo = ({ closeCode: code, reason } = {}) => ws.close(code, reason); - this.opened = new Promise((resolve, reject) => { - ws.onopen = () => { - resolve({ - readable: new ReadableStream({ - start(controller) { - ws.onmessage = ({ data }) => controller.enqueue(data); - ws.onerror = e => controller.error(e); - }, - cancel: closeWithInfo, - }), - writable: new WritableStream({ - write(chunk) { ws.send(chunk); }, - abort() { ws.close(); }, - close: closeWithInfo, - }), - protocol: ws.protocol, - extensions: ws.extensions, - }); - ws.removeEventListener('error', reject); - }; - ws.addEventListener('error', reject); - }); - this.closed = new Promise((resolve, reject) => { - ws.onclose = ({ code, reason }) => { - resolve({ closeCode: code, reason }); - ws.removeEventListener('error', reject); - }; - ws.addEventListener('error', reject); - }); - if (options.signal) { - options.signal.onabort = () => ws.close(); - } - this.close = closeWithInfo; - } + const closeWithInfo = ({ closeCode: code, reason } = {}) => ws.close(code, reason); + this.opened = new Promise((resolve, reject) => { + ws.onopen = () => { + resolve({ + readable: new ReadableStream({ + start(controller) { + ws.onmessage = ({ data }) => controller.enqueue(data); + ws.onerror = e => controller.error(e); + }, + cancel: closeWithInfo, + }), + writable: new WritableStream({ + write(chunk) { ws.send(chunk); }, + abort() { ws.close(); }, + close: closeWithInfo, + }), + protocol: ws.protocol, + extensions: ws.extensions, + }); + ws.removeEventListener('error', reject); + }; + ws.addEventListener('error', reject); + }); + this.closed = new Promise((resolve, reject) => { + ws.onclose = ({ code, reason }) => { + resolve({ closeCode: code, reason }); + ws.removeEventListener('error', reject); + }; + ws.addEventListener('error', reject); + }); + if (options.signal) { + options.signal.onabort = () => ws.close(); + } + this.close = closeWithInfo; + } } export function object_get(obj, k) { @@ -459,7 +459,7 @@ export function from_entries(entries){ } async function websocket_connect(url, protocols) { - let wss = new WebSocketStreamPonyfill(url, { protocols: protocols }); + let wss = new (WebSocketStream ? WebSocketStream : WebSocketStreamPonyfill)(url, { protocols: protocols }); let {readable, writable} = await wss.opened; return {read: readable, write: writable}; }