update README.md

This commit is contained in:
mattyatea 2024-02-16 19:07:52 +09:00
parent 3e9b3e5a3a
commit e074d975e1
7 changed files with 130 additions and 50 deletions

View file

@ -150,6 +150,7 @@
"pkce-challenge": "4.1.0",
"probe-image-size": "7.2.3",
"promise-limit": "2.7.0",
"proxycheck-ts": "^0.0.9",
"pug": "3.0.2",
"punycode": "2.3.1",
"pureimage": "0.3.17",

View file

@ -611,4 +611,15 @@ export class MiMeta {
default: false,
})
public enableGDPRMode: boolean;
@Column('boolean', {
default: false,
})
public enableProxyCheckio: boolean;
@Column('varchar', {
length: 32,
nullable: true,
})
public proxyCheckioApiKey: string;
}

View file

@ -6,6 +6,7 @@
import { Inject, Injectable } from '@nestjs/common';
import bcrypt from 'bcryptjs';
import { IsNull } from 'typeorm';
import ProxyCheck from 'proxycheck-ts';
import { DI } from '@/di-symbols.js';
import type { RegistrationTicketsRepository, UsedUsernamesRepository, UserPendingsRepository, UserProfilesRepository, UsersRepository, MiRegistrationTicket } from '@/models/_.js';
import type { Config } from '@/config.js';
@ -74,6 +75,14 @@ export class SignupApiService {
const instance = await this.metaService.fetch(true);
if (instance.enableProxyCheckio) {
if (instance.proxyCheckioApiKey == null) throw new FastifyReplyError(400, 'PROXY_CHECKIO_API_KEY_NOT_SET');
const proxyCheck = new ProxyCheck({ api_key: instance.proxyCheckioApiKey });
const result = await proxyCheck.check(request.headers['x-real-ip'] ?? request.ip, {
vpn: 1,
});
if (result[request.headers['x-real-ip'] ?? request.ip].proxy === 'yes') throw new FastifyReplyError(400, 'PROXY_DETECTED');
}
// Verify *Captcha
// ただしテスト時はこの機構は障害となるため無効にする
if (process.env.NODE_ENV !== 'test') {

View file

@ -459,6 +459,14 @@ export const meta = {
type: 'string',
optional: false, nullable: true,
},
enableProxyCheckio: {
type: 'boolean',
optional: false, nullable: false,
},
proxyCheckioApiKey: {
type: 'string',
optional: false, nullable: true,
},
},
},
} as const;
@ -590,6 +598,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
EmojiBotToken: instance.EmojiBotToken,
ApiBase: instance.ApiBase,
enableGDPRMode: instance.enableGDPRMode,
enableProxyCheckio: instance.enableProxyCheckio,
proxyCheckioApiKey: instance.proxyCheckioApiKey,
};
});
}

View file

@ -91,7 +91,7 @@ export const paramDef = {
},
},
summalyProxy: { type: 'string', nullable: true },
DiscordWebhookUrl:{ type: 'string', nullable: true},
DiscordWebhookUrl: { type: 'string', nullable: true },
deeplAuthKey: { type: 'string', nullable: true },
deeplIsPro: { type: 'boolean' },
enableEmail: { type: 'boolean' },
@ -152,9 +152,15 @@ export const paramDef = {
type: 'string',
},
},
EmojiBotToken:{ type: 'string', nullable: true},
ApiBase:{ type: 'string',nullable:true},
EmojiBotToken: { type: 'string', nullable: true },
ApiBase: { type: 'string', nullable: true },
enableGDPRMode: { type: 'boolean' },
enableProxyCheckio: {
type: 'boolean', nullable: true,
},
proxyCheckioApiKey: {
type: 'string', nullable: true,
},
},
required: [],
} as const;
@ -201,14 +207,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.themeColor !== undefined) {
set.themeColor = ps.themeColor;
}
if (ps.DiscordWebhookUrl !== undefined){
set.DiscordWebhookUrl = ps.DiscordWebhookUrl
if (ps.DiscordWebhookUrl !== undefined) {
set.DiscordWebhookUrl = ps.DiscordWebhookUrl;
}
if (ps.EmojiBotToken !== undefined){
set.EmojiBotToken = ps.EmojiBotToken
if (ps.EmojiBotToken !== undefined) {
set.EmojiBotToken = ps.EmojiBotToken;
}
if (ps.ApiBase !== undefined){
set.ApiBase = ps.ApiBase
if (ps.ApiBase !== undefined) {
set.ApiBase = ps.ApiBase;
}
if (ps.mascotImageUrl !== undefined) {
set.mascotImageUrl = ps.mascotImageUrl;
@ -234,10 +240,18 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.serverErrorImageUrl = ps.serverErrorImageUrl;
}
if (ps.enableProxyCheckio !== undefined) {
set.enableProxyCheckio = ps.enableProxyCheckio;
}
if (ps.proxyCheckioApiKey !== undefined) {
set.proxyCheckioApiKey = ps.proxyCheckioApiKey;
}
if (ps.infoImageUrl !== undefined) {
set.infoImageUrl = ps.infoImageUrl;
}
console.log(ps.enableGDPRMode);
if (ps.enableGDPRMode !== undefined) {
set.enableGDPRMode = ps.enableGDPRMode;
}