From 1b77d101eeb7f5b5eaaaf3ad936686a16500051c Mon Sep 17 00:00:00 2001 From: sparrow Date: Wed, 28 Jun 2023 00:41:18 +0100 Subject: [PATCH 1/6] Make redis and postgres tls optional and opt-in --- .config/example.yml | 4 +++- packages/backend/ormconfig.js | 6 +++--- packages/backend/src/config/types.ts | 2 ++ packages/backend/src/db/postgre.ts | 10 +++++----- packages/backend/src/db/redis.ts | 6 +++--- packages/backend/src/queue/initialize.ts | 6 +++--- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index ee61ebe25c..2d42c2522b 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -35,7 +35,7 @@ port: 3000 db: host: localhost port: 5432 - + #ssl: false # Database name db: calckey @@ -48,6 +48,7 @@ db: # Extra Connection options #extra: + # TODO: find another example # ssl: true # ┌─────────────────────┐ @@ -56,6 +57,7 @@ db: redis: host: localhost port: 6379 + #tls: false #family: 0 # 0=Both, 4=IPv4, 6=IPv6 #pass: example-pass #prefix: example-prefix diff --git a/packages/backend/ormconfig.js b/packages/backend/ormconfig.js index c230e09fd5..b4a9333560 100644 --- a/packages/backend/ormconfig.js +++ b/packages/backend/ormconfig.js @@ -12,8 +12,8 @@ export default new DataSource({ extra: config.db.extra, entities: entities, migrations: ["migration/*.js"], - ssl: { - rejectUnauthorized: false, + ssl: config.db.ssl ? { + rejectUnauthorized: false, //TODO make configurable ca: process.env.DB_SSL_CERT, - }, + } : undefined, }); diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index e9d1dbb645..93cb760f9b 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -15,6 +15,7 @@ export type Source = { pass: string; disableCache?: boolean; extra?: { [x: string]: string }; + ssl?: boolean; }; redis: { host: string; @@ -24,6 +25,7 @@ export type Source = { db?: number; prefix?: string; user?: string; + tls?: boolean; }; elasticsearch: { host: string; diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 0a0802a3a8..93de959a81 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -211,10 +211,10 @@ export const db = new DataSource({ password: config.redis.pass, keyPrefix: `${config.redis.prefix}:query:`, db: config.redis.db || 0, - tls: { + tls: config.redis.tls ? { host: config.redis.host, - rejectUnauthorized: false, - }, + rejectUnauthorized: false, // TODO make configurable + } : undefined, }, } : false, @@ -223,10 +223,10 @@ export const db = new DataSource({ maxQueryExecutionTime: 300, entities: entities, migrations: ["../../migration/*.js"], - ssl: { + ssl: config.db.ssl ? { rejectUnauthorized: false, ca: process.env.DB_SSL_CERT, - }, + } : undefined, }); export async function initDb(force = false) { diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index a54bad2e7a..e79b971081 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -10,10 +10,10 @@ export function createConnection() { username: config.redis.user ?? "default", keyPrefix: `${config.redis.prefix}:`, db: config.redis.db || 0, - tls: { - rejectUnauthorized: false, + tls: config.redis.tls ? { + rejectUnauthorized: false, //TODO make configurable host: config.redis.host, - }, + } : undefined, }); } diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index 5d96f7747d..9a99d23e26 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -10,9 +10,9 @@ export function initialize(name: string, limitPerSec = -1) { user: config.redis.user ?? "default", password: config.redis.pass, db: config.redis.db || 0, - tls: { - host: config.redis.host, - }, + tls: config.redis.tls ? { + host: config.redis.host, //TODO add configurable cert validation + } : undefined, }, prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : "queue", limiter: From cc32d09913c52f3ca12acb7c3b537108f3e94cee Mon Sep 17 00:00:00 2001 From: sparrow Date: Wed, 28 Jun 2023 01:48:55 +0100 Subject: [PATCH 2/6] Remove static postgres tls settings They can be configured through `extra` in config. --- .config/example.yml | 5 +++-- packages/backend/ormconfig.js | 4 ---- packages/backend/src/config/types.ts | 1 - packages/backend/src/db/postgre.ts | 4 ---- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index 2d42c2522b..b96dc643ba 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -48,8 +48,9 @@ db: # Extra Connection options #extra: - # TODO: find another example - # ssl: true + # ssl: + # host: localhost + # rejectUnauthorized: false # ┌─────────────────────┐ #───┘ Redis configuration └───────────────────────────────────── diff --git a/packages/backend/ormconfig.js b/packages/backend/ormconfig.js index b4a9333560..5f85cead8a 100644 --- a/packages/backend/ormconfig.js +++ b/packages/backend/ormconfig.js @@ -12,8 +12,4 @@ export default new DataSource({ extra: config.db.extra, entities: entities, migrations: ["migration/*.js"], - ssl: config.db.ssl ? { - rejectUnauthorized: false, //TODO make configurable - ca: process.env.DB_SSL_CERT, - } : undefined, }); diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 93cb760f9b..028403374f 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -15,7 +15,6 @@ export type Source = { pass: string; disableCache?: boolean; extra?: { [x: string]: string }; - ssl?: boolean; }; redis: { host: string; diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 93de959a81..2295246eb1 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -223,10 +223,6 @@ export const db = new DataSource({ maxQueryExecutionTime: 300, entities: entities, migrations: ["../../migration/*.js"], - ssl: config.db.ssl ? { - rejectUnauthorized: false, - ca: process.env.DB_SSL_CERT, - } : undefined, }); export async function initDb(force = false) { From 2f1e9696a8f1e637d9789302bc17aea2aadf8962 Mon Sep 17 00:00:00 2001 From: sparrow Date: Wed, 28 Jun 2023 02:11:02 +0100 Subject: [PATCH 3/6] empty object instead of undefined --- packages/backend/src/db/postgre.ts | 2 +- packages/backend/src/db/redis.ts | 2 +- packages/backend/src/queue/initialize.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 2295246eb1..a3f065e198 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -214,7 +214,7 @@ export const db = new DataSource({ tls: config.redis.tls ? { host: config.redis.host, rejectUnauthorized: false, // TODO make configurable - } : undefined, + } : {}, }, } : false, diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index e79b971081..0d353d3ce1 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -13,7 +13,7 @@ export function createConnection() { tls: config.redis.tls ? { rejectUnauthorized: false, //TODO make configurable host: config.redis.host, - } : undefined, + } : {}, }); } diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index 9a99d23e26..d5cf2b9087 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -12,7 +12,7 @@ export function initialize(name: string, limitPerSec = -1) { db: config.redis.db || 0, tls: config.redis.tls ? { host: config.redis.host, //TODO add configurable cert validation - } : undefined, + } : {}, }, prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : "queue", limiter: From f0256b08ffe566885521d48ba275708a46e2703b Mon Sep 17 00:00:00 2001 From: sparrow Date: Wed, 28 Jun 2023 03:09:22 +0100 Subject: [PATCH 4/6] expose redis tls settings directly to config --- .config/example.yml | 4 +++- packages/backend/src/config/types.ts | 2 +- packages/backend/src/db/postgre.ts | 5 +---- packages/backend/src/db/redis.ts | 5 +---- packages/backend/src/queue/initialize.ts | 4 +--- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index b96dc643ba..51d380e7e7 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -58,7 +58,9 @@ db: redis: host: localhost port: 6379 - #tls: false + #tls: + # host: localhost + # rejectUnauthorized: false #family: 0 # 0=Both, 4=IPv4, 6=IPv6 #pass: example-pass #prefix: example-prefix diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 028403374f..cbe27543b3 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -24,7 +24,7 @@ export type Source = { db?: number; prefix?: string; user?: string; - tls?: boolean; + tls?: { [x: string]: string }; }; elasticsearch: { host: string; diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index a3f065e198..f632a6ec4a 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -211,10 +211,7 @@ export const db = new DataSource({ password: config.redis.pass, keyPrefix: `${config.redis.prefix}:query:`, db: config.redis.db || 0, - tls: config.redis.tls ? { - host: config.redis.host, - rejectUnauthorized: false, // TODO make configurable - } : {}, + tls: config.redis.tls || {} , }, } : false, diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index 0d353d3ce1..24563661e9 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -10,10 +10,7 @@ export function createConnection() { username: config.redis.user ?? "default", keyPrefix: `${config.redis.prefix}:`, db: config.redis.db || 0, - tls: config.redis.tls ? { - rejectUnauthorized: false, //TODO make configurable - host: config.redis.host, - } : {}, + tls: config.redis.tls || {}, }); } diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index d5cf2b9087..8d728df5be 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -10,9 +10,7 @@ export function initialize(name: string, limitPerSec = -1) { user: config.redis.user ?? "default", password: config.redis.pass, db: config.redis.db || 0, - tls: config.redis.tls ? { - host: config.redis.host, //TODO add configurable cert validation - } : {}, + tls: config.redis.tls || {}, }, prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : "queue", limiter: From bb43cc27eee69dd3996c80522552949d7e0e739b Mon Sep 17 00:00:00 2001 From: sparrow Date: Wed, 28 Jun 2023 03:10:54 +0100 Subject: [PATCH 5/6] update helm config template --- chart/templates/_helpers.tpl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 62ff2f8ff0..81009ed017 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -137,7 +137,9 @@ db: # Extra Connection options #extra: - # ssl: true + # ssl: + # host: localhost + # rejectUnauthorized: false # ┌─────────────────────┐ #───┘ Redis configuration └───────────────────────────────────── @@ -154,6 +156,9 @@ redis: #prefix: example-prefix #db: 1 #user: default + #tls: + # host: localhost + # rejectUnauthorized: false # ┌─────────────────────┐ #───┘ Sonic configuration └───────────────────────────────────── From 022d478fa87cdb1e4112a7dff24d997af621e13b Mon Sep 17 00:00:00 2001 From: sparrow Date: Wed, 28 Jun 2023 03:55:29 +0100 Subject: [PATCH 6/6] format --- packages/backend/src/db/postgre.ts | 2 +- .../src/components/MkReactionsViewer.vue | 16 +++++++++++++--- packages/client/src/pages/settings/general.vue | 18 ++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index f632a6ec4a..1ba226a8e1 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -211,7 +211,7 @@ export const db = new DataSource({ password: config.redis.pass, keyPrefix: `${config.redis.prefix}:query:`, db: config.redis.db || 0, - tls: config.redis.tls || {} , + tls: config.redis.tls || {}, }, } : false, diff --git a/packages/client/src/components/MkReactionsViewer.vue b/packages/client/src/components/MkReactionsViewer.vue index f5a9a6cb2e..b60c53df6b 100644 --- a/packages/client/src/components/MkReactionsViewer.vue +++ b/packages/client/src/components/MkReactionsViewer.vue @@ -7,7 +7,7 @@ :count="count" :is-initial="initialReactions.has(reaction)" :note="note" - @reacted="reactionsEl.scrollTo(0,0)" + @reacted="reactionsEl.scrollTo(0, 0)" /> @@ -37,8 +37,18 @@ const isMe = computed(() => $i && $i.id === props.note.userId); overflow-x: auto; margin-inline: -24px; padding-inline: 22px 160px; - mask: linear-gradient(to right, transparent, black 24px calc(100% - 160px), transparent); - -webkit-mask: linear-gradient(to right, transparent, black 24px calc(100% - 160px), transparent); + mask: linear-gradient( + to right, + transparent, + black 24px calc(100% - 160px), + transparent + ); + -webkit-mask: linear-gradient( + to right, + transparent, + black 24px calc(100% - 160px), + transparent + ); scrollbar-width: none; &::-webkit-scrollbar { display: none; diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 0add2b9df9..3a3bf6bb1d 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -45,12 +45,18 @@ class="_formBlock" >{{ i18n.ts.useReactionPickerForContextMenu }} - {{ - i18n.ts.swipeOnMobile - }} - {{ - i18n.ts.swipeOnDesktop - }} + {{ i18n.ts.swipeOnMobile }} + {{ i18n.ts.swipeOnDesktop }} {{ i18n.ts.enterSendsMessage }}