Skip to content

"Policy Servers" #2440

Open
Open

Description

@cyrneko

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.

kind of related to #2179

Footnotes

  1. I am still rather new to IRC as a protocol, sorry if I'm missing anything! ↩

Activity

  1. slingamn commented on Aug 7, 2026

    @slingamn
    Member

    Seems reasonable! It would be effectively zero-cost when disabled.

  2. added this to the v2.20 milestone on Aug 7, 2026
  3. cyrneko commented on Aug 7, 2026

    @cyrneko
    Author

    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.

  4. slingamn commented on Sep 7, 2026

    @slingamn
    Member

    Relevant to a problem @KlaasT is having

  5. KlaasT commented on Sep 8, 2026

    @KlaasT
    Contributor

    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).

    Sorry. A lot of text and just my thoughts.

  6. slingamn commented on Sep 8, 2026

    @slingamn
    Member

    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.

  7. TehPeGaSuS commented on Sep 8, 2026

    @TehPeGaSuS
    Contributor

    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.

  8. cyrneko commented on Sep 9, 2026

    @cyrneko
    Author

    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?

  9. KlaasT commented on Sep 9, 2026

    @KlaasT
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions