|
|
@@ -23,11 +23,9 @@ type RedisOptionsSource = Partial<RedisOptions> & {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* ユーザーが設定する必要のある情報
|
|
|
|
* 設定ファイルの型
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export type Source = {
|
|
|
|
type Source = {
|
|
|
|
repository_url?: string;
|
|
|
|
|
|
|
|
feedback_url?: string;
|
|
|
|
|
|
|
|
url: string;
|
|
|
|
url: string;
|
|
|
|
port?: number;
|
|
|
|
port?: number;
|
|
|
|
socket?: string;
|
|
|
|
socket?: string;
|
|
|
@@ -93,12 +91,63 @@ export type Source = {
|
|
|
|
videoThumbnailGenerator?: string;
|
|
|
|
videoThumbnailGenerator?: string;
|
|
|
|
|
|
|
|
|
|
|
|
signToActivityPubGet?: boolean;
|
|
|
|
signToActivityPubGet?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
perChannelMaxNoteCacheCount?: number;
|
|
|
|
|
|
|
|
perUserNotificationsMaxCount?: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
export type Config = {
|
|
|
|
* Misskeyが自動的に(ユーザーが設定した情報から推論して)設定する情報
|
|
|
|
url: string;
|
|
|
|
*/
|
|
|
|
port: number;
|
|
|
|
export type Mixin = {
|
|
|
|
socket: string | undefined;
|
|
|
|
|
|
|
|
chmodSocket: string | undefined;
|
|
|
|
|
|
|
|
disableHsts: boolean | undefined;
|
|
|
|
|
|
|
|
db: {
|
|
|
|
|
|
|
|
host: string;
|
|
|
|
|
|
|
|
port: number;
|
|
|
|
|
|
|
|
db: string;
|
|
|
|
|
|
|
|
user: string;
|
|
|
|
|
|
|
|
pass: string;
|
|
|
|
|
|
|
|
disableCache?: boolean;
|
|
|
|
|
|
|
|
extra?: { [x: string]: string };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
dbReplications: boolean | undefined;
|
|
|
|
|
|
|
|
dbSlaves: {
|
|
|
|
|
|
|
|
host: string;
|
|
|
|
|
|
|
|
port: number;
|
|
|
|
|
|
|
|
db: string;
|
|
|
|
|
|
|
|
user: string;
|
|
|
|
|
|
|
|
pass: string;
|
|
|
|
|
|
|
|
}[] | undefined;
|
|
|
|
|
|
|
|
meilisearch: {
|
|
|
|
|
|
|
|
host: string;
|
|
|
|
|
|
|
|
port: string;
|
|
|
|
|
|
|
|
apiKey: string;
|
|
|
|
|
|
|
|
ssl?: boolean;
|
|
|
|
|
|
|
|
index: string;
|
|
|
|
|
|
|
|
scope?: 'local' | 'global' | string[];
|
|
|
|
|
|
|
|
} | undefined;
|
|
|
|
|
|
|
|
proxy: string | undefined;
|
|
|
|
|
|
|
|
proxySmtp: string | undefined;
|
|
|
|
|
|
|
|
proxyBypassHosts: string[] | undefined;
|
|
|
|
|
|
|
|
allowedPrivateNetworks: string[] | undefined;
|
|
|
|
|
|
|
|
maxFileSize: number | undefined;
|
|
|
|
|
|
|
|
accesslog: string | undefined;
|
|
|
|
|
|
|
|
clusterLimit: number | undefined;
|
|
|
|
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
outgoingAddress: string | undefined;
|
|
|
|
|
|
|
|
outgoingAddressFamily: 'ipv4' | 'ipv6' | 'dual' | undefined;
|
|
|
|
|
|
|
|
deliverJobConcurrency: number | undefined;
|
|
|
|
|
|
|
|
inboxJobConcurrency: number | undefined;
|
|
|
|
|
|
|
|
relashionshipJobConcurrency: number | undefined;
|
|
|
|
|
|
|
|
deliverJobPerSec: number | undefined;
|
|
|
|
|
|
|
|
inboxJobPerSec: number | undefined;
|
|
|
|
|
|
|
|
relashionshipJobPerSec: number | undefined;
|
|
|
|
|
|
|
|
deliverJobMaxAttempts: number | undefined;
|
|
|
|
|
|
|
|
inboxJobMaxAttempts: number | undefined;
|
|
|
|
|
|
|
|
proxyRemoteFiles: boolean | undefined;
|
|
|
|
|
|
|
|
signToActivityPubGet: boolean | undefined;
|
|
|
|
|
|
|
|
|
|
|
|
version: string;
|
|
|
|
version: string;
|
|
|
|
host: string;
|
|
|
|
host: string;
|
|
|
|
hostname: string;
|
|
|
|
hostname: string;
|
|
|
@@ -117,10 +166,10 @@ export type Mixin = {
|
|
|
|
redis: RedisOptions & RedisOptionsSource;
|
|
|
|
redis: RedisOptions & RedisOptionsSource;
|
|
|
|
redisForPubsub: RedisOptions & RedisOptionsSource;
|
|
|
|
redisForPubsub: RedisOptions & RedisOptionsSource;
|
|
|
|
redisForJobQueue: RedisOptions & RedisOptionsSource;
|
|
|
|
redisForJobQueue: RedisOptions & RedisOptionsSource;
|
|
|
|
|
|
|
|
perChannelMaxNoteCacheCount: number;
|
|
|
|
|
|
|
|
perUserNotificationsMaxCount: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type Config = Source & Mixin;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const _filename = fileURLToPath(import.meta.url);
|
|
|
|
const _filename = fileURLToPath(import.meta.url);
|
|
|
|
const _dirname = dirname(_filename);
|
|
|
|
const _dirname = dirname(_filename);
|
|
|
|
|
|
|
|
|
|
|
@@ -138,7 +187,7 @@ const path = process.env.MISSKEY_CONFIG_YML
|
|
|
|
? resolve(dir, 'test.yml')
|
|
|
|
? resolve(dir, 'test.yml')
|
|
|
|
: resolve(dir, 'default.yml');
|
|
|
|
: resolve(dir, 'default.yml');
|
|
|
|
|
|
|
|
|
|
|
|
export function loadConfig() {
|
|
|
|
export function loadConfig(): Config {
|
|
|
|
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
|
|
|
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
|
|
|
const clientManifestExists = fs.existsSync(_dirname + '/../../../built/_vite_/manifest.json');
|
|
|
|
const clientManifestExists = fs.existsSync(_dirname + '/../../../built/_vite_/manifest.json');
|
|
|
|
const clientManifest = clientManifestExists ?
|
|
|
|
const clientManifest = clientManifestExists ?
|
|
|
@@ -146,43 +195,72 @@ export function loadConfig() {
|
|
|
|
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
|
|
|
|
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
|
|
|
|
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
|
|
|
|
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
|
|
|
|
|
|
|
|
|
|
|
|
const mixin = {} as Mixin;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const url = tryCreateUrl(config.url);
|
|
|
|
const url = tryCreateUrl(config.url);
|
|
|
|
|
|
|
|
const version = meta.version;
|
|
|
|
config.url = url.origin;
|
|
|
|
const host = url.host;
|
|
|
|
|
|
|
|
const hostname = url.hostname;
|
|
|
|
config.port = config.port ?? parseInt(process.env.PORT ?? '', 10);
|
|
|
|
const scheme = url.protocol.replace(/:$/, '');
|
|
|
|
|
|
|
|
const wsScheme = scheme.replace('http', 'ws');
|
|
|
|
mixin.version = meta.version;
|
|
|
|
|
|
|
|
mixin.host = url.host;
|
|
|
|
|
|
|
|
mixin.hostname = url.hostname;
|
|
|
|
|
|
|
|
mixin.scheme = url.protocol.replace(/:$/, '');
|
|
|
|
|
|
|
|
mixin.wsScheme = mixin.scheme.replace('http', 'ws');
|
|
|
|
|
|
|
|
mixin.wsUrl = `${mixin.wsScheme}://${mixin.host}`;
|
|
|
|
|
|
|
|
mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
|
|
|
|
|
|
|
|
mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
|
|
|
|
|
|
|
|
mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`;
|
|
|
|
|
|
|
|
mixin.userAgent = `Misskey/${meta.version} (${config.url})`;
|
|
|
|
|
|
|
|
mixin.clientEntry = clientManifest['src/_boot_.ts'];
|
|
|
|
|
|
|
|
mixin.clientManifestExists = clientManifestExists;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const externalMediaProxy = config.mediaProxy ?
|
|
|
|
const externalMediaProxy = config.mediaProxy ?
|
|
|
|
config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy
|
|
|
|
config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy
|
|
|
|
: null;
|
|
|
|
: null;
|
|
|
|
const internalMediaProxy = `${mixin.scheme}://${mixin.host}/proxy`;
|
|
|
|
const internalMediaProxy = `${scheme}://${host}/proxy`;
|
|
|
|
mixin.mediaProxy = externalMediaProxy ?? internalMediaProxy;
|
|
|
|
const redis = convertRedisOptions(config.redis, host);
|
|
|
|
mixin.externalMediaProxyEnabled = externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mixin.videoThumbnailGenerator = config.videoThumbnailGenerator ?
|
|
|
|
return {
|
|
|
|
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
|
|
|
|
version,
|
|
|
|
: null;
|
|
|
|
url: url.origin,
|
|
|
|
|
|
|
|
port: config.port ?? parseInt(process.env.PORT ?? '', 10),
|
|
|
|
mixin.redis = convertRedisOptions(config.redis, mixin.host);
|
|
|
|
socket: config.socket,
|
|
|
|
mixin.redisForPubsub = config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, mixin.host) : mixin.redis;
|
|
|
|
chmodSocket: config.chmodSocket,
|
|
|
|
mixin.redisForJobQueue = config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, mixin.host) : mixin.redis;
|
|
|
|
disableHsts: config.disableHsts,
|
|
|
|
|
|
|
|
host,
|
|
|
|
return Object.assign(config, mixin);
|
|
|
|
hostname,
|
|
|
|
|
|
|
|
scheme,
|
|
|
|
|
|
|
|
wsScheme,
|
|
|
|
|
|
|
|
wsUrl: `${wsScheme}://${host}`,
|
|
|
|
|
|
|
|
apiUrl: `${scheme}://${host}/api`,
|
|
|
|
|
|
|
|
authUrl: `${scheme}://${host}/auth`,
|
|
|
|
|
|
|
|
driveUrl: `${scheme}://${host}/files`,
|
|
|
|
|
|
|
|
db: config.db,
|
|
|
|
|
|
|
|
dbReplications: config.dbReplications,
|
|
|
|
|
|
|
|
dbSlaves: config.dbSlaves,
|
|
|
|
|
|
|
|
meilisearch: config.meilisearch,
|
|
|
|
|
|
|
|
redis,
|
|
|
|
|
|
|
|
redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, host) : redis,
|
|
|
|
|
|
|
|
redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, host) : redis,
|
|
|
|
|
|
|
|
id: config.id,
|
|
|
|
|
|
|
|
proxy: config.proxy,
|
|
|
|
|
|
|
|
proxySmtp: config.proxySmtp,
|
|
|
|
|
|
|
|
proxyBypassHosts: config.proxyBypassHosts,
|
|
|
|
|
|
|
|
allowedPrivateNetworks: config.allowedPrivateNetworks,
|
|
|
|
|
|
|
|
maxFileSize: config.maxFileSize,
|
|
|
|
|
|
|
|
accesslog: config.accesslog,
|
|
|
|
|
|
|
|
clusterLimit: config.clusterLimit,
|
|
|
|
|
|
|
|
outgoingAddress: config.outgoingAddress,
|
|
|
|
|
|
|
|
outgoingAddressFamily: config.outgoingAddressFamily,
|
|
|
|
|
|
|
|
deliverJobConcurrency: config.deliverJobConcurrency,
|
|
|
|
|
|
|
|
inboxJobConcurrency: config.inboxJobConcurrency,
|
|
|
|
|
|
|
|
relashionshipJobConcurrency: config.relashionshipJobConcurrency,
|
|
|
|
|
|
|
|
deliverJobPerSec: config.deliverJobPerSec,
|
|
|
|
|
|
|
|
inboxJobPerSec: config.inboxJobPerSec,
|
|
|
|
|
|
|
|
relashionshipJobPerSec: config.relashionshipJobPerSec,
|
|
|
|
|
|
|
|
deliverJobMaxAttempts: config.deliverJobMaxAttempts,
|
|
|
|
|
|
|
|
inboxJobMaxAttempts: config.inboxJobMaxAttempts,
|
|
|
|
|
|
|
|
proxyRemoteFiles: config.proxyRemoteFiles,
|
|
|
|
|
|
|
|
signToActivityPubGet: config.signToActivityPubGet,
|
|
|
|
|
|
|
|
mediaProxy: externalMediaProxy ?? internalMediaProxy,
|
|
|
|
|
|
|
|
externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy,
|
|
|
|
|
|
|
|
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
|
|
|
|
|
|
|
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
userAgent: `Misskey/${version} (${config.url})`,
|
|
|
|
|
|
|
|
clientEntry: clientManifest['src/_boot_.ts'],
|
|
|
|
|
|
|
|
clientManifestExists: clientManifestExists,
|
|
|
|
|
|
|
|
perChannelMaxNoteCacheCount: config.perChannelMaxNoteCacheCount ?? 1000,
|
|
|
|
|
|
|
|
perUserNotificationsMaxCount: config.perUserNotificationsMaxCount ?? 300,
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function tryCreateUrl(url: string) {
|
|
|
|
function tryCreateUrl(url: string) {
|
|
|
|