A set of tools for strfry relays for the Nostr protocol.
Included programs and plugins:
strfry-config
This will auto generate configs for astryfry router
,strfry relay
andstrfry-sync
based on user pubkeys for streaming and syncing a network of contacts.strfry-sync
This will sync a network of contacts usingnegentropy
withstrfry sync
.strfry-down-plugin
This is a write policy plugin forstryfry router
andstrfry relay
to only allow specific event authors.
This program (strfry-config
) creates configuration files based on a set of configured root pubkeys. Their kind 3
(NIP-02) contact/follow lists and kind 10002
(NIP-65) relay list metadata ("outbox model") are retrieved for syncing and streaming events for them and their contacts through their relays.
There are several output files:
- A config file for a
strfry router
to have user specific relay-to-relay topology. - A config for
strfry-sync
that usesnegentropy
to sync notes for complete and bandwidth efficient synchronization. - A plugin config file for
strfry router
andstrfry relay
to only allow a set of pubkeys to write events.
make
cp strfry-config /usr/local/bin/strfry-config
cp strfry-down-plugin /usr/local/bin/strfry-down-plugin
cp sample-config.yml /etc/strfry-tools/config.yml
Then edit the config.yml
to have your pubkey and other settings. You will likely also need to create directories such as /var/local/strfry-tools
or similar.
You can also enable a service to keep it running, this will also include strfry router
.
cp scripts/strfry-config.service /etc/systemd/system/strfry-config.service
cp scripts/strfry-router.service /etc/systemd/system/strfry-router.service
Then edit those scripts with your customizations and enable them with systemctl enable <name>
.
Example configuration (sample-router.yml
):
log-level: "debug"
discovery-relays:
- "wss://domain1.tld"
- "wss://domian2.tld"
plugin-down: "/usr/bin/local/strfry-router-plugin"
plugin-config: "/var/local/strfry-tools/router-plugin"
router-config: "/var/local/strfry-tools/router.config"
router-timeout: "600"
sync-config: "/var/local/strfry-tools/sync.json"
sync-strfry: "/usr/bin/local/strfry"
sync-strfry-log: "/var/local/strfry-tools/logs/sync"
sync-status-file: "/var/local/strfry-tools/sync-status.json"
users:
- name: "alice"
pubkey: "<32-byte-public-key-hex>"
depth: 1
relay-depth: 1
dir: down
Main options:
log-level
defines the verbosity of logs. The options include from less verbose to most: "panic", "fatal", "error", "warn", "info", "debug" and "trace".discovery-relays
are used to retrieve thekind 10002
(NIP-65) relay list metadata for each pubkey that has been defined inusers
.plugin-down
defines the location of thestrfry-down-plugin
executable for astrfry router
andstrfry relay
.plugin-config
defines the configuration base path for thestrfry router
plugin andstrfry relay
.router-config
is the location of thestrfry router
configuration.router-timeout
the timeout for a stream connection instrfry router
.sync-config
is the location of thestrfry-sync
configuration file.sync-strfry
is the location of thestrfry
executable.sync-strfry-log
is the location of thestrfry sync
command logs, it is a base filename.sync-status-file
is the location that the sync status for each relay will be written.users
defines the set of root pubkeys that will have theirkind 3
andkind 10002
events used to define the router streams.
Other user options:
pubkey
is the hex encoding of a Nostr user's public keydir
defines the direction of the stream. Values can be "down", "both" or "up".depth
defines how deep thekind 3
contact/follow list will be navigated (it is usually left as1
).relay-depth
option is the depth that relay list metadata is added to the config, it must be equal or less than thedepth
.
To run the program:
./strfry-config --conf="</path/to/config.yml>"
This will start a daemon process that will create the configuration files necessary to run a strfry router
. Please see strfry
router documentation for further information about installing and running the router. The strfry router
will reload modifications to the config made from this daemon automatically. Similarly the config for the plugin will also met reloaded, thus changes can be made to the topology without restarting the processes.
make
cp strfry-sync /usr/local/bin/strfry-sync
You can also enable a service to keep it running:
cp scripts/strfry-sync.service /etc/systemd/system/strfry-sync.service
Then edit it with the customizations and enable it with systemctl enable <name>
.
This program uses the strfry sync
command to synchronize a set of users defined in the configuration file. The file is auto generated by the command strfry-config
based on user's pubkeys. As similar to the router, Their kind 3
(NIP-02) contact/follow lists and kind 10002
(NIP-65) relay list metadata ("outbox model") are retrieved for syncing.
To run the program:
./strfry-sync --conf="</path/to/config.json>"
make
cp strfry-down-plugin /usr/local/bin/strfry-down-plugin
This plugin is used for the strfry router
and strfry relay
to allow events from specific authors based on a config file auto generated by strfry-config
.
In your strfry.conf
file, you can add this plugin by including it in the write policy configuration.
writePolicy {
plugin = "/var/local/bin/strfry-down-plugin --conf=/var/local/strfry/down-plugin.json"
}
To configure the plugin use the strfry-config
tool and point the configuration to that output file.