Move whitelist in config
This commit is contained in:
parent
1e516a8eeb
commit
3c603d2324
|
@ -23,11 +23,17 @@ Then open http://localhost:3234.
|
|||
|
||||
## Production
|
||||
|
||||
Install dependencies:
|
||||
* NodeJS (v12)
|
||||
* Elastic Search
|
||||
|
||||
In the root of the cloned repo:
|
||||
|
||||
```terminal
|
||||
$ git submodule update --init --recursive
|
||||
$ yarn install --pure-lockfile
|
||||
$ npm run build
|
||||
$ cp config/default.yaml config/production.yaml
|
||||
$ vim config/production.yaml
|
||||
$ node dist/server.js
|
||||
```
|
||||
|
|
|
@ -18,4 +18,10 @@ log:
|
|||
level: 'debug' # debug/info/warning/error
|
||||
|
||||
instances-index:
|
||||
url: 'https://instances.joinpeertube.org'
|
||||
# Contains PeerTube instance hosts the indexer will index
|
||||
# Must answer the following format: https://framagit.org/framasoft/peertube/instances-peertube#peertube-auto-follow-global-search
|
||||
url: 'https://instances.joinpeertube.org/api/v1/instances/hosts'
|
||||
|
||||
whitelist:
|
||||
enabled: false
|
||||
hosts: null
|
||||
|
|
|
@ -2,3 +2,14 @@ elastic_search:
|
|||
indexes:
|
||||
videos: 'peertube-index-videos-test1'
|
||||
channels: 'peertube-index-channels-test1'
|
||||
|
||||
whitelist:
|
||||
enabled: true
|
||||
hosts:
|
||||
- 'peertube.cpy.re'
|
||||
- 'peertube2.cpy.re'
|
||||
- 'peertube3.cpy.re'
|
||||
- 'framatube.org'
|
||||
- 'aperi.tube'
|
||||
- 'peertube.datagueule.tv'
|
||||
- 'thinkerview.video'
|
||||
|
|
|
@ -20,6 +20,10 @@ const CONFIG = {
|
|||
},
|
||||
INSTANCES_INDEX: {
|
||||
URL: config.get<string>('instances-index.url')
|
||||
},
|
||||
WHITELIST: {
|
||||
ENABLED: config.get<boolean>('whitelist.enabled'),
|
||||
HOSTS: config.get<string[]>('whitelist.hosts')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,17 +21,13 @@ async function listIndexInstances () {
|
|||
}
|
||||
|
||||
async function buildInstanceHosts () {
|
||||
const whitelist = [
|
||||
'peertube.cpy.re',
|
||||
'peertube2.cpy.re',
|
||||
'peertube3.cpy.re',
|
||||
'framatube.org',
|
||||
'aperi.tube',
|
||||
'peertube.datagueule.tv',
|
||||
'thinkerview.video'
|
||||
]
|
||||
let indexHosts = await listIndexInstancesHost()
|
||||
|
||||
const indexHosts = (await listIndexInstancesHost()).filter(h => whitelist.includes(h))
|
||||
if (CONFIG.WHITELIST.ENABLED) {
|
||||
const whitelistHosts = Array.isArray(CONFIG.WHITELIST.HOSTS) ? CONFIG.WHITELIST.HOSTS : []
|
||||
|
||||
indexHosts = indexHosts.filter(h => whitelistHosts.includes(h))
|
||||
}
|
||||
|
||||
const dbHosts = await listIndexInstances()
|
||||
const removedHosts = getRemovedHosts(dbHosts, indexHosts)
|
||||
|
|
|
@ -2,9 +2,12 @@ import { CONFIG } from '../initializers/constants'
|
|||
import { doRequest } from '../helpers/requests'
|
||||
|
||||
async function listIndexInstancesHost (): Promise<string[]> {
|
||||
const uri = CONFIG.INSTANCES_INDEX.URL + '/api/v1/instances/hosts'
|
||||
const uri = CONFIG.INSTANCES_INDEX.URL
|
||||
|
||||
const qs = { count: 5000 }
|
||||
const qs = {
|
||||
healthy: true,
|
||||
count: 5000
|
||||
}
|
||||
|
||||
const { body } = await doRequest<any>({ uri, qs, json: true })
|
||||
|
||||
|
|
Loading…
Reference in New Issue