Repository navigation
feat(nip66): advanced probes, enriched 30166, and mirror targets #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c98a7f5
feat(nip66): advanced probes, enriched 30166, and mirror targets
Ferryx349 a1062a5
fix(nip66): keep ws probe ok when read/write probes are best-effort
Ferryx349 ff065ce
fix(nip66): address Greptile review on probes and discovery publish
Ferryx349 1bb5df0
fix(nip66): keep read/write RTT on ws probe timeout
Ferryx349 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "nostream": minor | ||
| --- | ||
|
|
||
| feat(nip66): add read/write RTT probes, NIP-42 detection, mirror targets, and enriched kind 30166 tags | ||
|
|
||
| Extends the relay monitor with WebSocket read/write probes, optional NIP-42 auth detection, probing of `mirroring.static[]` peers, and richer NIP-66 discovery and monitor announcement events. | ||
|
|
||
| Closes #794 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { Tag } from '../@types/base' | ||
| import { StoredProbeResult } from '../@types/relay-probe-snapshot' | ||
| import { Nip11Limitation } from './relay-probe/types' | ||
|
|
||
| const requirementTag = (name: string, required: boolean | undefined): Tag | undefined => { | ||
| if (required === undefined) { | ||
| return undefined | ||
| } | ||
|
|
||
| return ['R', required ? name : `!${name}`] | ||
| } | ||
|
|
||
| export const appendNip11DiscoveryTags = (tags: Tag[], result: StoredProbeResult): void => { | ||
| const nip11 = result.nip11.status === 'ok' ? result.nip11.data : undefined | ||
|
|
||
| if (!nip11) { | ||
| return | ||
| } | ||
|
|
||
| for (const nip of nip11.supportedNips ?? []) { | ||
| tags.push(['N', String(nip)]) | ||
| } | ||
|
|
||
| const limitation: Nip11Limitation | undefined = nip11.limitation | ||
|
|
||
| const requirementTags = [ | ||
| requirementTag('auth', limitation?.authRequired), | ||
| requirementTag('writes', limitation?.restrictedWrites), | ||
| requirementTag('payment', limitation?.paymentRequired), | ||
| requirementTag( | ||
| 'pow', | ||
| limitation?.minPowDifficulty === undefined ? undefined : limitation.minPowDifficulty > 0, | ||
| ), | ||
| ].filter((tag): tag is Tag => tag !== undefined) | ||
|
|
||
| tags.push(...requirementTags) | ||
|
|
||
| for (const kind of nip11.acceptedKinds ?? []) { | ||
| tags.push(['k', String(kind)]) | ||
| } | ||
| } | ||
|
|
||
| export const appendWsProbeDiscoveryTags = (tags: Tag[], result: StoredProbeResult): void => { | ||
| const ws = result.wsRtt.status === 'ok' ? result.wsRtt.data : undefined | ||
|
|
||
| if (!ws) { | ||
| return | ||
| } | ||
|
|
||
| if (typeof ws.rttOpenMs === 'number') { | ||
| tags.push(['rtt-open', String(ws.rttOpenMs)]) | ||
| } | ||
|
|
||
| if (typeof ws.rttReadMs === 'number') { | ||
| tags.push(['rtt-read', String(ws.rttReadMs)]) | ||
| } | ||
|
|
||
| if (typeof ws.rttWriteMs === 'number') { | ||
| tags.push(['rtt-write', String(ws.rttWriteMs)]) | ||
| } | ||
|
|
||
| if (ws.nip42AuthRequired === true) { | ||
| tags.push(['R', 'auth']) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.