cleanup, debugging

This commit is contained in:
dskvr
2022-12-17 23:54:07 +01:00
parent 7444da8764
commit c369b675ea
11 changed files with 11 additions and 320 deletions

View File

@@ -35,7 +35,7 @@ jobs:
with: with:
host: ${{secrets.SSH_DEPLOY_HOST}} host: ${{secrets.SSH_DEPLOY_HOST}}
key: ${{secrets.SSH_DEPLOY_KEY}} key: ${{secrets.SSH_DEPLOY_KEY}}
username: deploy username: ${{secrets.SSH_DEPLOY_USERNAME}}
script: | script: |
docker pull registry.digitalocean.com/sandwich-farm/nostr-relay-status:latest docker pull registry.digitalocean.com/sandwich-farm/nostr-relay-status:latest
docker-compose stop docker-compose stop

View File

@@ -13,7 +13,6 @@ relays:
- 'wss://nostr-pub.semisol.dev' - 'wss://nostr-pub.semisol.dev'
- 'wss://nostr-verified.wellorder.net' - 'wss://nostr-verified.wellorder.net'
- 'wss://nostr.drss.io' - 'wss://nostr.drss.io'
- 'wss://relay.damus.io'
- 'wss://nostr.rocks' - 'wss://nostr.rocks'
- 'wss://nostr.bitcoiner.social' - 'wss://nostr.bitcoiner.social'
- 'wss://nostr.openchain.fr' - 'wss://nostr.openchain.fr'
@@ -21,6 +20,7 @@ relays:
- 'wss://relay.nostr.info' - 'wss://relay.nostr.info'
- 'wss://relay.nostr.pro' - 'wss://relay.nostr.pro'
- 'wss://relay.minds.com/nostr/v1/ws' - 'wss://relay.minds.com/nostr/v1/ws'
- 'wss://relay.damus.io'
- 'wss://nostr.zaprite.io' - 'wss://nostr.zaprite.io'
- 'wss://nostr.oxtr.dev' - 'wss://nostr.oxtr.dev'
- 'wss://nostr.ono.re' - 'wss://nostr.ono.re'

View File

@@ -48,8 +48,6 @@ export default {
}, },
methods: { methods: {
getLatLng(){ getLatLng(){
console.log("geo", this.relay, this.geo[this.relay].lat, this.geo[this.relay].lon)
// if (!geo[this.relay]) console.log("no geo?", geo, this.relay, geo[this.relay])
return [this.geo[this.relay].lat, this.geo[this.relay].lon] return [this.geo[this.relay].lat, this.geo[this.relay].lon]
}, },
getCircleColor(relay){ getCircleColor(relay){
@@ -66,9 +64,7 @@ export default {
return 'black' return 'black'
} }
}, },
async mounted() { async mounted() {},
console.log('GEO', this.geo[this.relay])
},
props: { props: {
geo: { geo: {
type: Object, type: Object,

View File

@@ -59,7 +59,6 @@ export default defineComponent({
if(this.isDone()) { if(this.isDone()) {
this.saveState('lastUpdate') this.saveState('lastUpdate')
console.log('isDone()', this.getState('lastUpdate') )
} }
this.refreshData.untilNext = this.timeUntilRefresh() this.refreshData.untilNext = this.timeUntilRefresh()

View File

@@ -138,9 +138,7 @@ export default defineComponent({
showModal: false showModal: false
} }
}, },
mounted(){ mounted(){},
console.log('')
},
computed: {}, computed: {},
methods: { methods: {
getHeadingClass(){ getHeadingClass(){
@@ -168,10 +166,6 @@ export default defineComponent({
unsorted = this.relays.filter(filterFn); unsorted = this.relays.filter(filterFn);
console.log('unsorted', unsorted)
console.log('isDone', this.isDone())
if(!this.isDone()) { if(!this.isDone()) {
return unsorted return unsorted
} }
@@ -180,7 +174,6 @@ export default defineComponent({
sorted = unsorted.sort((relay1, relay2) => { sorted = unsorted.sort((relay1, relay2) => {
return this.result?.[relay1]?.latency.final - this.result?.[relay2]?.latency.final return this.result?.[relay1]?.latency.final - this.result?.[relay2]?.latency.final
}) })
console.log('sorted', sorted)
return sorted return sorted
} }
@@ -200,11 +193,9 @@ export default defineComponent({
}, },
relaysCompleted () { relaysCompleted () {
let value = Object.entries(this.result).map((value) => { return value.state == 'complete' }).length let value = Object.entries(this.result).map((value) => { return value.state == 'complete' }).length
console.log('relaysCompleted', value)
return value return value
}, },
isDone(){ isDone(){
console.log('isDone()', this.relaysTotal(), '-', this.relaysCompleted(), '=', this.relaysTotal()-this.relaysCompleted() )
return this.relaysTotal()-this.relaysCompleted() == 0 return this.relaysTotal()-this.relaysCompleted() == 0
}, },
} }

View File

@@ -115,9 +115,7 @@ export default defineComponent({
showModal: false showModal: false
} }
}, },
mounted(){ mounted(){},
console.log('')
},
computed: {}, computed: {},
methods: { methods: {
// getHeadingClass(){ // getHeadingClass(){

View File

@@ -172,10 +172,6 @@ export default defineComponent({
users = Object.entries(this.result?.identities), users = Object.entries(this.result?.identities),
count = 0 count = 0
// if(!this.result?.identities) return
console.log(this.result?.uri, 'admin', this.result?.identities.serverAdmin, this.result.info)
if(this.result?.identities) { if(this.result?.identities) {
if(this.result?.identities.serverAdmin) { if(this.result?.identities.serverAdmin) {
string = `Relay has registered an administrator pubkey: ${this.result?.identities.serverAdmin}. ` string = `Relay has registered an administrator pubkey: ${this.result?.identities.serverAdmin}. `
@@ -209,11 +205,10 @@ export default defineComponent({
return `https://github.com/nostr-protocol/nips/blob/master/${this.nipSignature(key)}.md` return `https://github.com/nostr-protocol/nips/blob/master/${this.nipSignature(key)}.md`
}, },
async copy(text) { async copy(text) {
console.log('copy', text)
try { try {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);
} catch($e) { } catch(err) {
//console.log('Cannot copy'); console.error(err)
} }
}, },
} }

View File

@@ -1,237 +0,0 @@
<template>
<!-- <NavComponent /> -->
<div id="wrapper" :class="loadingComplete()">
<row container :gutter="12">
<column :xs="12" :md="12" :lg="12" class="title-card">
<h1>nostr.watch<sup>{{version}}</sup></h1>
</column>
</row>
<row container :gutter="12">
<column :xs="12" :md="12" :lg="12">
<LeafletComponent
:geo="geo"
:result="result"
/>
</column>
</row>
<row container :gutter="12">
<column :xs="12" :md="12" :lg="12">
<div class="block">
<table>
<RelayListComponent
section="public"
:relays="relays"
:result="result"
:geo="geo"
:messages="messages"
:alerts="alerts"
:connections="connections"
/>
<RelayListComponent
section="restricted"
:relays="relays"
:result="result"
:geo="geo"
:messages="messages"
:alerts="alerts"
:connections="connections"
/>
<RelayListComponent
section="offline"
:relays="relays"
:result="result"
:geo="geo"
:messages="messages"
:alerts="alerts"
:connections="connections"
/>
<!-- <RelayListComponent
section="processing"
:relays="relays"
:result="result"
:messages="messages"
:alerts="alerts"
:connections="connections"
:showJson="false"
/> -->
</table>
</div>
</column>
</row>
<row container :gutter="12">
<column :xs="12" :md="12" :lg="12" class="processing-card loading">
<span v-if="(relaysTotal()-relaysConnected()>0)">Processing {{ relaysConnected() }}/{{ relaysTotal() }}</span>
</column>
</row>
<span class="credit"><a href="http://sandwich.farm">Another 🥪 by sandwich.farm</a>, built with <a href="https://github.com/jb55/nostr-js">nostr-js</a> and <a href="https://github.com/dskvr/nostr-relay-inspector">nostr-relay-inspector</a>, inspired by <a href="https://github.com/fiatjaf/nostr-relay-registry">nostr-relay-registry</a></span>
</div>
</template>
<script>
import { defineComponent} from 'vue'
import RelayListComponent from './RelayListComponent.vue'
import LeafletComponent from './LeafletComponent.vue'
// import NavComponent from './NavComponent.vue'
import { Row, Column } from 'vue-grid-responsive';
import { version } from '../../package.json'
import { relays } from '../../relays.yaml'
import { geo } from '../../geo.yaml'
import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.yaml'
import { Inspector, InspectorObservation } from 'nostr-relay-inspector'
// import { Inspector, InspectorObservation } from '../../lib/nostr-relay-inspector'
import crypto from "crypto"
export default defineComponent({
title: "nostr.watch registry & network status",
name: 'RelayTableComponent',
components: {
Row,
Column,
RelayListComponent,
LeafletComponent
// NavComponent
},
data() {
return {
relays,
result: {},
messages: {},
connections: {},
nips: {},
alerts: {},
timeouts: {},
lastPing: Date.now(),
nextPing: Date.now() + (60*1000),
count: 0,
geo,
version: version
}
},
async mounted() {
console.log('mounted')
this.relays.forEach(relay => {
this.check(relay)
})
},
computed: {},
methods: {
check(relay){
const opts = {
checkLatency: true,
setIP: false,
setGeo: false,
}
let inspect = new Inspector(relay, opts)
.on('run', (result) => {
result.aggregate = 'processing'
})
.on('open', (e, result) => {
this.result[relay] = result
})
.on('complete', (instance) => {
console.log('on_complete', instance.result.aggregate)
this.result[relay] = instance.result
this.messages[relay] = instance.inbox
// this.setFlag(relay)
this.setAggregateResult(relay)
this.adjustResult(relay)
})
.on('notice', (notice) => {
const hash = this.sha1(notice)
let message_obj = RELAY_MESSAGES[hash]
let code_obj = RELAY_CODES[message_obj.code]
let response_obj = {...message_obj, ...code_obj}
this.result[relay].observations.push( new InspectorObservation('notice', response_obj.code, response_obj.description, response_obj.relates_to) )
console.log(this.result[relay].observations)
})
.on('close', () => {})
.on('error', () => {
})
.run()
this.connections[relay] = inspect
},
adjustResult (relay) {
this.result[relay].observations.forEach( observation => {
if (observation.code == "BLOCKS_WRITE_STATUS_CHECK") {
this.result[relay].check.write = false
this.result[relay].aggregate = 'public'
}
})
},
setAggregateResult (relay) {
let aggregateTally = 0
aggregateTally += this.result?.[relay]?.check.connect ? 1 : 0
aggregateTally += this.result?.[relay]?.check.read ? 1 : 0
aggregateTally += this.result?.[relay]?.check.write ? 1 : 0
if (aggregateTally == 3) {
this.result[relay].aggregate = 'public'
}
else if (aggregateTally == 0) {
this.result[relay].aggregate = 'offline'
}
else {
this.result[relay].aggregate = 'restricted'
}
},
relaysTotal () {
return this.relays.length-1 //TODO: Figure out WHY?
},
relaysConnected () {
return Object.entries(this.result).length
},
relaysComplete () {
if(!Object.keys(this.results).length) return 0
return this.relays.filter(relay => this.results?.[relay]?.state == 'complete').length
},
sha1 (message) {
const hash = crypto.createHash('sha1').update(JSON.stringify(message)).digest('hex')
// //console.log(message, ':', hash)
return hash
},
isDone(){
return this.relaysTotal()-this.relaysComplete() == 0
},
loadingComplete(){
return this.isDone() ? 'loaded' : ''
},
},
})
</script>

View File

@@ -99,7 +99,7 @@ import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.ya
export default defineComponent({ export default defineComponent({
title: "nostr.watch registry & network status", title: "nostr.watch registry & network status",
name: 'RelayTableComponent', name: 'ByStatus',
components: { components: {
Row, Row,
Column, Column,
@@ -150,36 +150,15 @@ export default defineComponent({
this.result[relay] = this.storage.getStorageSync(relay) this.result[relay] = this.storage.getStorageSync(relay)
}) })
console.log('meow', this.result)
if(Object.keys(this.result).length) if(Object.keys(this.result).length)
this.hasStorage = true this.hasStorage = true
if(this.isExpired()) if(this.isExpired())
this.relays.forEach(async relay => await this.check(relay) ) this.relays.forEach(async relay => await this.check(relay) )
console.log('zzz', this.result)
// this.relays.forEach( relay => {
// // this.result[relay].state = 'complete'
// // this.setAggregateResult(relay)
// // this.adjustResult(relay)
// console.log('boom', relay, this.result[relay])
// })
// }
// console.log(`zing ${Date.now()} - ${this.lastUpdate} = ${Date.now()-this.lastUpdate} > ${60*1000}`)
return true return true
}, },
// head: {
// // creates a title tag in header.
// base () {
// return {
// href: "/"
// }
// }
// },
computed: {}, computed: {},
methods: { methods: {

View File

@@ -76,7 +76,7 @@ import { geo } from '../../geo.yaml'
export default defineComponent({ export default defineComponent({
title: "nostr.watch registry & network status", title: "nostr.watch registry & network status",
name: 'RelayTableComponent', name: 'HomePage',
components: { components: {
Row, Row,
Column, Column,
@@ -118,8 +118,6 @@ export default defineComponent({
}) })
this.invalidate() this.invalidate()
console.log('last update',-1*(Date.now()-(this.lastUpdate+this.preferences.cacheExpiration)))
}, },
computed: { computed: {

View File

@@ -177,8 +177,6 @@ export default defineComponent({
if(this.isExpired()) if(this.isExpired())
this.check(this.relay) this.check(this.relay)
// console.log('zing ', (Date.now() - this.lastUpdate) /1000)
}, },
computed: { computed: {
@@ -247,10 +245,8 @@ export default defineComponent({
this.result = result this.result = result
this.result.checkClass = {read: null, write: null, connect: null} this.result.checkClass = {read: null, write: null, connect: null}
this.setResultClass('connect') this.setResultClass('connect')
/* console.log('result on open', this.result) */
}) })
.on('complete', (instance) => { .on('complete', (instance) => {
/* console.log('on_complete', instance.result.aggregate) */
this.result = instance.result this.result = instance.result
this.messages[this.relay] = instance.inbox this.messages[this.relay] = instance.inbox
@@ -260,9 +256,6 @@ export default defineComponent({
this.setResultClass('read') this.setResultClass('read')
this.setResultClass('write') this.setResultClass('write')
this.saveState(relay) this.saveState(relay)
/* console.log(this.result)
console.log(this.result.info.supported_nips) */
/* resolve(this.result) */
}) })
.on('notice', (notice) => { .on('notice', (notice) => {
const hash = this.sha1(notice) const hash = this.sha1(notice)
@@ -272,16 +265,12 @@ export default defineComponent({
let response_obj = {...message_obj, ...code_obj} let response_obj = {...message_obj, ...code_obj}
this.result.observations.push( new InspectorObservation('notice', response_obj.code, response_obj.description, response_obj.relates_to) ) this.result.observations.push( new InspectorObservation('notice', response_obj.code, response_obj.description, response_obj.relates_to) )
/* console.log(this.result.observations) */
}) })
.on('close', (msg) => { .on('close', (msg) => {
console.warn("CAUTION", msg) console.warn("CAUTION", msg)
/* console.log('supported_nips', inspect.result.info) */
}) })
.on('error', (err) => { .on('error', (err) => {
console.error("ERROR", err) console.error("ERROR", err)
/* reject(err) */
}) })
.run() .run()
@@ -295,8 +284,6 @@ export default defineComponent({
: this.result?.check?.[key] === false : this.result?.check?.[key] === false
? 'failure' ? 'failure'
: 'pending' : 'pending'
/* console.log('result class', result) */
this.result.checkClass[key] = result this.result.checkClass[key] = result
}, },
getLoadingClass () { getLoadingClass () {
@@ -334,8 +321,6 @@ export default defineComponent({
users = Object.entries(this.result.identities), users = Object.entries(this.result.identities),
count = 0 count = 0
// console.log(this.result.uri, 'admin', this.result.identities.serverAdmin)
if(this.result.identities) { if(this.result.identities) {
if(this.result.identities.serverAdmin) { if(this.result.identities.serverAdmin) {
string = `Relay has registered an administrator pubkey: ${this.result.identities.serverAdmin}. ` string = `Relay has registered an administrator pubkey: ${this.result.identities.serverAdmin}. `
@@ -366,23 +351,13 @@ export default defineComponent({
return `https://github.com/nostr-protocol/nips/blob/master/${this.nipSignature(key)}.md` return `https://github.com/nostr-protocol/nips/blob/master/${this.nipSignature(key)}.md`
}, },
async copy(text) { async copy(text) {
// console.log('copy', text)
try { try {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);
} catch($e) { } catch(err) {
//console.log('Cannot copy'); console.error(err)
} }
}, },
// adjustResult (relay) {
// this.result.observations.forEach( observation => {
// if (observation.code == "BLOCKS_WRITE_STATUS_CHECK") {
// this.result.check.write = false
// this.result.aggregate = 'public'
// }
// })
// },
setAggregateResult () { setAggregateResult () {
if(!this.result) return if(!this.result) return
@@ -401,11 +376,8 @@ export default defineComponent({
} }
}, },
sha1 (message) { sha1 (message) {
const hash = crypto.createHash('sha1').update(JSON.stringify(message)).digest('hex') const hash = crypto.createHash('sha1').update(JSON.stringify(message)).digest('hex')
// //console.log(message, ':', hash)
return hash return hash
}, },