diff --git a/README.md b/README.md index ab04dcf..bbde8c2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Misskeyの/proxyが単体で動作します(Misskeyのコードがほぼそのまま移植されています)。 +/proxyは画像ではないと403を返しますが、Media Proxyではそのまま内容を送信します。 + **Fastifyプラグインとして動作する気がします。** `pnpm start`は[fastify-cli](https://github.com/fastify/fastify-cli)が動作します。 @@ -52,7 +54,7 @@ export default { // プライベートネットワークでも許可するIP CIDR(default.ymlと同じ) allowedPrivateNetworks: [], - // ダウンロードするファイルの最大サイズ + // ダウンロードするファイルの最大サイズ (bytes) maxSize: 262144000, // フォワードプロキシ diff --git a/built/index.js b/built/index.js index 5b75ad2..2a513ce 100644 --- a/built/index.js +++ b/built/index.js @@ -3,7 +3,6 @@ import { fileURLToPath } from 'node:url'; import { dirname } from 'node:path'; import fastifyStatic from '@fastify/static'; import { createTemp } from './create-temp.js'; -import { FILE_TYPE_BROWSERSAFE } from './const.js'; import { convertToWebpStream, webpDefault } from './image-processor.js'; import { detectType, isMimeImage } from './file-info.js'; import sharp from 'sharp'; @@ -143,9 +142,6 @@ async function proxyHandler(request, reply) { else if (file.mime === 'image/svg+xml') { image = convertToWebpStream(file.path, 2048, 2048); } - else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) { - throw new StatusError('Rejected type', 403, 'Rejected type'); - } if (!image) { image = { data: fs.createReadStream(file.path), diff --git a/package.json b/package.json index 60d5c8a..99f162a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey-media-proxy", - "version": "0.0.3", + "version": "0.0.4", "description": "The Media Proxy for Misskey", "main": "built/index.js", "packageManager": "pnpm@7.26.0", diff --git a/src/download.ts b/src/download.ts index 4401aa6..2920b85 100644 --- a/src/download.ts +++ b/src/download.ts @@ -93,7 +93,6 @@ export async function downloadUrl(url: string, path: string, settings:DownloadCo if (process.env.NODE_ENV !== 'production') console.log(`Download finished: ${url}`); } - function isPrivateIp(ip: string, allowedPrivateNetworks: string[]): boolean { for (const net of allowedPrivateNetworks ?? []) { const cidr = new IPCIDR(net); diff --git a/src/index.ts b/src/index.ts index 218fe7d..95cc408 100644 --- a/src/index.ts +++ b/src/index.ts @@ -182,8 +182,6 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; }; }; } else if (file.mime === 'image/svg+xml') { image = convertToWebpStream(file.path, 2048, 2048); - } else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) { - throw new StatusError('Rejected type', 403, 'Rejected type'); } if (!image) {