From 43d914ed3c667746fc70812f1d2a8749cae3f351 Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 27 Apr 2020 04:23:50 +0200 Subject: [PATCH] make canvases.json and proxies.json externals --- README.md | 4 ++-- src/core/Image.js | 2 +- src/core/draw.js | 2 +- src/core/me.js | 2 +- src/core/tileserver.js | 2 +- src/data/models/RedisCanvas.js | 2 +- src/routes/admintools.js | 2 +- src/routes/api/mctp.js | 2 +- src/utils/proxiedFetch.js | 2 +- tools/copy.js | 2 ++ tools/webpack.config.js | 2 ++ 11 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b9d39d35..a0650987 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Configuration takes place in the environment variables that are defined in ecosy Notes: -- to be able to use USE_PROXYCHECK, you have to have an account on proxycheck.io or getipintel or another checker setup and you might set some proxies in `src/proxies.json` (before building) that get used for making proxycheck requests. Look into `src/isProxy.js` to see how things work, but keep in mind that this isn't neccessarily how pixelplanet.fun uses it. +- to be able to use USE_PROXYCHECK, you have to have an account on proxycheck.io or getipintel or another checker setup and you might set some proxies in`proxies.json that get used for making proxycheck requests. Look into `src/isProxy.js` to see how things work, but keep in mind that this isn't neccessarily how pixelplanet.fun uses it. - Admins are users with 0cd and access to `./admintools` for image-upload and whatever - You can find out the id of a user by looking into the logs (i.e. `info: {ip} / {id} wants to place 2 in (1701, -8315)`) when he places a pixel or by checking the MySql Users database - If you use gmail as mail transport, make sure that less-secure apps are allowed to access it in your settings [here](https://myaccount.google.com/lesssecureapps) @@ -120,7 +120,7 @@ Notes: - The HTML for SocialMedia logins is in src/componets/UserAreaModal.js , delete stuff from there if you don't need it - The HTML for the Help Screen is in src/components/HelpModal.js -Canvas specific configuartion like colors and cooldown is in `src/canvases.json` for all canvases. +Canvas specific configuartion like colors and cooldown is in canvases.json` for all canvases. The CanvasSize is expected to be a power of 4 (4096, 16384, 65536) and not smaller than 256 and not larger than 65536 (you can however change the websocket packages in src/socket/packages/ to send chunk coordinates in 16bit and surpas that limit). bcd is base cooldown for unset pixels, pcd is cooldown for placing on top of others, cds is stacktime, ranked if it counts towards the pixelPlaced stats, req is the requirement to be allowed to set on canvas in total pixels placed (or -1 for no requirement or 0 for having to be registered). `sd` is the start-date of the canvas, its used to know the oldest available backup (see Backup & Historical View section). All the cooldown values are in ms. cli is the numbers of colors to ignore for the player palette, i.e. the given world is made out of blue ocean and white continents with those two colors being the first two in the palette and they are used to know if a pixel got set by a player or not, so cli = 2 here. diff --git a/src/core/Image.js b/src/core/Image.js index 91861bcb..e9c72cd3 100644 --- a/src/core/Image.js +++ b/src/core/Image.js @@ -8,7 +8,7 @@ import RedisCanvas from '../data/models/RedisCanvas'; import logger from './logger'; import { getChunkOfPixel } from './utils'; import { TILE_SIZE } from './constants'; -import canvases from '../canvases.json'; +import canvases from './canvases.json'; import Palette from './Palette'; diff --git a/src/core/draw.js b/src/core/draw.js index d0fde05d..f2ea7840 100644 --- a/src/core/draw.js +++ b/src/core/draw.js @@ -8,7 +8,7 @@ import { getChunkOfPixel, getOffsetOfPixel } from './utils'; import webSockets from '../socket/websockets'; import logger from './logger'; import RedisCanvas from '../data/models/RedisCanvas'; -import canvases from '../canvases.json'; +import canvases from './canvases.json'; import { THREE_CANVAS_HEIGHT } from './constants'; diff --git a/src/core/me.js b/src/core/me.js index 048ee065..519c0c1e 100644 --- a/src/core/me.js +++ b/src/core/me.js @@ -5,7 +5,7 @@ * * @flow */ -import canvases from '../canvases.json'; +import canvases from './canvases.json'; export default async function getMe(user) { diff --git a/src/core/tileserver.js b/src/core/tileserver.js index c9742277..3f160ba7 100644 --- a/src/core/tileserver.js +++ b/src/core/tileserver.js @@ -8,7 +8,7 @@ import fs from 'fs'; import type { Cell } from './Cell'; import logger from './logger'; -import canvases from '../canvases.json'; +import canvases from './canvases.json'; import Palette from './Palette'; import RedisCanvas from '../data/models/RedisCanvas'; diff --git a/src/data/models/RedisCanvas.js b/src/data/models/RedisCanvas.js index 6460da1b..ef5fed86 100644 --- a/src/data/models/RedisCanvas.js +++ b/src/data/models/RedisCanvas.js @@ -6,7 +6,7 @@ import { THREE_TILE_SIZE, THREE_CANVAS_HEIGHT, } from '../../core/constants'; -import canvases from '../../canvases.json'; +import canvases from './canvases.json'; import logger from '../../core/logger'; import redis from '../redis'; diff --git a/src/routes/admintools.js b/src/routes/admintools.js index e5188fc8..cee40874 100644 --- a/src/routes/admintools.js +++ b/src/routes/admintools.js @@ -20,7 +20,7 @@ import logger from '../core/logger'; import { Blacklist, Whitelist } from '../data/models'; import { MINUTE } from '../core/constants'; -import canvases from '../canvases.json'; +import canvases from './canvases.json'; import { imageABGR2Canvas } from '../core/Image'; import adminHtml from '../components/Admin'; diff --git a/src/routes/api/mctp.js b/src/routes/api/mctp.js index fc85e7aa..c2b07091 100644 --- a/src/routes/api/mctp.js +++ b/src/routes/api/mctp.js @@ -9,7 +9,7 @@ import type { Request, Response } from 'express'; -import canvases from '../../canvases.json'; +import canvases from './canvases.json'; import webSockets from '../../socket/websockets'; const CANVAS_MAX_XY = (canvases[0].size / 2); diff --git a/src/utils/proxiedFetch.js b/src/utils/proxiedFetch.js index ced51930..1110bdb3 100644 --- a/src/utils/proxiedFetch.js +++ b/src/utils/proxiedFetch.js @@ -7,7 +7,7 @@ import isoFetch from 'isomorphic-fetch'; import HttpProxyAgent from 'http-proxy-agent'; -import proxylist from '../proxies.json'; +import proxylist from './proxies.json'; import logger from '../core/logger'; diff --git a/tools/copy.js b/tools/copy.js index 775bbd7c..62a16287 100644 --- a/tools/copy.js +++ b/tools/copy.js @@ -14,6 +14,8 @@ async function copy() { await Promise.all([ copyFile('LICENSE', 'build/LICENSE'), copyDir('public', 'build/public'), + copyFile('src/canvases.json', 'build/canvases.json'), + copyFile('src/proxies.json', 'build/proxies.json'), copyFile('tools/example-ecosystem.yml', 'build/ecosystem.example.yml'), copyFile('tools/example-ecosystem-backup.yml', 'build/ecosystem-backup.example.yml'), ]); diff --git a/tools/webpack.config.js b/tools/webpack.config.js index 86988491..dcf3fb40 100644 --- a/tools/webpack.config.js +++ b/tools/webpack.config.js @@ -333,6 +333,8 @@ const webConfig = { // needed because webpack tries to pack socket.io externals: [ + /\/proxies\.json$/, + /\/canvases\.json$/, /^\.\/assets\.json$/, (context, request, callback) => { const isExternal = request.match(/^[@a-z][a-z/.\-0-9]*$/i)