From 8afe46122d9fd095f61873adc95f71163faba924 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 6 Aug 2024 11:24:43 +0100 Subject: [PATCH 1/3] fix type for env variable --- packages/backend/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index f3957fae76..b32edf6b81 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -227,7 +227,7 @@ export function loadConfig(): Config { if (configFiles.length === 0 && !process.env['MK_WARNED_ABOUT_CONFIG']) { console.log('No config files loaded, check if this is intentional'); - process.env['MK_WARNED_ABOUT_CONFIG'] = true; + process.env['MK_WARNED_ABOUT_CONFIG'] = '1'; } const config = configFiles.map(path => fs.readFileSync(path, 'utf-8')) From 5565985f84d6e1fc1170b5a01f58602e4f48b20a Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 6 Aug 2024 11:35:03 +0100 Subject: [PATCH 2/3] appease the linter --- packages/backend/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index b32edf6b81..0e1306fd3e 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -455,7 +455,7 @@ function applyEnvOverrides(config: Source) { _apply_top([['sentryForFrontend', 'sentryForBackend'], 'options', ['dsn', 'profileSampleRate', 'serverName', 'includeLocalVariables', 'proxy', 'keepAlive', 'caCerts']]); _apply_top(['sentryForBackend', 'enableNodeProfiling']); _apply_top([['clusterLimit', 'deliverJobConcurrency', 'inboxJobConcurrency', 'relashionshipJobConcurrency', 'deliverJobPerSec', 'inboxJobPerSec', 'relashionshipJobPerSec', 'deliverJobMaxAttempts', 'inboxJobMaxAttempts']]); - _apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaProxy', 'proxyRemoteFiles','videoThumbnailGenerator']]); + _apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaProxy', 'proxyRemoteFiles', 'videoThumbnailGenerator']]); _apply_top([['maxFileSize', 'maxNoteLength', 'pidFile']]); _apply_top(['import', ['downloadTimeout', 'maxFileSize']]); _apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature']]); From 8d29df64faf6774cc5062396ad45a02f4b544c32 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 6 Aug 2024 19:07:01 +0100 Subject: [PATCH 3/3] fix webfinger for instances without a `/host-meta` we were inconsistent with the colons, thanks to usedbunny for noticing! --- packages/backend/src/core/WebfingerService.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/WebfingerService.ts b/packages/backend/src/core/WebfingerService.ts index cbbac52cdb..1517dd0074 100644 --- a/packages/backend/src/core/WebfingerService.ts +++ b/packages/backend/src/core/WebfingerService.ts @@ -22,7 +22,9 @@ export type IWebFinger = { const urlRegex = /^https?:\/\//; const mRegex = /^([^@]+)@(.*)/; -const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() === 'true' ? 'http' : 'https'; +// we have the colons here, because URL.protocol does as well, so it's +// more uniform in the places we use both +const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() === 'true' ? 'http:' : 'https:'; @Injectable() export class WebfingerService { @@ -82,7 +84,7 @@ export class WebfingerService { const m = query.match(mRegex); if (m) { const hostname = m[2]; - return `${defaultProtocol}://${hostname}/.well-known/host-meta`; + return `${defaultProtocol}//${hostname}/.well-known/host-meta`; } throw new Error(`Invalid query (${query})`); @@ -101,7 +103,7 @@ export class WebfingerService { const template = (hostMeta['XRD']['Link'] as Array).filter(p => p['@_rel'] === 'lrdd')[0]['@_template']; return template.indexOf('{uri}') < 0 ? null : template; } catch (err) { - console.error(`error while request host-meta for ${url}`); + console.error(`error while request host-meta for ${url}: ${err}`); return null; } }