A set of tools for strfry relays for the Nostr protocol.
Included programs and plugins:
strfry-configThis will auto generate configs for astryfry router,strfry relayandstrfry-syncbased on user pubkeys for streaming and syncing a network of contacts.strfry-syncThis will sync a network of contacts usingnegentropywithstrfry sync.strfry-down-pluginThis is a write policy plugin forstryfry routerandstrfry relayto 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 routerto have user specific relay-to-relay topology. - A config for
strfry-syncthat usesnegentropyto sync notes for complete and bandwidth efficient synchronization. - A plugin config file for
strfry routerandstrfry relayto 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.ymlThen 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.serviceThen 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: downMain options:
log-leveldefines the verbosity of logs. The options include from less verbose to most: "panic", "fatal", "error", "warn", "info", "debug" and "trace".discovery-relaysare used to retrieve thekind 10002(NIP-65) relay list metadata for each pubkey that has been defined inusers.plugin-downdefines the location of thestrfry-down-pluginexecutable for astrfry routerandstrfry relay.plugin-configdefines the configuration base path for thestrfry routerplugin andstrfry relay.router-configis the location of thestrfry routerconfiguration.router-timeoutthe timeout for a stream connection instrfry router.sync-configis the location of thestrfry-syncconfiguration file.sync-strfryis the location of thestrfryexecutable.sync-strfry-logis the location of thestrfry synccommand logs, it is a base filename.sync-status-fileis the location that the sync status for each relay will be written.usersdefines the set of root pubkeys that will have theirkind 3andkind 10002events used to define the router streams.
Other user options:
pubkeyis the hex encoding of a Nostr user's public keydirdefines the direction of the stream. Values can be "down", "both" or "up".depthdefines how deep thekind 3contact/follow list will be navigated (it is usually left as1).relay-depthoption 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-syncYou can also enable a service to keep it running:
cp scripts/strfry-sync.service /etc/systemd/system/strfry-sync.serviceThen 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.
