Jump to content
Eternal Lands Official Forums
Sign in to follow this  
CeruleanBlaze

Server's response to a login request

Recommended Posts

Hey

Curiosity inspired me to try writing a bot in Python. I've ran into an issue fairly quickly, however, with the logging in. What i'm doing is:

 

Connecting to the server on port 2000

Reading the data from the socket (welcome message)

Sending the username and password, separated by a blank space, prepended by LOG_IN (0x8c).

Reading the server's response

 

From what I understand I read the response to the login and check the first character against LOG_IN_OK and LOG_IN_NOT_OK. The problem is that the response i'm getting is "<\x05\x00h\x01\xae\x0e" (sans the quotes of course). The first character (0x3c/60) is neither LOG_IN_OK (250) nor LOG_IN_NOT_OK (251).

I suppose that i'm missing out a step or sending something incorrectly.

Apologies if it's something simple (it usually always is). If any part needs clarifying just say so.

 

Thanks for your time

Edited by CeruleanBlaze

Share this post


Link to post
Share on other sites

Hrm, the first thing my bot gets is the login message, which used to throw it... not sure if it's raw text you're getting, though.

Share this post


Link to post
Share on other sites

LOG_IN_OK is not necessarily the first thing you get. I don't even know for sure if there is a specific order in which events arrive.

Share this post


Link to post
Share on other sites
  Hrm, the first thing my bot gets is the login message, which used to throw it...

Didn't get a login message, just got that data that I pasted - "<\x05\x00h\x01\xae\x0e", where \x signifies hex.

 

 

LOG_IN_OK is not necessarily the first thing you get. I don't even know for sure if there is a specific order in which events arrive.

I thought that might be the case so I read data from the socket over a 10 second interval - that was the only data I got.

Share this post


Link to post
Share on other sites

Look in client_server.h for more info about the protocol. That way, by examinign the first byte, you can see what the server sends.

Share this post


Link to post
Share on other sites

Looks like that wasn't my issue (or maybe it was another).

I've replied to the ping (just sent the received data straight back), and then sent the login request:

self.sock.send("%s%s %s" % (chr(el.LOG_IN), self.username, self.password))

I just get no response from the server.

Any suggestions?

Share this post


Link to post
Share on other sites

You need to send the length of the message too. First, the protocol number (one byte), then the total size of the message (unsigned short, two bytes, little-endian), then the message itself.

Share this post


Link to post
Share on other sites

Unfortunately i'm still having the same luck.

Here's a log of what i'm sending (shown by '>') and what i'm receiving (shown by '<')

 

< "\x00t\x01\x90Hi, and welcome to Eternal Lands! If you're new to the game and need help, please read the newbie helper guides on the main website. If you would rather learn by doing, talk to the Tutorial NPC, which is at the start point. In addition to that, you can type #help_me and your question to get a live response if there are helpers online. Click on the screen to continue!\n"
> '\x8c\x11\x00Chocolate xxxxxxx'
< '<\x05\x00\xbe\xcf\xe3\x13'
> '<\x05\x00\xbe\xcf\xe3\x13'
< '<\x05\x00g\xd0\xe3\x13\xfb\x01\x00'
> '<\x05\x00g\xd0\xe3\x13\xfb\x01\x00'
Connection closed by server

You can see the welcome message, my login, and my responding to the pings. The connection is then closed (I receive null data from the socket).

 

Thanks to everyone who's stopped by and lent a hand already. I appreciate it.

Share this post


Link to post
Share on other sites

Precisely what i've done - I see no difference. I downloaded elbot (elbot.sf.net) and logged what it sent - it sent the username and password precisely how I did and then got a LOG_IN_OK response directly.

This one has got me scratching my head :P

Share this post


Link to post
Share on other sites

EDIT.

 

Send null packets at least every 15 seconds, otherwise you'll get disconnected. (GRUE)

Edited by Placid

Share this post


Link to post
Share on other sites
EDIT.

 

Send null packets at least every 15 seconds, otherwise you'll get disconnected. (GRUE)

You're supposed to send a heartbeat packet once per minute. Don't waste the servers bandwidth please :(

Share this post


Link to post
Share on other sites
EDIT.

 

Send null packets at least every 15 seconds, otherwise you'll get disconnected. (GRUE)

You're supposed to send a heartbeat packet once per minute. Don't waste the servers bandwidth please :(

Heh, that was me getting the timing wrong....I'll amend my bots code :D

Also, I meant 'null' packets as HEARTBEAT packets :) (They are null packets with the EL constant (from client_serv.h) as first byte)

Edited by Placid

Share this post


Link to post
Share on other sites
How can there be a first byte in a null packet?

I think Its my terminology, the packet doesnt actually contain anything, apart from the HEARTBEAT constant, thats what I mean...Sorry :blink:

Share this post


Link to post
Share on other sites

it contains the length too =P

and it only need to be sent when u didnt send anything in the last 25 seconds.

Share this post


Link to post
Share on other sites
it contains the length too =P

and it only need to be sent when u didnt send anything in the last 25 seconds.

ROFL, ok I stand corrected :P

 

Yes, frak is right, im just talking spurts of rubbish here :P

Share this post


Link to post
Share on other sites

Well, i'm getting something now, though i'm not too sure what :S

I tried sending the login message and then sleeping for a second. When I read the data from the socket I get one _long_ piece of data in response - it includes the welcome message and a tonne of bytes. It looks fairly promising as I can see, amidst those bytes, the text `/maps/startmap.elm` - i'm guessing it's telling the client to display that map.

It just strikes me as odd that I should be receiving such a big lump of data.

Here is all the data (again note that \x0a, for example, represents the hex value 0a)

Edited by CeruleanBlaze

Share this post


Link to post
Share on other sites

You're getting a whole bunch of messages from the server in one packet. Since the message length is included in the messages, you can split them and parse them all separately. Have a look at multiplayer.c, get_message_from_server() and process_data_from_server()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×