Skip to content

Commit

Permalink
stricter custom protocol checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ayunami2000 committed Dec 24, 2024
1 parent cc30287 commit a4f8a50
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/connection/fakewebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,12 @@ export function makeFakeWebSocket(): typeof WebSocket {
return new Proxy(WebSocket, {
construct(_target, [uri, protos]) {
let url = new URL(uri);
if (url.host == "java") {
let isCustomProtocol = url.port == "" && url.pathname.startsWith("//");
if (isCustomProtocol && url.hostname == "java") {
const ws = new WispWS(uri);
ws.start();
return ws;
} else if (url.hostname == "settings") {
} else if (isCustomProtocol && url.hostname == "settings") {
return new SettingsWS();
} else {
return new AutoWS(uri, protos);
Expand Down
2 changes: 0 additions & 2 deletions src/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class Connection {
wispurl: string,
private authStore: AuthStore,
) {
console.log(uri, wispurl);
initWisp(wispurl);

const [processIn, eaglerIn] = link<Buffer>();
Expand All @@ -70,7 +69,6 @@ export class Connection {
this.eaglerOut = eaglerOut;
this.processOut = processOut.getWriter();

console.log(uri);
this.url = new URL(uri.slice(uri.toLowerCase().indexOf("://") + 3));
if (!this.url.port) this.url.port = "25565";
if (this.url.protocol != "java:") throw new Error("invalid protocol");
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ window.fetch = async function (url: RequestInfo | URL, init?: RequestInit) {
type EaglerXOptions = any;
let eagoptions: EaglerXOptions;
// append settings to the server list
const settings = { addr: "settings", name: "Wispcraft Settings" };
const settings = { addr: "settings://", name: "Wispcraft Settings" };
Object.defineProperty(window, "eaglercraftXOpts", {
get() {
if (eagoptions) {
Expand Down

0 comments on commit a4f8a50

Please sign in to comment.