parent
							
								
									da20675ada
								
							
						
					
					
						commit
						e21ff916b0
					
				
					 5 changed files with 28 additions and 1 deletions
				
			
		|  | @ -161,3 +161,6 @@ id: 'aid' | |||
| #allowedPrivateNetworks: [ | ||||
| #  '127.0.0.1/32' | ||||
| #] | ||||
| 
 | ||||
| # Upload or download file size limits (bytes) | ||||
| #maxFileSize: 262144000 | ||||
|  |  | |||
|  | @ -17,6 +17,8 @@ | |||
| 	- Proxy使用時には、この制限は適用されません。 | ||||
| 		Proxy使用時に同等の制限を行いたい場合は、Proxy側で設定を行う必要があります。 | ||||
| 	- `default.yml`にて`allowedPrivateNetworks`にCIDRを追加することにより、宛先ネットワークを指定してこの制限から除外することが出来ます。 | ||||
| - アップロード, ダウンロード出来るファイルサイズにハードリミットが適用されるようになりました。(約250MB) | ||||
| 	- `default.yml`にて`maxFileSize`を変更することにより、制限値を変更することが出来ます。 | ||||
| 
 | ||||
| ### Bugfixes | ||||
| - 管理者が最初にサインアップするページでログインされないのを修正 | ||||
|  |  | |||
|  | @ -39,6 +39,8 @@ export type Source = { | |||
| 
 | ||||
| 	allowedPrivateNetworks?: string[]; | ||||
| 
 | ||||
| 	maxFileSize?: number; | ||||
| 
 | ||||
| 	accesslog?: string; | ||||
| 
 | ||||
| 	clusterLimit?: number; | ||||
|  |  | |||
|  | @ -18,6 +18,7 @@ export async function downloadUrl(url: string, path: string) { | |||
| 
 | ||||
| 	const timeout = 30 * 1000; | ||||
| 	const operationTimeout = 60 * 1000; | ||||
| 	const maxSize = config.maxFileSize || 262144000; | ||||
| 
 | ||||
| 	const req = got.stream(url, { | ||||
| 		headers: { | ||||
|  | @ -44,6 +45,20 @@ export async function downloadUrl(url: string, path: string) { | |||
| 				req.destroy(); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		const contentLength = res.headers['content-length']; | ||||
| 		if (contentLength != null) { | ||||
| 			const size = Number(contentLength); | ||||
| 			if (size > maxSize) { | ||||
| 				logger.warn(`maxSize exceeded (${size} > ${maxSize}) on response`); | ||||
| 				req.destroy(); | ||||
| 			} | ||||
| 		} | ||||
| 	}).on('downloadProgress', (progress: Got.Progress) => { | ||||
| 		if (progress.transferred > maxSize) { | ||||
| 			logger.warn(`maxSize exceeded (${progress.transferred} > ${maxSize}) on downloadProgress`); | ||||
| 			req.destroy(); | ||||
| 		} | ||||
| 	}).on('error', (e: any) => { | ||||
| 		if (e.name === 'HTTPError') { | ||||
| 			const statusCode = e.response?.statusCode; | ||||
|  |  | |||
|  | @ -16,6 +16,7 @@ import discord from './service/discord'; | |||
| import github from './service/github'; | ||||
| import twitter from './service/twitter'; | ||||
| import { Instances, AccessTokens, Users } from '@/models/index'; | ||||
| import config from '@/config'; | ||||
| 
 | ||||
| // Init app
 | ||||
| const app = new Koa(); | ||||
|  | @ -37,7 +38,11 @@ app.use(bodyParser({ | |||
| 
 | ||||
| // Init multer instance
 | ||||
| const upload = multer({ | ||||
| 	storage: multer.diskStorage({}) | ||||
| 	storage: multer.diskStorage({}), | ||||
| 	limits: { | ||||
| 		fileSize: config.maxFileSize || 262144000, | ||||
| 		files: 1, | ||||
| 	} | ||||
| }); | ||||
| 
 | ||||
| // Init router
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue