mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
bypatrol wisp detector bypass 9000 working 2024
This commit is contained in:
parent
7535ef8f48
commit
7c9605474d
2 changed files with 47 additions and 50 deletions
|
@ -78,10 +78,7 @@ pub enum EpoxyError {
|
||||||
#[error("Webpki: {0:?} ({0})")]
|
#[error("Webpki: {0:?} ({0})")]
|
||||||
Webpki(#[from] webpki::Error),
|
Webpki(#[from] webpki::Error),
|
||||||
|
|
||||||
#[error("Wisp WebSocket failed to connect")]
|
#[error("Wisp transport: {0}")]
|
||||||
WebSocketConnectFailed,
|
|
||||||
|
|
||||||
#[error("Custom wisp transport: {0}")]
|
|
||||||
WispTransport(String),
|
WispTransport(String),
|
||||||
#[error("Invalid Wisp transport")]
|
#[error("Invalid Wisp transport")]
|
||||||
InvalidWispTransport,
|
InvalidWispTransport,
|
||||||
|
|
|
@ -373,52 +373,52 @@ pub fn is_null_body(code: u16) -> bool {
|
||||||
|
|
||||||
#[wasm_bindgen(inline_js = r#"
|
#[wasm_bindgen(inline_js = r#"
|
||||||
class WebSocketStreamPonyfill {
|
class WebSocketStreamPonyfill {
|
||||||
url;
|
url;
|
||||||
opened;
|
opened;
|
||||||
closed;
|
closed;
|
||||||
close;
|
close;
|
||||||
constructor(url, options = {}) {
|
constructor(url, options = {}) {
|
||||||
if (options.signal?.aborted) {
|
if (options.signal?.aborted) {
|
||||||
throw new DOMException('This operation was aborted', 'AbortError');
|
throw new DOMException('This operation was aborted', 'AbortError');
|
||||||
}
|
}
|
||||||
this.url = url;
|
this.url = url;
|
||||||
const ws = new WebSocket(url, options.protocols ?? []);
|
const ws = new WebSocket(url, options.protocols ?? []);
|
||||||
ws.binaryType = "arraybuffer";
|
ws.binaryType = "arraybuffer";
|
||||||
const closeWithInfo = ({ closeCode: code, reason } = {}) => ws.close(code, reason);
|
const closeWithInfo = ({ closeCode: code, reason } = {}) => ws.close(code, reason);
|
||||||
this.opened = new Promise((resolve, reject) => {
|
this.opened = new Promise((resolve, reject) => {
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
resolve({
|
resolve({
|
||||||
readable: new ReadableStream({
|
readable: new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
ws.onmessage = ({ data }) => controller.enqueue(data);
|
ws.onmessage = ({ data }) => controller.enqueue(data);
|
||||||
ws.onerror = e => controller.error(e);
|
ws.onerror = e => controller.error(e);
|
||||||
},
|
},
|
||||||
cancel: closeWithInfo,
|
cancel: closeWithInfo,
|
||||||
}),
|
}),
|
||||||
writable: new WritableStream({
|
writable: new WritableStream({
|
||||||
write(chunk) { ws.send(chunk); },
|
write(chunk) { ws.send(chunk); },
|
||||||
abort() { ws.close(); },
|
abort() { ws.close(); },
|
||||||
close: closeWithInfo,
|
close: closeWithInfo,
|
||||||
}),
|
}),
|
||||||
protocol: ws.protocol,
|
protocol: ws.protocol,
|
||||||
extensions: ws.extensions,
|
extensions: ws.extensions,
|
||||||
});
|
});
|
||||||
ws.removeEventListener('error', reject);
|
ws.removeEventListener('error', reject);
|
||||||
};
|
};
|
||||||
ws.addEventListener('error', reject);
|
ws.addEventListener('error', reject);
|
||||||
});
|
});
|
||||||
this.closed = new Promise((resolve, reject) => {
|
this.closed = new Promise((resolve, reject) => {
|
||||||
ws.onclose = ({ code, reason }) => {
|
ws.onclose = ({ code, reason }) => {
|
||||||
resolve({ closeCode: code, reason });
|
resolve({ closeCode: code, reason });
|
||||||
ws.removeEventListener('error', reject);
|
ws.removeEventListener('error', reject);
|
||||||
};
|
};
|
||||||
ws.addEventListener('error', reject);
|
ws.addEventListener('error', reject);
|
||||||
});
|
});
|
||||||
if (options.signal) {
|
if (options.signal) {
|
||||||
options.signal.onabort = () => ws.close();
|
options.signal.onabort = () => ws.close();
|
||||||
}
|
}
|
||||||
this.close = closeWithInfo;
|
this.close = closeWithInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function object_get(obj, k) {
|
export function object_get(obj, k) {
|
||||||
|
@ -459,7 +459,7 @@ export function from_entries(entries){
|
||||||
}
|
}
|
||||||
|
|
||||||
async function websocket_connect(url, protocols) {
|
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;
|
let {readable, writable} = await wss.opened;
|
||||||
return {read: readable, write: writable};
|
return {read: readable, write: writable};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue