Page 1 of 1

Extension flood filter

Posted: 24 Jul 2023, 17:51
by moccha
Hello, I am trying to implement the extension flood filter added in 2.19. Here is my code:

Code: Select all

static final String MOVEMENT_HANDLER = "move";
static final String TEST_HANDLER = "test";

public void init()
    {
        // Login and Sign-up process
        initSignUpAssistant();
        initLoginAssistant();
        
        // Assign game handler
        gameAPI = sfs.getAPIManager().getGameApi();
        
        // Extension flood filter
        ExtensionFloodFilterConfig cfg = new ExtensionFloodFilterConfig();
        cfg.banDurationMinutes = 120;
        cfg.maxFloodingAttempts = 3;
        cfg.secondsBeforeBan = 2;
        cfg.banMode = BanMode.BY_NAME;
        cfg.logFloodingAttempts = true;
        cfg.banMessage = "Banned for spam";
        cfg.filterRules = Map.of
                        (
                            MOVEMENT_HANDLER, 1,
                            TEST_HANDLER, 15
                        );
     
        initFloodFilter(cfg);

        //Request handlers
        addRequestHandler(MOVEMENT_HANDLER, MovementHandler.class);
        addRequestHandler(TEST_HANDLER, TestHandler.class);
}
I have made sure that the extension is successfully compiling as well. No matter what I do on the client side, even hundreds of requests / second, the filter is not triggered and nothing is displayed serverside. On server boot I see "Extension AntiFlood Filter initialized" so I know it starts.

Re: Extension flood filter

Posted: 25 Jul 2023, 09:19
by Lapo
Hi,
can you show me an example of the client code that is used to test this?
Also, are you testing locally or remotely?
Thanks

Re: Extension flood filter

Posted: 25 Jul 2023, 13:13
by moccha
I am testing on a local setup. The code looks like this:

Code: Select all

public function sendLoc()
	{
		// Send XY position to server
		var params:ISFSObject = new SFSObject();
		params.putInt("x", x);
		params.putInt("y", y);

		smartfox.send(new ExtensionRequest("move", params));
	}
I know the requests are received rapidly because on my server I put a println("Hello") message anytime a movement is received in MovementHandler. My game runs at about 60fps an I can see it println() roughly 60 requests being received a second.

Are there other settings I need to enable?

I think I may be having the same problem here, but they did not respond back to you. I made sure my functions are properly being called however: https://forums.smartfoxserver.com/v ... od#p104492

Re: Extension flood filter

Posted: 25 Jul 2023, 14:58
by Lapo
Thanks.
I was testing the same scenario and found a bug with one of the configuration parameters. The best way to fix this is via a patch.
We can send you a pre-release test for you to test.

Just send us an email to support@... with a reference to this thread and we'll give you the link.
I think the patch will be released by the end of the week.

Cheers

Re: Extension flood filter

Posted: 27 Jul 2023, 16:43
by moccha
Thanks Lapo. Can you tell what setting causes this bug?

Re: Extension flood filter

Posted: 28 Jul 2023, 06:31
by Lapo
It's not a setting per se, but rather the way in which it is handled internally.
The patch is already online. Release 2.19.3
https://www.smartfoxserver.com/download/sfs2x#p=updates

Cheers