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

Update wsmc/Java for mc framing removal in wsmc/JS #25

Merged
merged 4 commits into from
Jan 17, 2016
Merged

Conversation

deathcap
Copy link
Owner

#21 removed the varint length prefix from the ws-encapsulated mc protocol, but only in the JavaScript version (wsmc.js). The Java proxy should be updated too, or it won't be compatible with new clients.

To close #22

@deathcap
Copy link
Owner Author

^C^[[Awsmc $ ./run.sh 
+ java -cp target/wsmc-0.0.1.jar deathcap.wsmc.Main
WS(0.0.0.0:24444) <--> MC(localhost:25565)
Jan 17, 2016 2:34:30 PM deathcap.wsmc.lib.netty.channel.DefaultChannelId defaultProcessId
WARNING: Failed to find the current process ID; using a random value: 52704
Jan 17, 2016 2:34:36 PM deathcap.wsmc.web.WebSocketHandler setupInitialConnection
INFO: Received WS connection: /0:0:0:0:0:0:0:1:63810 --> /0:0:0:0:0:0:0:1:24444
Jan 17, 2016 2:34:36 PM deathcap.wsmc.web.WebSocketHandler setupInitialConnection
INFO: readableBytes = 14
Jan 17, 2016 2:34:36 PM deathcap.wsmc.web.WebSocketHandler setupInitialConnection
INFO: clientCredential = mcwebchatuserX
Jan 17, 2016 2:34:36 PM deathcap.wsmc.web.WebSocketHandler setupInitialConnection
INFO: command-line mode, allowing everyone
Connecting to localhost:25565 as mcwebchatuserX
Connected to localhost/127.0.0.1:25565
wrote handshake packet
opcode = 3
03 80 
Compression threshold set to 256
m = UnpooledUnsafeDirectByteBuf(ridx: 0, widx: 3, cap: 3)=03 80 02 
mc -> ws: 03 80 02 

mcwebchat fails to decode, 256 is not in the mappings value:

function readMapper(buffer, offset, _ref, rootNode) {
  var type = _ref.type;
  var mappings = _ref.mappings;

  var _read = this.read(buffer, offset, type, rootNode);

  var size = _read.size;
  var value = _read.value;

  var results = {
    size: size,
    value: mappings[value]
  };
  if (results.value == undefined) throw new Error(value + " is not in the mappings value");
  return results;
}

buffer is [128, 2, 0], tries to read varint for packet type, gets 256 (varint size 2).

versus wsmc/JS proxy:

compress { threshold: 256 }
mc received 3 bytes

000000   03 80 02                                          ...
lengthField= <Buffer 03>
writing to ws 4 bytes

000000   03 03 80 02                                       ....

still have length prepending on mc -> ws. Only remove on ws -> mc?

@deathcap deathcap changed the title [WIP] Update wsmc/Java for mc framing removal in wsmc/JS Update wsmc/Java for mc framing removal in wsmc/JS Jan 17, 2016
deathcap added a commit that referenced this pull request Jan 17, 2016
Update wsmc/Java for mc framing removal in wsmc/JS
@deathcap deathcap merged commit 11741d3 into master Jan 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update wsmc/Java for mc framing removal in wsmc/JS
1 participant