Make sure it makes it through the previous steps too (handshake and header), they are different in 317 and 474 as far as I remember.
You could also do some debugging by putting println's etc around the code to see where it may possibly fail
|
Could someone explain why this code doesn't cooperate with certain client revisions?
I don't understand why my 474 clients don't connect to this but it came from the Apollo484 and my 317 client will.
Code:private Object decodePayload(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() >= loginLength) { ChannelBuffer payload = buffer.readBytes(loginLength); int releaseNumber = payload.readInt(); int lowMemoryFlag = payload.readUnsignedByte(); if (lowMemoryFlag != 0 && lowMemoryFlag != 1) throw new Exception("Invalid value for low memory flag"); boolean lowMemory = lowMemoryFlag == 1; for (int i = 0; i < 24; i++) payload.readByte(); int[] archiveCrcs = new int[16]; for (int i = 0; i < 16; i++) archiveCrcs[i] = payload.readInt(); loginLength--; int securePayloadLength = payload.readUnsignedByte(); int secureBytesLength = (loginLength - 93); if (securePayloadLength != secureBytesLength) throw new Exception("Secure payload length mismatch"); byte[] secureBytes = new byte[secureBytesLength]; payload.readBytes(secureBytes); ChannelBuffer securePayload = ChannelBuffers.wrappedBuffer(new BigInteger(secureBytes).modPow(RSA_EXPONENT, RSA_MODULUS).toByteArray()); int secureId = securePayload.readUnsignedByte(); if (secureId != 10) throw new Exception("Invalid secure payload id"); long clientSeed = securePayload.readLong(); long reportedServerSeed = securePayload.readLong(); if (reportedServerSeed != serverSeed) throw new Exception("Server seed mismatch"); String username = NameUtil.decodeBase37(securePayload.readLong()); String password = ChannelBufferUtil.readString(securePayload); if (username.length() > 12 || password.length() > 20) throw new Exception("Username or password too long"); int[] seed = new int[4]; seed[0] = (int) (clientSeed >> 32); seed[1] = (int) clientSeed; seed[2] = (int) (serverSeed >> 32); seed[3] = (int) serverSeed; IsaacRandom decodingRandom = new IsaacRandom(seed); for (int i = 0; i < seed.length; i++) seed[i] += 50; IsaacRandom encodingRandom = new IsaacRandom(seed); PlayerCredentials credentials = new PlayerCredentials(username, password, usernameHash); IsaacRandomPair randomPair = new IsaacRandomPair(encodingRandom, decodingRandom); LoginRequest req = new LoginRequest(credentials, randomPair, reconnecting, lowMemory, releaseNumber, archiveCrcs); if (buffer.readable()) { return new Object[] { req, buffer.readBytes(buffer.readableBytes()) }; } else { return req; } } return null; }
Make sure it makes it through the previous steps too (handshake and header), they are different in 317 and 474 as far as I remember.
You could also do some debugging by putting println's etc around the code to see where it may possibly fail
Although I haven't checked the previous steps. I did have prints around this code and I noticed that for example:
When I changed "93" to a number that would make the if statement work, it would throw an exception on the next. And the number to replace 93 with wasn't consistent. It also changed when I used different logins which is problematic.Code:int securePayloadLength = payload.readUnsignedByte(); int secureBytesLength = (loginLength - 93); if (securePayloadLength != secureBytesLength) throw new Exception("Secure payload length mismatch");
A more detailed explanation of my problem...
I threw a system print before the code I posted above to determine the loginLength. This changes with different name/password lengths. I have studied the Rs474 LoginDecoder and have recognized the similar system however it is similar to the extent that it has everything around the above code, but not the code or anything equivalent.
I printed the variables in the if statement that is throwing my client
The thing is loginLength changes upon username/password length. I think it varied from 119-135 as you can see that would cause trouble with the if statement. I set it to 114(loginLength=124) for the time being to suite my common username and of course was halted by the next if statement.Code:loginLength--; System.out.print("Done5"); System.out.print(loginLength); int securePayloadLength = payload.readUnsignedByte(); int secureBytesLength = (loginLength - 114); System.out.print(secureBytesLength); System.out.print(securePayloadLength); if (securePayloadLength != secureBytesLength) throw new Exception("Secure payload length mismatch");
As far as RSA keys do they differ that from client to client? My current client has no RSA keys, but when I did add them(to another 474 client) at one point it changed nothing.
Well that did change my problem. I managed to add the RSA keys from the server. Now this is crashing my client
I'm just throwing this up here... I'll study it for a bit, but if you all have something to share, go for it.Code:private Object decodeHandshake(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readable()) { usernameHash = buffer.readUnsignedByte(); serverSeed = random.nextLong(); ChannelBuffer resp = ChannelBuffers.buffer(9); System.out.print("Done1"); resp.writeByte(LoginConstants.STATUS_EXCHANGE_DATA); resp.writeLong(serverSeed); channel.write(resp); setState(LoginDecoderState.LOGIN_HEADER); System.out.print("Done2"); } return null; }
Yeah it's odd. I used the client that came with rs2-server 474 and my original problem still occurred.
However if I use the 474 client I downloaded from another topic it never even passes decodeHandshake.
I've been studying the code and other code consistently for the past 30 hours or so, as I'm sitting in a hospital with nothing better to do.
bump, im getting this error to?
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |