diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-10-09 15:17:22 +0100 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-10-09 15:17:22 +0100 |
| commit | f00576bce6b5f4086112f48046316bfe49559759 (patch) | |
| tree | 9268031a42551f3bfafbb33091f925e0cb5af3aa /packages/backend/src/core/UtilityService.ts | |
| parent | Merge branch 'merge-requests/668' into feature/2024.9.0 (diff) | |
| parent | Merge pull request #14580 from misskey-dev/develop (diff) | |
| download | sharkey-f00576bce6b5f4086112f48046316bfe49559759.tar.gz sharkey-f00576bce6b5f4086112f48046316bfe49559759.tar.bz2 sharkey-f00576bce6b5f4086112f48046316bfe49559759.zip | |
Merge remote-tracking branch 'misskey/master' into feature/2024.9.0
Diffstat (limited to 'packages/backend/src/core/UtilityService.ts')
| -rw-r--r-- | packages/backend/src/core/UtilityService.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts index 22871e44f8..009dd4665f 100644 --- a/packages/backend/src/core/UtilityService.ts +++ b/packages/backend/src/core/UtilityService.ts @@ -10,12 +10,16 @@ import RE2 from 're2'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import { bindThis } from '@/decorators.js'; +import { MiMeta } from '@/models/Meta.js'; @Injectable() export class UtilityService { constructor( @Inject(DI.config) private config: Config, + + @Inject(DI.meta) + private meta: MiMeta, ) { } @@ -112,4 +116,18 @@ export class UtilityService { const host = `${this.toPuny(urlObj.hostname)}${urlObj.port.length > 0 ? ':' + urlObj.port : ''}`; return host; } + + public isFederationAllowedHost(host: string): boolean { + if (this.meta.federation === 'none') return false; + if (this.meta.federation === 'specified' && !this.meta.federationHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`))) return false; + if (this.isBlockedHost(this.meta.blockedHosts, host)) return false; + + return true; + } + + @bindThis + public isFederationAllowedUri(uri: string): boolean { + const host = this.extractDbHost(uri); + return this.isFederationAllowedHost(host); + } } |