Skip to content

Instantly share code, notes, and snippets.

@alanshaw
Created November 30, 2022 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanshaw/f69003c5d7a7d8d3becb49084c561104 to your computer and use it in GitHub Desktop.
Save alanshaw/f69003c5d7a7d8d3becb49084c561104 to your computer and use it in GitHub Desktop.
Extract the gateway peer IDs from the bifrost infra repo
import fs from 'fs'
import path from 'path'
const dir = path.join('ansible', 'inventories', 'bifrost', 'host_vars')
const regex = /ipfs_config_identity_peerid: "(.*)"/ig
async function main () {
const peers = []
for (const f of fs.readdirSync(dir)) {
if (!(f.startsWith('ipfs-bank') && f.endsWith('ipfs.gateway.dwebops.net.yml'))) continue
const data = fs.readFileSync(path.join(dir, f), 'utf8')
const matches = regex.exec(data)
if (!matches) continue
peers.push({ name: f.split('.')[0], peer: matches[1] })
}
peers.sort((a, b) => a.name < b.name ? 1 : 0)
console.log(JSON.stringify(peers, null, 2))
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment