Skip to content

Conversation

Zbizu
Copy link
Contributor

@Zbizu Zbizu commented Sep 19, 2021

Pull Request Prelude

Changes Proposed

  • web login support (standalone login with 10.98 client still possible using account name)
  • search both name and email columns when logging in (login with email is webservice only)
  • changed the way of handling checksums
  • client 12 login still not possible, but now if you set up a webservice, the client won't crash on login attempt (will send only 10.98 error to the client instead)
  • dropping token auth since it wasn't present in version 12 login packet (or no one knows how to set it up yet) Reverted. You can make client 12 compatible using this change: TFS compatibility adjustments to webLogin Znote/ZnoteAAC#491

Issues addressed: one step closer to #3492

Notes

I know these changes are far from perfect, therefore I'm waiting for reviews and opinions
Changes based on opentibiabr/canary code (License GPL-2.0, same as ours)

logging in now possible both ways - legacy and webService\nClient 12 will crash on login because the server still sends 10.98 packets.
@ghost ghost requested a review from DSpeichert September 19, 2021 21:22
@ghost ghost added the feature New feature or functionality label Sep 19, 2021
@Zbizu Zbizu marked this pull request as draft September 19, 2021 22:49
Not necessary unless you run multiworld loginserver. Not present in current tfs either.
@Zbizu Zbizu marked this pull request as ready for review September 21, 2021 15:39
@Zbizu Zbizu marked this pull request as draft September 21, 2021 15:42
@Zbizu Zbizu marked this pull request as ready for review September 21, 2021 18:14
@Zbizu
Copy link
Contributor Author

Zbizu commented Sep 21, 2021

Fixed the bugs and walked a bit around the temple.

7.6, 8.6, 9.7, 10.99, 12.71: only client with protocol 10.98 allowed
10.98 vanilla/Windows: OK (walked a bit as a player, killed 2 rats, eaten a cheese, cast light healing, life is good)
10.98 edubart otc/Windows: OK (performed same test as above)

Waiting for a review.

@ghost ghost self-requested a review September 21, 2021 18:42
@Zbizu Zbizu changed the title early support for web login early support for web login and packet sequencing Sep 21, 2021
@ghost ghost requested review from ranisalt and nekiro September 22, 2021 19:27
receivedFirst = true;

if (!protocol) {
// Skip deprecarted checksum bytes (with clients that aren't using it in mind)
uint16_t len = msg.getLength();
if (len < 280 && len != 151) {
Copy link
Member

Choose a reason for hiding this comment

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

I would like to know what are these numbers xD

Copy link
Contributor Author

@Zbizu Zbizu Sep 22, 2021

Choose a reason for hiding this comment

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

151 is exact packet length for 8.6 and 9.7 (and probably all the clients in the middle)
clients that use checksums have packet lengths larger than 280 although I'm not sure how was that figured out
7.6 has packet lengths varying on user input for credentials fields, but it never goes above 100

This won't affect the gameplay because after login, it skips all these checks and just calls onRecvPacket

// Read size of the first packet
boost::asio::async_read(socket,
boost::asio::buffer(msg.getBuffer(), NetworkMessage::HEADER_LENGTH),
std::bind(&Connection::parseHeader, shared_from_this(), std::placeholders::_1));
Copy link
Member

@ranisalt ranisalt Sep 25, 2021

Choose a reason for hiding this comment

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

You can use a lambda here, I think it will be way cleaner, e.g.

		auto bufferLength = !receivedLastChar && receivedName && connectionState == CONNECTION_STATE_CONNECTING_STAGE2 ?  1 : NetworkMessage::HEADER_LENGTH
			// Read size of the first packet
		boost::asio::async_read(socket,
			boost::asio::buffer(msg.getBuffer(), bufferLength),
			[connection = shared_from_this()](auto packet) { connection->parseHeader(packet); });

Not 100% sure about the syntax but you'll get the idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand this enough to make that change. I'm not that good at c++

Copy link
Member

Choose a reason for hiding this comment

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

I believe it is right now, just copy it over the whole if/else block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you meant. There is same code with a small difference written twice. The code preview on github didn't show that so I didn't understood the context. Everything is clear now.

Copy link
Contributor Author

@Zbizu Zbizu Oct 13, 2021

Choose a reason for hiding this comment

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

[connection = shared_from_this()](auto packet) { connection->parseHeader(packet); }); this line causes an error btw

C2780 "auto Connection::accept::<lambda_a28015d96ed371fa3d8a39af35f1cb78>::operator ()(_T1) const": expected 1 argument, got 2 theforgottenserver c:\vcpkg\installed\x64-windows\include\boost\asio\impl\read.hpp 480 so I'll use current tfs implementation instead

@Zbizu Zbizu requested a review from ranisalt October 13, 2021 19:58
@Zbizu
Copy link
Contributor Author

Zbizu commented Oct 13, 2021

Applied the requested changes except for lambda expression because it was causing compiling issues

@ranisalt ranisalt requested a review from a user October 13, 2021 20:27
@Zbizu Zbizu mentioned this pull request Oct 18, 2021
3 tasks
@Zbizu
Copy link
Contributor Author

Zbizu commented Oct 24, 2021

See the pull request referenced above for continuation of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants