mirror of
https://github.com/aljazceru/nostr-watch.git
synced 2025-12-17 05:24:19 +01:00
cleanup, debugging
This commit is contained in:
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
with:
|
||||
host: ${{secrets.SSH_DEPLOY_HOST}}
|
||||
key: ${{secrets.SSH_DEPLOY_KEY}}
|
||||
username: deploy
|
||||
username: ${{secrets.SSH_DEPLOY_USERNAME}}
|
||||
script: |
|
||||
docker pull registry.digitalocean.com/sandwich-farm/nostr-relay-status:latest
|
||||
docker-compose stop
|
||||
|
||||
@@ -13,7 +13,6 @@ relays:
|
||||
- 'wss://nostr-pub.semisol.dev'
|
||||
- 'wss://nostr-verified.wellorder.net'
|
||||
- 'wss://nostr.drss.io'
|
||||
- 'wss://relay.damus.io'
|
||||
- 'wss://nostr.rocks'
|
||||
- 'wss://nostr.bitcoiner.social'
|
||||
- 'wss://nostr.openchain.fr'
|
||||
@@ -21,6 +20,7 @@ relays:
|
||||
- 'wss://relay.nostr.info'
|
||||
- 'wss://relay.nostr.pro'
|
||||
- 'wss://relay.minds.com/nostr/v1/ws'
|
||||
- 'wss://relay.damus.io'
|
||||
- 'wss://nostr.zaprite.io'
|
||||
- 'wss://nostr.oxtr.dev'
|
||||
- 'wss://nostr.ono.re'
|
||||
|
||||
@@ -48,8 +48,6 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
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]
|
||||
},
|
||||
getCircleColor(relay){
|
||||
@@ -66,9 +64,7 @@ export default {
|
||||
return 'black'
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
console.log('GEO', this.geo[this.relay])
|
||||
},
|
||||
async mounted() {},
|
||||
props: {
|
||||
geo: {
|
||||
type: Object,
|
||||
|
||||
@@ -59,7 +59,6 @@ export default defineComponent({
|
||||
|
||||
if(this.isDone()) {
|
||||
this.saveState('lastUpdate')
|
||||
console.log('isDone()', this.getState('lastUpdate') )
|
||||
}
|
||||
|
||||
this.refreshData.untilNext = this.timeUntilRefresh()
|
||||
|
||||
@@ -138,9 +138,7 @@ export default defineComponent({
|
||||
showModal: false
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
console.log('')
|
||||
},
|
||||
mounted(){},
|
||||
computed: {},
|
||||
methods: {
|
||||
getHeadingClass(){
|
||||
@@ -168,10 +166,6 @@ export default defineComponent({
|
||||
|
||||
unsorted = this.relays.filter(filterFn);
|
||||
|
||||
console.log('unsorted', unsorted)
|
||||
|
||||
console.log('isDone', this.isDone())
|
||||
|
||||
if(!this.isDone()) {
|
||||
return unsorted
|
||||
}
|
||||
@@ -180,7 +174,6 @@ export default defineComponent({
|
||||
sorted = unsorted.sort((relay1, relay2) => {
|
||||
return this.result?.[relay1]?.latency.final - this.result?.[relay2]?.latency.final
|
||||
})
|
||||
console.log('sorted', sorted)
|
||||
return sorted
|
||||
}
|
||||
|
||||
@@ -200,11 +193,9 @@ export default defineComponent({
|
||||
},
|
||||
relaysCompleted () {
|
||||
let value = Object.entries(this.result).map((value) => { return value.state == 'complete' }).length
|
||||
console.log('relaysCompleted', value)
|
||||
return value
|
||||
},
|
||||
isDone(){
|
||||
console.log('isDone()', this.relaysTotal(), '-', this.relaysCompleted(), '=', this.relaysTotal()-this.relaysCompleted() )
|
||||
return this.relaysTotal()-this.relaysCompleted() == 0
|
||||
},
|
||||
}
|
||||
|
||||
@@ -115,9 +115,7 @@ export default defineComponent({
|
||||
showModal: false
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
console.log('')
|
||||
},
|
||||
mounted(){},
|
||||
computed: {},
|
||||
methods: {
|
||||
// getHeadingClass(){
|
||||
|
||||
@@ -172,10 +172,6 @@ export default defineComponent({
|
||||
users = Object.entries(this.result?.identities),
|
||||
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.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`
|
||||
},
|
||||
async copy(text) {
|
||||
console.log('copy', text)
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch($e) {
|
||||
//console.log('Cannot copy');
|
||||
} catch(err) {
|
||||
console.error(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -99,7 +99,7 @@ import { messages as RELAY_MESSAGES, codes as RELAY_CODES } from '../../codes.ya
|
||||
|
||||
export default defineComponent({
|
||||
title: "nostr.watch registry & network status",
|
||||
name: 'RelayTableComponent',
|
||||
name: 'ByStatus',
|
||||
components: {
|
||||
Row,
|
||||
Column,
|
||||
@@ -150,36 +150,15 @@ export default defineComponent({
|
||||
this.result[relay] = this.storage.getStorageSync(relay)
|
||||
})
|
||||
|
||||
console.log('meow', this.result)
|
||||
|
||||
if(Object.keys(this.result).length)
|
||||
this.hasStorage = true
|
||||
|
||||
if(this.isExpired())
|
||||
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
|
||||
},
|
||||
|
||||
// head: {
|
||||
// // creates a title tag in header.
|
||||
// base () {
|
||||
// return {
|
||||
// href: "/"
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
computed: {},
|
||||
|
||||
methods: {
|
||||
|
||||
@@ -76,7 +76,7 @@ import { geo } from '../../geo.yaml'
|
||||
|
||||
export default defineComponent({
|
||||
title: "nostr.watch registry & network status",
|
||||
name: 'RelayTableComponent',
|
||||
name: 'HomePage',
|
||||
components: {
|
||||
Row,
|
||||
Column,
|
||||
@@ -118,8 +118,6 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
this.invalidate()
|
||||
|
||||
console.log('last update',-1*(Date.now()-(this.lastUpdate+this.preferences.cacheExpiration)))
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
||||
@@ -177,8 +177,6 @@ export default defineComponent({
|
||||
|
||||
if(this.isExpired())
|
||||
this.check(this.relay)
|
||||
|
||||
// console.log('zing ', (Date.now() - this.lastUpdate) /1000)
|
||||
},
|
||||
|
||||
computed: {
|
||||
@@ -247,10 +245,8 @@ export default defineComponent({
|
||||
this.result = result
|
||||
this.result.checkClass = {read: null, write: null, connect: null}
|
||||
this.setResultClass('connect')
|
||||
/* console.log('result on open', this.result) */
|
||||
})
|
||||
.on('complete', (instance) => {
|
||||
/* console.log('on_complete', instance.result.aggregate) */
|
||||
this.result = instance.result
|
||||
this.messages[this.relay] = instance.inbox
|
||||
|
||||
@@ -260,9 +256,6 @@ export default defineComponent({
|
||||
this.setResultClass('read')
|
||||
this.setResultClass('write')
|
||||
this.saveState(relay)
|
||||
/* console.log(this.result)
|
||||
console.log(this.result.info.supported_nips) */
|
||||
/* resolve(this.result) */
|
||||
})
|
||||
.on('notice', (notice) => {
|
||||
const hash = this.sha1(notice)
|
||||
@@ -272,16 +265,12 @@ export default defineComponent({
|
||||
let response_obj = {...message_obj, ...code_obj}
|
||||
|
||||
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) => {
|
||||
console.warn("CAUTION", msg)
|
||||
/* console.log('supported_nips', inspect.result.info) */
|
||||
})
|
||||
.on('error', (err) => {
|
||||
console.error("ERROR", err)
|
||||
/* reject(err) */
|
||||
})
|
||||
.run()
|
||||
|
||||
@@ -295,8 +284,6 @@ export default defineComponent({
|
||||
: this.result?.check?.[key] === false
|
||||
? 'failure'
|
||||
: 'pending'
|
||||
|
||||
/* console.log('result class', result) */
|
||||
this.result.checkClass[key] = result
|
||||
},
|
||||
getLoadingClass () {
|
||||
@@ -334,8 +321,6 @@ export default defineComponent({
|
||||
users = Object.entries(this.result.identities),
|
||||
count = 0
|
||||
|
||||
// console.log(this.result.uri, 'admin', this.result.identities.serverAdmin)
|
||||
|
||||
if(this.result.identities) {
|
||||
if(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`
|
||||
},
|
||||
async copy(text) {
|
||||
// console.log('copy', text)
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch($e) {
|
||||
//console.log('Cannot copy');
|
||||
} catch(err) {
|
||||
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 () {
|
||||
if(!this.result) return
|
||||
|
||||
@@ -401,11 +376,8 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
sha1 (message) {
|
||||
const hash = crypto.createHash('sha1').update(JSON.stringify(message)).digest('hex')
|
||||
// //console.log(message, ':', hash)
|
||||
return hash
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user