mirror of
https://github.com/aljazceru/nostr-watch.git
synced 2025-12-18 13:54:23 +01:00
have to commit geo-cache to src :(
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,4 @@ node_modules
|
|||||||
*.wasm
|
*.wasm
|
||||||
public/main.js
|
public/main.js
|
||||||
lib/nostr-relay-inspector
|
lib/nostr-relay-inspector
|
||||||
geo.yaml
|
|
||||||
geo.yml
|
|
||||||
dist
|
dist
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
const fetch = require('cross-fetch'),
|
const fetch = require('cross-fetch'),
|
||||||
// relays = require('../relays.yaml'),
|
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
YAML = require('yaml')
|
YAML = require('yaml')
|
||||||
|
|
||||||
let object,
|
let object,
|
||||||
yaml,
|
yaml,
|
||||||
result,
|
result,
|
||||||
file = fs.readFileSync('./relays.yaml', 'utf8')
|
file = fs.readFileSync('./relays.yaml', 'utf8'),
|
||||||
|
geoCache = fs.readFileSync('./cache/geo.yaml', 'utf8')
|
||||||
|
|
||||||
const getDns = async function(relay){
|
const getDns = async function(relay){
|
||||||
let dns
|
let dns
|
||||||
@@ -36,14 +36,14 @@ const getGeo = async function(ip) {
|
|||||||
const query = async function(){
|
const query = async function(){
|
||||||
|
|
||||||
const relays = YAML.parse(file).relays,
|
const relays = YAML.parse(file).relays,
|
||||||
result = {}
|
result = YAML.parse(geoCache).geo || {}
|
||||||
|
|
||||||
for (const relay of relays) {
|
for (const relay of relays) {
|
||||||
let dns, ip, geo
|
let dns, ip, geo
|
||||||
dns = await getDns(relay)
|
dns = await getDns(relay).catch()
|
||||||
ip = await getIp(dns)
|
ip = await getIp(dns).catch()
|
||||||
// console.log(dns, ip)
|
// console.log(dns, ip)
|
||||||
geo = await getGeo(ip)
|
geo = await getGeo(ip).catch()
|
||||||
|
|
||||||
// console.log(geo, ip, dns)
|
// console.log(geo, ip, dns)
|
||||||
|
|
||||||
@@ -52,6 +52,9 @@ const query = async function(){
|
|||||||
|
|
||||||
if(geo && geo.status == 'success')
|
if(geo && geo.status == 'success')
|
||||||
result[relay] = geo
|
result[relay] = geo
|
||||||
|
|
||||||
|
if(!geo)
|
||||||
|
console.warn('api was mean, no geo for', relay)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -63,7 +66,7 @@ const run = async function(){
|
|||||||
yaml = new YAML.Document()
|
yaml = new YAML.Document()
|
||||||
yaml.contents = object
|
yaml.contents = object
|
||||||
// console.log(object)
|
// console.log(object)
|
||||||
fs.writeFile('./geo.yaml', yaml.toString(), (err) => {
|
fs.writeFile('./cache/geo.yaml', yaml.toString(), (err) => {
|
||||||
if (err) return console.error('./scripts/geo.js', err);
|
if (err) return console.error('./scripts/geo.js', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ import RefreshComponent from '../components/RefreshComponent.vue'
|
|||||||
|
|
||||||
import { version as nwVersion } from '../../package.json'
|
import { version as nwVersion } from '../../package.json'
|
||||||
import { relays } from '../../relays.yaml'
|
import { relays } from '../../relays.yaml'
|
||||||
import { geo } from '../../geo.yaml'
|
import { geo } from '../../cache/geo.yaml'
|
||||||
import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.yaml'
|
import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.yaml'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ import RefreshComponent from '../components/RefreshComponent.vue'
|
|||||||
|
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
import { relays } from '../../relays.yaml'
|
import { relays } from '../../relays.yaml'
|
||||||
import { geo } from '../../geo.yaml'
|
import { geo } from '../../cache/geo.yaml'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
title: "nostr.watch registry & network status",
|
title: "nostr.watch registry & network status",
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ import sharedMethods from '../shared'
|
|||||||
|
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
import { relays } from '../../relays.yaml'
|
import { relays } from '../../relays.yaml'
|
||||||
import { geo } from '../../geo.yaml'
|
import { geo } from '../../cache/geo.yaml'
|
||||||
|
|
||||||
const localMethods = {
|
const localMethods = {
|
||||||
relayUrl() {
|
relayUrl() {
|
||||||
|
|||||||
@@ -31,4 +31,4 @@ module.exports = defineConfig({
|
|||||||
.use('yaml-loader')
|
.use('yaml-loader')
|
||||||
.loader('yaml-loader')
|
.loader('yaml-loader')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user