enforce canvas bounds

block users from other servers from the bridge
This commit is contained in:
HF 2023-05-20 18:47:57 +02:00
parent 79cb946ef4
commit b6163fbb10
3 changed files with 15 additions and 2 deletions

View File

@ -2,4 +2,4 @@ export const WIDTH = 800;
export const HEIGHT = 600;
export const MAX_SCALE = 40; // 52 in log2
export const TILE_SIZE = 256;
export const TILE_ZOOM_LEVEL = 4;
export const TILE_ZOOM_LEVEL = 2;

View File

@ -40,7 +40,14 @@ export async function parseCanvasLinks(text) {
const [ canvasIdent, x, y, z ] = coordsParts;
const canvas = canvases.get(canvasIdent);
if (!canvas) {
const upperBound = canvas.size / 2 - 1;
const lowerBound = canvas.size / -2;
if (!canvas
|| x > upperBound
|| y > upperBound
|| x < lowerBound
|| y < lowerBound
) {
return;
}
console.log(`Fetch canvas ${canvas.title} on ${x}/${y} with zoom ${z}`);

View File

@ -176,6 +176,12 @@ class PPfunMatrixBridge {
}
const userId = event.sender;
// block none :pixelplanet.fun users
if (!userId.endsWith(this.domain)) {
return;
}
const uid = (userId.startsWith(`@${this.prefix}_`)
&& userId.endsWith(this.domain))
? userId.slice(2 + this.prefix.length, -this.domain.length - 1)