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

Login performance #1331

Merged
merged 3 commits into from Sep 17, 2017
Merged

Login performance #1331

merged 3 commits into from Sep 17, 2017

Conversation

sgdc3
Copy link
Member

@sgdc3 sgdc3 commented Sep 16, 2017

No description provided.

@sgdc3
Copy link
Member Author

sgdc3 commented Sep 16, 2017

@ljacqu what do you think about this? ;)

@ljacqu
Copy link
Member

ljacqu commented Sep 16, 2017

hi @sgdc3, this looks cool! This will make the verifications happen in async for server implementations where it's possible. Hopefully this is helpful for us. One thing I'm unsure about is if PermissionsManager#hasPermissionOffline will have differences in behavior vs. the currently used PermissionsManager#hasPermission. That might be worth to have a quick look at.

Edit: Actually I think it's quite a difference given that if we don't hook into a specific perms system, the default permission (true / op / false) will be considered. IMHO a breaking change I'm not sure is worth to introduce?

onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
onJoinVerifier.checkAntibot(name, isAuthAvailable);
onJoinVerifier.checkNameCasing(name, auth);
onJoinVerifier.checkPlayerCountry(name, ip, isAuthAvailable);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One iteration beyond this (but only once we resolve this permission behavior change!) is to look at whether we really need the auth object at all? As far as I see here from a quick look, we only want to know whether isAuthAvailable and then I only see it used in checkNameCasing(name, auth).
If instead we can have a dedicated method to return the real name (similar to DataSourceResult<String> getEmail(String)) we avoid constructing PlayerAuth objects, which is more costly.

// Note #831: AsyncPlayerPreLoginEvent is not fired by all servers in offline mode
// e.g. CraftBukkit does not fire it. So we need to run crucial things with PlayerLoginEvent.
// Single session feature can be implemented for Spigot and CraftBukkit by canceling a kick
// event caused by "logged in from another location". The nicer way, but only for Spigot, would be
// to check in the AsyncPlayerPreLoginEvent. To support all servers, we use the less nice way.

private boolean isAsyncPlayerPreLoginEventCalled = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields go to the top of the class :) Thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to move that, sorry xD


if (validationService.isUnrestricted(name)) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, like in the non-async method, would it be worth to check event#result? I don't think it's dramatic as it is right now, but we'd be more consistent with the same check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would break some features like the single session kick message.

teleportationService.teleportOnJoin(player);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a change in behavior I'm not sure is intentional—previously with the red block we did all of the onJoin verifications before and kicked the player. With the green addition the player gets teleported before any checks are made.
This is maybe better because this way a player is teleported as fast as possible (since we don't want to show the original location before login in many cases) ? But at the same time in the case of a bot attack we might be teleporting a lot of players before determining that they have no right being online. Difficult...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Teleporting players to a same spot shouldn't be resource intensive

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed ✔️

@sgdc3
Copy link
Member Author

sgdc3 commented Sep 16, 2017

Edit: Actually I think it's quite a difference given that if we don't hook into a specific perms system, the default permission (true / op / false) will be considered. IMHO a breaking change I'm not sure is worth to introduce?

Could we chat about that on discord? @ljacqu

@sgdc3
Copy link
Member Author

sgdc3 commented Sep 16, 2017

Ready to merge?

@ljacqu
Copy link
Member

ljacqu commented Sep 17, 2017

I'll test this locally and merge afterwards.

@ljacqu
Copy link
Member

ljacqu commented Sep 17, 2017

Single session worked fine for me on Spigot 1.11.2. Didn't test on Bukkit but the mechanism shouldn't change at all, so now I merge.

@ljacqu ljacqu merged commit 6c6fbaf into master Sep 17, 2017
@sgdc3 sgdc3 deleted the login-performance branch September 17, 2017 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants