enforce canvas bounds
block users from other servers from the bridge
This commit is contained in:
parent
79cb946ef4
commit
b6163fbb10
|
@ -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;
|
||||
|
|
|
@ -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}`);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user