Skip to content

Commit

Permalink
fix wisp spec hell (trailing slash)
Browse files Browse the repository at this point in the history
also remove logging
  • Loading branch information
ayunami2000 committed Dec 27, 2024
1 parent b6dbfd4 commit 171f7d4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 40 deletions.
2 changes: 0 additions & 2 deletions src/1.8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ export class EaglerProxy {
}

let serverid = packet.readString();
console.log("Server ID: " + serverid);
let publicKey = packet.readVariableData();
let verifyToken = packet.readVariableData();

Expand All @@ -372,7 +371,6 @@ export class EaglerProxy {
modulus,
exponent
);
console.log("joining with: ", this.authStore);
await joinServer(
this.authStore.yggToken,
digest,
Expand Down
16 changes: 0 additions & 16 deletions src/connection/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ export class Decryptor {
// this.feedback = new Uint8Array(iv);
const start = performance.now();
this.aesCfb = new CFBDecryptor(iv, iv, 1);
console.log("Took " + (performance.now() - start) + " to seed Decryptor");
}

constructor() {
Expand All @@ -426,13 +425,6 @@ export class Decryptor {
}
const start = performance.now();
controller.enqueue(new Buffer(this.aesCfb.decrypt(chunk.inner)));
console.log(
"Took " +
(performance.now() - start) +
" to transform chunk of size " +
chunk.length +
" (Decryption)"
);
},
});
}
Expand All @@ -449,7 +441,6 @@ export class Encryptor {
// this.feedback = new Uint8Array(iv);
const start = performance.now();
this.aesCfb = new CFBEncryptor(iv, iv, 1);
console.log("Took " + (performance.now() - start) + " to seed Encryptor");
}

transform(chunk: Buffer): Buffer {
Expand All @@ -462,13 +453,6 @@ export class Encryptor {
if (!this.aesCfb) return chunk;
const start = performance.now();
const retobj = new Buffer(this.aesCfb.encrypt(chunk.inner));
console.log(
"Took " +
(performance.now() - start) +
" to transform chunk of size " +
chunk.length +
" (Encryption)"
);
return retobj;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/connection/epoxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import initEpoxy, {
EpoxyClient,
EpoxyClientOptions,
} from "@mercuryworkshop/epoxy-tls/minimal-epoxy-bundled";
import { setWispUrl } from "..";

let connectedwisp = "";

Expand Down Expand Up @@ -48,6 +49,7 @@ export async function connect_tcp(socket: string): Promise<EpoxyIoStream> {

export function set_wisp_server(wisp_url: string) {
initpromise = new Promise((r) => (resolver = r));
setWispUrl(wisp_url);
initWisp(wisp_url);
}

Expand Down
8 changes: 5 additions & 3 deletions src/connection/fakewebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,14 @@ const NativeWebSocket = WebSocket;
export function makeFakeWebSocket(): typeof WebSocket {
return new Proxy(WebSocket, {
construct(_target, [uri, protos]) {
if (uri == wispUrl) {
return new NativeWebSocket(uri, protos);
}

let url = new URL(uri);
let isCustomProtocol = url.port == "" && url.pathname.startsWith("//");

if (url.href == wispUrl) {
return new NativeWebSocket(uri, protos);
} else if (isCustomProtocol && url.hostname == "java") {
if (isCustomProtocol && url.hostname == "java") {
const ws = new WispWS(uri);
ws.start();
return ws;
Expand Down
9 changes: 0 additions & 9 deletions src/connection/framer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ export function bufferTransformer(): TransformStream<Uint8Array, Buffer> {
return new TransformStream({
transform(chunk, controller) {
controller.enqueue(new Buffer(chunk));
console.log(
"Got a packet of size " + chunk.length + " (bufferTransformer)"
);
},
});
}
Expand Down Expand Up @@ -101,9 +98,6 @@ export function lengthTransformer(): TransformStream<Buffer> {
controller.enqueue(pkt);
currentSize = -1;
}
console.log(
"Took " + (performance.now() - start) + " to lengthTransform packet"
);
},
});
}
Expand Down Expand Up @@ -133,9 +127,6 @@ export class Decompressor {
"Decompressor: server sent compressed packet below threshold"
);
}
console.log(
"Took " + (performance.now() - start) + " to decompress packet"
);
},
});
}
Expand Down
6 changes: 0 additions & 6 deletions src/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ export class Connection {
() => backlog++
).getReader();

// setInterval(() => console.log("epoxy backlog ", backlog), 1000);

while (true) {
const { done, value } = await reader.read();
if (done || !value) return;
Expand All @@ -147,15 +145,11 @@ export class Connection {
() => backlog++
).getReader();

// setInterval(() => console.log("eagler backlog ", backlog), 1000);
while (true) {
const start = performance.now();
const { done, value } = await reader.read();
if (done || !value) return;
await impl.eaglerRead(value);
console.log(
"Took " + (performance.now() - start) + " to eaglerRead packet"
);
backlog--;
}

Expand Down
17 changes: 13 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ export let authstore: AuthStore = {

const nativeFetch = fetch;

wispUrl =
new URL(window.location.href).searchParams.get("wisp") ||
localStorage["wispcraft_wispurl"] ||
"wss://wisp.run/";
export function setWispUrl(wisp: string) {
const wispUrlUrl = new URL(wisp);
if (!wispUrlUrl.pathname.endsWith("/")) {
wispUrlUrl.pathname += "/";
}
wispUrl = wispUrlUrl.href;
}

setWispUrl(wispUrl =
new URL(window.location.href).searchParams.get("wisp") ||
localStorage["wispcraft_wispurl"] ||
"wss://wisp.run/"
);

if (localStorage["wispcraft_accounts"]) {
const accounts = JSON.parse(
Expand Down

0 comments on commit 171f7d4

Please sign in to comment.