Compare commits
2 Commits
8655727009
...
83a28e3ad3
Author | SHA1 | Date | |
---|---|---|---|
83a28e3ad3 | |||
f27ab20679 |
@ -68,6 +68,7 @@ module.exports = async (client, apex, app) => {
|
|||||||
requestPart(`https://${instance}/api/v1/instance/peers`)
|
requestPart(`https://${instance}/api/v1/instance/peers`)
|
||||||
])
|
])
|
||||||
if (instancelocated.length === 0) {
|
if (instancelocated.length === 0) {
|
||||||
|
try {
|
||||||
await client.index({
|
await client.index({
|
||||||
index: constant.index,
|
index: constant.index,
|
||||||
body: {
|
body: {
|
||||||
@ -79,6 +80,10 @@ module.exports = async (client, apex, app) => {
|
|||||||
last: new Date()
|
last: new Date()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
return
|
||||||
|
}
|
||||||
app.locals.created++
|
app.locals.created++
|
||||||
return await util.sendFederatedMessage(constant.nick, 'New Fediblock Instance', `Fediblock Instance ${instance} with ${json.length} blocks - https://${constant.apexdomain}#${instance}`, getAccount(api))
|
return await util.sendFederatedMessage(constant.nick, 'New Fediblock Instance', `Fediblock Instance ${instance} with ${json.length} blocks - https://${constant.apexdomain}#${instance}`, getAccount(api))
|
||||||
} else {
|
} else {
|
||||||
@ -89,6 +94,7 @@ module.exports = async (client, apex, app) => {
|
|||||||
|| !instancelocated[0]._source.api
|
|| !instancelocated[0]._source.api
|
||||||
|| !instancelocated[0]._source.nodeinfo
|
|| !instancelocated[0]._source.nodeinfo
|
||||||
|| !instancelocated[0]._source.peers) {
|
|| !instancelocated[0]._source.peers) {
|
||||||
|
try {
|
||||||
await client.update({
|
await client.update({
|
||||||
index: constant.index,
|
index: constant.index,
|
||||||
id: instancelocated[0]._id,
|
id: instancelocated[0]._id,
|
||||||
@ -101,6 +107,10 @@ module.exports = async (client, apex, app) => {
|
|||||||
},
|
},
|
||||||
doc_as_upsert: true
|
doc_as_upsert: true
|
||||||
})
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
return
|
||||||
|
}
|
||||||
app.locals.updated++
|
app.locals.updated++
|
||||||
if (instancelocated[0]._source.api && instancelocated[0]._source.api.uri && instancelocated[0]._source.api.contact_account && instancelocated[0]._source.api.contact_account.acct) {
|
if (instancelocated[0]._source.api && instancelocated[0]._source.api.uri && instancelocated[0]._source.api.contact_account && instancelocated[0]._source.api.contact_account.acct) {
|
||||||
const difference = blocks.filter(block => block.domain && block.domain.trim().length > 0 && !elasticinstance.some(instance => block.domain === instance.domain))
|
const difference = blocks.filter(block => block.domain && block.domain.trim().length > 0 && !elasticinstance.some(instance => block.domain === instance.domain))
|
||||||
@ -134,17 +144,17 @@ module.exports = async (client, apex, app) => {
|
|||||||
app.locals.scan.emit('data', 'data: ' + (app.locals.scannum > 0 ? '(' + app.locals.scannum-- + ':' + (index + 1) + '): ' + instance : ': ' + instance) + '\n\n')
|
app.locals.scan.emit('data', 'data: ' + (app.locals.scannum > 0 ? '(' + app.locals.scannum-- + ':' + (index + 1) + '): ' + instance : ': ' + instance) + '\n\n')
|
||||||
app.locals.peers++
|
app.locals.peers++
|
||||||
await scanInstance(instance)
|
await scanInstance(instance)
|
||||||
global.gc()
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
yield 1
|
|
||||||
}
|
|
||||||
global.gc()
|
global.gc()
|
||||||
yield 0
|
yield 0
|
||||||
|
} catch (e) {
|
||||||
|
global.gc()
|
||||||
|
console.error(e)
|
||||||
|
yield 1
|
||||||
|
}
|
||||||
},
|
},
|
||||||
scanIndex = async (server, instancesall) => {
|
scanIndex = async (server, instancesall) => {
|
||||||
try {
|
try {
|
||||||
@ -249,7 +259,7 @@ module.exports = async (client, apex, app) => {
|
|||||||
}
|
}
|
||||||
await Promise.all(parts.map(async (p, i) => {
|
await Promise.all(parts.map(async (p, i) => {
|
||||||
for await (const exit of scanPart(p, i)) {
|
for await (const exit of scanPart(p, i)) {
|
||||||
console.log(`Scan finished ${server} - index ${i} - exit ${exit}`)
|
console.log('Done: ' + server + ' - ' + i + ' parts with exit ' + exit + '.')
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
return await scanReturn()
|
return await scanReturn()
|
||||||
|
Loading…
Reference in New Issue
Block a user