Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastLogin handling cancelled PreLogin events #304

Closed
haeiven opened this issue Mar 8, 2020 · 7 comments
Closed

FastLogin handling cancelled PreLogin events #304

haeiven opened this issue Mar 8, 2020 · 7 comments
Labels
bug Something isn't working BungeeCord/Velocity BungeeCord/Velocity server platform

Comments

@haeiven
Copy link

haeiven commented Mar 8, 2020

What behaviour is observed:

FastLogin is handling cancelled PreLogin events

What behaviour is expected:

Is shouldn't handle them, since my antibot was cancelling them.

Steps/models to reproduce:

Cancel the prelogin event & it will send a request to mojang

Screenshots (if applicable)

/

Plugin list:

AuthmeReloaded, FastLogin, AntibotDeluxe

Environment description

Paper 1.8.8 & Latest build of Waterfall, using MariaDB for the 3 plugins

Plugin version or build number (don't write latest):

1.11-SNAPSHOT-74b1323

Server Log:

Hastebin / Gist link of the error, stacktrace or the complete log (if any)
https://paste.soleria.eu/yarafifuvi.md

Configuration:

Hastebin / Gist link of your config.yml file
https://paste.soleria.eu/feniliyeva.makefile

@haeiven haeiven added the bug Something isn't working label Mar 8, 2020
@games647 games647 added the BungeeCord/Velocity BungeeCord/Velocity server platform label Mar 8, 2020
@games647
Copy link
Owner

games647 commented Mar 8, 2020

Which priority does the plugin use for the PreLoginEvent?

EDIT: Do you use asynchronous calls, so in case of BungeeCord registerIntent()?

@haeiven
Copy link
Author

haeiven commented Mar 8, 2020

Antibotdeluxe seems to be in highest priority, and i'm pretty sure it's async since it need to manage something like 2k connections/s.

Atm, when under attack, antibotdeluxe can handle it easy, but fastlogin is creating a lot of threads for each connections and is crashing the dedicated :/

@games647
Copy link
Owner

games647 commented Mar 8, 2020

and i'm pretty sure it's async since it need to manage something like 2k connections/s.

Background:

So do you use registerIntent() in combination with runAsync? If you do that, then the plugins (FastLogin and AnitBotDeluxe) will run concurrently. BungeeCord has no concept for asynchronous calls in events waiting for listeners on lower priority.

Approaches

Basically FastLogin have to wait until your checks are finished. Do you have maybe some kind of API event, where FastLogin could hook into after you made your checks?

is crashing the dedicated :/

Yes there is concept issue in FastLogin. However an approaches like above FastLogin would still make API request to Mojang although your plugin already identified the connection as malicious.

FastLogin threading - Idea solve too many threads

  • If you are not interest you can skip this. Ended up a little bit too long. Maybe it helps others too.

Yes it's correct, FastLogins creates a new async task (utilizing caching from Bungee's Scheduler) for every blocking actions (HTTP, database) from the BungeeCord handler thread. Back then I didn't know better. I'm planing to change this. Maybe you already implemented a similar approach. It would be great to hear your concept in AnitBotDeluxe (of course only if you want to). My idea is to use task queuing in combination with task pools.

In case of the database with connection pooling (HikariCP), the number of threads that can access the database are limited by the number of connections in the pool. Other requests should be queued up and not hold any threads blocking. This means that we should have a processing thread pool (<= number of cores - like in Java) that doesn't perform any blocking calls and a database thread pool (<= connection size).

  1. Queue database operation
  2. Database thread pool pulls tasks from queue and processes
  3. Queue a task to processing thread pool with the result (similar to callbacks)
    • Database thread pool can pull the next item and block

Therefore the number of threads will be limited, because we limit the number of blocking threads. Meanwhile we have potential full parallelism, because the processing pool doesn't block and only
CPU activity.

The idea is analog for HTTP. There we could use connection pooling using HTTP Keep-Alives and non-blocking I/O (ex: Netty).

@haeiven
Copy link
Author

haeiven commented Mar 8, 2020

After taking a look with FusionCoding, the author of AntibotDeluxe, the plugin is running asynchronously, but using a ThreadPool instead of the inbuilt runAsync with the registerIntent method.

However, he gave me this to get access to the plugin data by accessing it through the proxy, with this sample code: https://hastebin.com/uvohurazit.java

AntiBotDeluxe has no API at this time, which is intended for that use, but this way should work too, he is currently sick so if there are any huge logical stupid things in there, take it easy ^^

The blurred stuff is just unrelated, nothing to hide.
unknown

@games647 games647 changed the title FastLogin handling cancelled PreLogin events (On Bungeecord) FastLogin handling cancelled PreLogin events Mar 9, 2020
@games647
Copy link
Owner

games647 commented Mar 9, 2020

Oh I misinterpreted you as the author, because of the so technical question, sorry.

After taking a look with FusionCoding, the author of AntibotDeluxe, the plugin is running asynchronously, but using a ThreadPool instead of the inbuilt runAsync with the registerIntent method.

So like I assumed. Both tasks run concurrently.

However, he gave me this to get access to the plugin data by accessing it through the proxy, with this sample code: https://hastebin.com/uvohurazit.java

Thank you. Unfortunately this not an optimal solution in this case, because then FastLogin has to constantly pull the cache map if the result is available yet. How frequently should we pull, when do we time out and so on? Using something similar like a event or callbacks, we could get immediately notified. Alternatively we could prevent all Mojang calls meanwhile AntiBotDeluxe thinks the server is under attack. This way already registered players could still join while others will be kicked or assumed cracked at that time.

However regardless of the selected approach above, we still need access to jar to compile FastLogin. Heavy reflections would be unpractical here. Since AntiBotDeluxe is a paid plugin and this is an open source plugin (everyone needs access to the libraries), the optimal solution would be to publish a jar containing only the API specifications available for everyone. This jar could for example contain the specification using an Java interface (without any implementation).

he is currently sick so if there are any huge logical stupid things in there, take it easy ^^

Hope he gets well soon. Is there away we could do without him doing anything as he should focus on recovering than on this? I guess someone of your AntiBotDeluxe team with his approval?

Offtopic:

using a ThreadPool

Would still be interested in how the thread pools are created. Do they have limit and are there more? But as you said, we should maybe discuss that later.

@haeiven
Copy link
Author

haeiven commented Mar 9, 2020

Hello,

Can you add FusionCoding & me on Discord? It would be easier to communicate and solve it asap.
FusionCoding - Tim#5678
Haeiven#9999

Best regards,

games647 added a commit to AuthMe/FastLogin that referenced this issue Mar 14, 2020
@games647
Copy link
Owner

games647 commented May 8, 2020

Small recommendation is to use the ConnectionInitEvent, which is provided by Waterfall. This event fires very early. You could check if the event is present and listen to it if it does.

EDIT: https://github.com/PaperMC/Waterfall/blob/master/BungeeCord-Patches/0054-ConnectionInitEvent.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working BungeeCord/Velocity BungeeCord/Velocity server platform
Projects
None yet
Development

No branches or pull requests

2 participants