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
|
||||
public/main.js
|
||||
lib/nostr-relay-inspector
|
||||
geo.yaml
|
||||
geo.yml
|
||||
dist
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const fetch = require('cross-fetch'),
|
||||
// relays = require('../relays.yaml'),
|
||||
fs = require('fs'),
|
||||
YAML = require('yaml')
|
||||
|
||||
let object,
|
||||
yaml,
|
||||
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){
|
||||
let dns
|
||||
@@ -36,14 +36,14 @@ const getGeo = async function(ip) {
|
||||
const query = async function(){
|
||||
|
||||
const relays = YAML.parse(file).relays,
|
||||
result = {}
|
||||
result = YAML.parse(geoCache).geo || {}
|
||||
|
||||
for (const relay of relays) {
|
||||
let dns, ip, geo
|
||||
dns = await getDns(relay)
|
||||
ip = await getIp(dns)
|
||||
dns = await getDns(relay).catch()
|
||||
ip = await getIp(dns).catch()
|
||||
// console.log(dns, ip)
|
||||
geo = await getGeo(ip)
|
||||
geo = await getGeo(ip).catch()
|
||||
|
||||
// console.log(geo, ip, dns)
|
||||
|
||||
@@ -52,6 +52,9 @@ const query = async function(){
|
||||
|
||||
if(geo && geo.status == 'success')
|
||||
result[relay] = geo
|
||||
|
||||
if(!geo)
|
||||
console.warn('api was mean, no geo for', relay)
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -63,7 +66,7 @@ const run = async function(){
|
||||
yaml = new YAML.Document()
|
||||
yaml.contents = 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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ import RefreshComponent from '../components/RefreshComponent.vue'
|
||||
|
||||
import { version as nwVersion } from '../../package.json'
|
||||
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'
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -71,7 +71,7 @@ import RefreshComponent from '../components/RefreshComponent.vue'
|
||||
|
||||
import { version } from '../../package.json'
|
||||
import { relays } from '../../relays.yaml'
|
||||
import { geo } from '../../geo.yaml'
|
||||
import { geo } from '../../cache/geo.yaml'
|
||||
|
||||
export default defineComponent({
|
||||
title: "nostr.watch registry & network status",
|
||||
|
||||
@@ -133,7 +133,7 @@ import sharedMethods from '../shared'
|
||||
|
||||
import { version } from '../../package.json'
|
||||
import { relays } from '../../relays.yaml'
|
||||
import { geo } from '../../geo.yaml'
|
||||
import { geo } from '../../cache/geo.yaml'
|
||||
|
||||
const localMethods = {
|
||||
relayUrl() {
|
||||
|
||||
Reference in New Issue
Block a user