You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently caught wind of a development that happened over on the matrix side of things; To deal with moderation in a preventative manner, they divised a concept they call "Policy Servers", and the idea is rather simple.
A policy server is a separate program, which checks messages against a (mostly arbitrary) set of rules before being relayed to other participants.
Because it's implemented as a separate program, it's practically infinitely extensible, from simple regex word filters all the way to complex matching and parsing rules.
perhaps we could work on such a thing for ergo? it'd keep most the complexity out of ergo, and unless I'm missing something1, it'd need a relatively small amount of code to allow "screening" messages against a 'policy server' using a small, purpose-made protocol
to be clear, this issue was inspired by seeing the concept of policy servers on matrix, but I'm not trying to suggest we implement matrix to use their existing policy servers.
yea that seems reasonable! I think it's probably in our interest to makee the protocol this uses, whether it be over TCP or something like HTTP, rather simple so that the Policy Server itself can have basically arbitrary policies/rules defined; After all, unlike Matrix, we don't need to worry about S2S, signing and a bunch of other stuff.
I like the idea. I currently have an issue with people sending malicious links to people using private message.
The only problem I see right now it has to be on the other hand non-blocking when it is an external service. We can't wait for an external service to process every single message before it gets handed out. Or can we? Maybe that is a downside we need to take into account when activating the feature.
Because if you want to filter out messages ergo needs to wait for a response from the policy server before doing anything.
I could imagine the following (just simple and random thoughts)
When enabled Ergo sends the message using, for example, a HTTP webhook to the external service.
The external service scans the message and gives back a HTTP 200 ok or HTTP 403 denied together with the message id.
Maybe reserve an extra field in the response message for an action like "block" or even "ban"
How the external service is implemented is up to the service e.g. I would probably build something in laravel and a fancy UI to control everything and offer it as a docker container
Maybe in Ergo there need some configuration point on how long the ircd should wait for a response and what to do if there is no response (pass or blocking).
Because if you want to filter out messages ergo needs to wait for a response from the policy server before doing anything.
That's the proposed design AIUI, Ergo will wait for a response from the policy server before processing each message (up to a short timeout, failing open). This should be quite efficient on the Ergo side (http.Client supports pooled persistent connections) but will definitely add a small amount of latency to message processing.
Why not use something like InspIRCd's filter or UnrealIRCd's spamfilter instead of relying on third party services that only add up complexity and delays, especially if the network has lots of concurrent users.
Primarily because using an external service means entirely arbitrary rules can be implemented. The only limit is what you'd be able to program. I also like the idea that this could he implementation-independent.
In practice, the concerns about delay don't apply. The matrix ecosystem where this scheme is already widely deployed can handle tens of thousands of users at once in a channel with a policy server without noticeable delays caused by it. Especially if the policy server is running on the same host, delay will be unnoticeable.
CC @KlaasT on the Matrix end, if the policy server can't be reached it effectively acts like it isnt there, e.g messages go through normally; This was done to let people still talk should the policy server be down, though I guess here it could perhaps be configured?
CC @KlaasT on the Matrix end, if the policy server can't be reached it effectively acts like it isnt there, e.g messages go through normally; This was done to let people still talk should the policy server be down, though I guess here it could perhaps be configured?
I think a configuration option on how ergo should behave wouldn't do any harm.
So yeah. In the end honestly I'm looking forward to this feature and it seems simple and abstract enough.
Activity
slingamn commentedon Aug 7, 2026
Seems reasonable! It would be effectively zero-cost when disabled.
slingamn commentedon Aug 7, 2026
Matrix spec: https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/4284-policy-servers.md
@progval mentions rspamd as a precedent: https://docs.rspamd.com/developers/protocol/
cyrneko commentedon Aug 7, 2026
yea that seems reasonable! I think it's probably in our interest to makee the protocol this uses, whether it be over TCP or something like HTTP, rather simple so that the Policy Server itself can have basically arbitrary policies/rules defined; After all, unlike Matrix, we don't need to worry about S2S, signing and a bunch of other stuff.
slingamn commentedon Sep 7, 2026
Relevant to a problem @KlaasT is having
KlaasT commentedon Sep 8, 2026
I like the idea. I currently have an issue with people sending malicious links to people using private message.
The only problem I see right now it has to be on the other hand non-blocking when it is an external service. We can't wait for an external service to process every single message before it gets handed out. Or can we? Maybe that is a downside we need to take into account when activating the feature.
Because if you want to filter out messages ergo needs to wait for a response from the policy server before doing anything.
I could imagine the following (just simple and random thoughts)
Sorry. A lot of text and just my thoughts.
slingamn commentedon Sep 8, 2026
That's the proposed design AIUI, Ergo will wait for a response from the policy server before processing each message (up to a short timeout, failing open). This should be quite efficient on the Ergo side (
http.Clientsupports pooled persistent connections) but will definitely add a small amount of latency to message processing.TehPeGaSuS commentedon Sep 8, 2026
Why not use something like InspIRCd's filter or UnrealIRCd's spamfilter instead of relying on third party services that only add up complexity and delays, especially if the network has lots of concurrent users.
cyrneko commentedon Sep 9, 2026
Primarily because using an external service means entirely arbitrary rules can be implemented. The only limit is what you'd be able to program. I also like the idea that this could he implementation-independent.
In practice, the concerns about delay don't apply. The matrix ecosystem where this scheme is already widely deployed can handle tens of thousands of users at once in a channel with a policy server without noticeable delays caused by it. Especially if the policy server is running on the same host, delay will be unnoticeable.
CC @KlaasT on the Matrix end, if the policy server can't be reached it effectively acts like it isnt there, e.g messages go through normally; This was done to let people still talk should the policy server be down, though I guess here it could perhaps be configured?
KlaasT commentedon Sep 9, 2026
I think a configuration option on how ergo should behave wouldn't do any harm.
So yeah. In the end honestly I'm looking forward to this feature and it seems simple and abstract enough.