Project

General

Profile

How to suppress error stanza from a pre-processor?

Added by Gagan Malik 3 months ago

Hi,

We are trying to develop a spam block functionality. Here's a previous discussion from these forums on the recommended approach - https://projects.tigase.org/boards/4/topics/7122?r=7131#message-7131

I think it would be best to go with totally different approach and create preprocessor which forwards <message/> to different component which would be handling message filtering based on remote calls to HTTP server and then sending packets back to SM.

The recommendation is to develop a pre-processor that forwards message stanzas to a custom component, which checks for spam and sends valid messages back to the session manager.

We are able to forward the packets from a XMPPPreprocessorIfc to the custom spam component, but an error stanza is sent to the client when the preProcess() returns 'true'. We want the spam check component to determine if the current packet can be sent to the client. Until that happens, is there a way to suppress this error stanza from session manager to the client?

Any help is appreciated.

Code:

    public boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo,
            Queue<Packet> results, Map<String, Object> settings) {

        boolean isStanzaTypeChat = (packet.getType() == StanzaType.chat);
        if(!isStanzaTypeChat) {
            return false;
        }

        log.debug("Packet received by pre-processor: {}", packet.toString());

        try {
            JID messageProcessorComponentJid = JID.jidInstance("np-message-processor@gagan.mac");
            Packet packetToForward = packet.swapFromTo();
            packetToForward.setPacketTo(messageProcessorComponentJid);
            log.debug("sending following packet to message-processor:\n{}", packetToForward.toStringFull());

            results.offer(packetToForward);
            return true;
        } catch (TigaseStringprepException e) {
            log.error("error sending packet to message processor", e);
        }

        return false;
    }


Replies (2)

RE: How to suppress error stanza from a pre-processor? - Added by Artur Hefczyc 3 months ago

What exact version/built of the Tigase XMPP Server do you use? This part of the code could have changed over time, so to give you accurate answer I need to know what version of the Tigase you use.

By the way, we have already started working on anti-abuse code for the Tigase XMPP Server. We already have some spam filtering implemented and deployed to our servers: tigase.org and tigase.im. It works pretty well. I used to get about 100 spam messages per day on tigase.im and now I am not getting even 1 spam message.

Would you be interested in trying it on your system? We have version of the code compatible with Tigase server version 7.1.x and 7.2.x

RE: How to suppress error stanza from a pre-processor? - Added by Gagan Malik 3 months ago

What exact version/built of the Tigase XMPP Server do you use? This part of the code could have changed over time, so to give you accurate answer I need to know what version of the Tigase you use.

v7.1.0-b4379 is where we're seeing this behaviour.

Oh we'd love to try it out! We are in a process of upgrading from v5.2.2 to v7.1.0, which is where we plan to implement the spam block component. Our dev/lab environment already runs v7.1.0 and we'd love to try what you have so far.

    (1-2/2)