From 4609fbe88831f532b9058f1b353c267107a0d176 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 ee61ebe25..2d42c2522 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 c230e09fd..b4a933356 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 e9d1dbb64..93cb760f9 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 0a0802a3a..93de959a8 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 a54bad2e7..e79b97108 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 5d96f7747..9a99d23e2 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 11a80d1b1506b05e1eeac64562cc45a0f16d882c 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 2d42c2522..b96dc643b 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 b4a933356..5f85cead8 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 93cb760f9..028403374 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 93de959a8..2295246eb 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 0f164cea4e77bcba21444e1cfb53b4604b873aa5 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 2295246eb..a3f065e19 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 e79b97108..0d353d3ce 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 9a99d23e2..d5cf2b908 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 6a033513ea9e08a8342731864fccd7efd55d23c2 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 b96dc643b..51d380e7e 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 028403374..cbe27543b 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 a3f065e19..f632a6ec4 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 0d353d3ce..24563661e 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 d5cf2b908..8d728df5b 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 a59017f1d6d18ebdef49062d53846747b7582438 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 62ff2f8ff..81009ed01 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 5fd27545c8b86c1f2bd4e72507fd145f21474329 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 f632a6ec4..1ba226a8e 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 f5a9a6cb2..b60c53df6 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 0add2b9df..3a3bf6bb1 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 }}