lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

Add. Decode reserved bits in header. #55

Open moteus opened 9 years ago

lipp commented 9 years ago

why should we read out the reserved if they carry no info at all?

moteus commented 9 years ago

SV1, RSV2, RSV3: 1 bit each

  MUST be 0 unless an extension is negotiated that defines meanings
  for non-zero values.  If a nonzero value is received and none of
  the negotiated extensions defines the meaning of such a nonzero
  value, the receiving endpoint MUST _Fail the WebSocket
  Connection_.
  1. Implementation must check this to complain rfc
  2. It ma be set(I do not kno how yet)
  3. It needed to pass autobahn test(test case 3)
lipp commented 9 years ago

ok. but this implementation does not support extensions yet. further, we are not processing the rsv values... how can the autobahn test suite check this?

moteus commented 9 years ago

Autobahn server send messages with setted rsv and client must close connection with 1002 status

lipp commented 9 years ago

Ok. I don't see that the connection is closed when rsv != 0. Can we add this test to the Travis file?

moteus commented 9 years ago

May be we can use autobahn server. The only problem is I do not know how detect test fail. To run testcase for RSV you can use wstest -m fuzzingserver -s rsv-config.json with config like

{
   "url": "ws://127.0.0.1:9001",
   "outdir": "./reports/clients",
   "cases": ["3.*"],
   "exclude-cases": [],
   "exclude-agent-cases": {}
}

My test runner is https://github.com/moteus/lua-lluv-websocket/blob/master/test/autobahn_client_test.lua

lipp commented 9 years ago

interesting. i'd like to integrate that somehow.

anyways, shouldn't there be a check for rsv bytes and eventually a connection close?

moteus commented 9 years ago

shouldn't there be a check for rsv bytes and eventually a connection close?

websocket implementation should check RSV and if it not 0 then it should start close handshake with status 1002. I do not know how extensions works but it is valid for client without extenstions. So my lluv websocket in this case send protocol error and return WEBSOCKET.EOF error to client code. So this logic need to be inplemented in client/server code. Current implementation do not do this and it could work in real world but to provide ability to fix this websockets-core part should returns this bits.

moteus commented 9 years ago

I just make commit to run autobahn tests on Travis for lluv-websocket. Without this PR tests 3.* are failed.

lipp commented 9 years ago

:+1:

but still: we should integrate that test using the "official" api and auto-close the connection as you do in your lluv autobahn test client.

moteus commented 9 years ago

Please take a look to autobahn_wclient_test. It uses pablic client API. You just need remove SSL parts and replace uv.run() call. To run test you need first run run wstest wstest -m fuzzingserver -s rsv-config.json with config like

{
   "url": "ws://127.0.0.1:9001",
   "outdir": "./reports/clients",
   "cases": ["3.*"],
   "exclude-cases": [],
   "exclude-agent-cases": {}
}