mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-18 01:08:51 +00:00
only attempt to monitor the modification time of a plugin if the command does not contain spaces
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# Write policy plugins
|
||||
# Event-sifter plugins
|
||||
|
||||
In order to reduce complexity, strfry's design attempts to keep policy logic out of its core relay functionality. Instead, this logic can be implemented by operators by installing a write policy plugin. Among other things, plugins can be used for the following:
|
||||
In order to reduce complexity, strfry's design attempts to keep policy logic out of its core relay functionality. Instead, this logic can be implemented by operators by installing policy plugins to decide which events to store. Among other things, plugins can be used for the following:
|
||||
|
||||
* White/black-lists (particular pubkeys can/can't post events)
|
||||
* Rate-limits
|
||||
@ -8,7 +8,9 @@ In order to reduce complexity, strfry's design attempts to keep policy logic out
|
||||
|
||||
A plugin can be implemented in any programming language that supports reading lines from stdin, decoding JSON, and printing JSON to stdout. If a plugin is installed, strfry will send the event (along with some other information like IP address) to the plugin over stdin. The plugin should then decide what to do with it and print out a JSON object containing this decision.
|
||||
|
||||
Whenever the script's modification-time changes, or the plugin settings in `strfry.conf` change, the plugin will be reloaded upon the next write attempt.
|
||||
The plugin command can be any shell command, which lets you set environment variables, command-line switches, etc. If the plugin command contains no spaces, it is assumed to be a path to a script. In this case, whenever the script's modification-time changes, the plugin will be reloaded upon the next write attempt.
|
||||
|
||||
If the plugin's command in `strfry.conf` (or a router config file) change, then the plugin will also be reloaded.
|
||||
|
||||
|
||||
## Input messages
|
||||
|
@ -37,7 +37,7 @@ struct PluginEventSifter {
|
||||
r = fdopen(rfd, "r");
|
||||
w = fdopen(wfd, "w");
|
||||
setlinebuf(w);
|
||||
{
|
||||
if (currPluginCmd.find(' ') == std::string::npos) {
|
||||
struct stat statbuf;
|
||||
if (stat(currPluginCmd.c_str(), &statbuf)) throw herr("couldn't stat plugin: ", currPluginCmd);
|
||||
lastModTime = statbuf.st_mtim;
|
||||
@ -64,7 +64,7 @@ struct PluginEventSifter {
|
||||
if (running) {
|
||||
if (pluginCmd != running->currPluginCmd) {
|
||||
running.reset();
|
||||
} else {
|
||||
} else if (pluginCmd.find(' ') == std::string::npos) {
|
||||
struct stat statbuf;
|
||||
if (stat(pluginCmd.c_str(), &statbuf)) throw herr("couldn't stat plugin: ", pluginCmd);
|
||||
if (statbuf.st_mtim.tv_sec != running->lastModTime.tv_sec || statbuf.st_mtim.tv_nsec != running->lastModTime.tv_nsec) {
|
||||
|
Reference in New Issue
Block a user