Giter Site home page Giter Site logo

jchampio / apache-websocket Goto Github PK

View Code? Open in Web Editor NEW

This project forked from disconnect/apache-websocket

6.0 6.0 4.0 280 KB

WebSocket plugin module for the Apache HTTP Server

License: Apache License 2.0

Python 22.32% C 62.67% CMake 8.86% Shell 0.17% PowerShell 0.78% Makefile 2.54% M4 2.67%
apache-httpd websocket

apache-websocket's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

apache-websocket's Issues

Make plugins choose subprotocols by index instead of providing a string

mod_websocket_protocol_set() takes a const char* as an argument. This implies that it is legal for plugins to provide any string as a subprotocol, when in fact they must choose a subprotocol from the list provided by the client (or use none at all). The API should change to accept a numerical index (pointing to a subprotocol in the connection's protocols array) rather than any arbitrary string.

Allow plugins to read Pong bodies

RFC 6455 allows endpoints to send application data in pings. If we don't let the plugin read the application data received in the pong, this feature is somewhat useless.

Let developers point the test suite at an arbitrary server

The test suite currently hardcodes ws://127.0.0.1 as its root for constructing test URLs. It should be possible for developers to point the test suite at any arbitrary scheme/hostname/port, both as a general usability improvement and to assist in the testing of TLS-enabled installations (wss://).

mod_websocket chooses the first client subprotocol by default

If a plugin doesn't manually set a subprotocol in its on_connect callback, mod_websocket will just choose the first one provided by the client. This means that unsuspecting plugins may be "agreeing" to speak a subprotocol that they know nothing about. This behavior should be removed.

Allow plugins to read and write close codes/reasons

Plugins currently cannot read or write the status code or reason string for close frames. Incoming close frames are completely hidden by the module, and server->close() does not take any code or reason string in its parameter list.

Several invalid handshakes are not rejected

mod_websocket is too lax in its parsing of the initial client handshake (i.e. it doesn't correctly implement Sec. 4.2.1 of the RFC). Some examples:

  • Sec-WebSocket-Version values such as 13abc, +13, and 08 are allowed
  • HEAD requests are upgraded
  • the Origin header isn't checked at all
  • any value is accepted for Sec-WebSocket-Key

Provide a "allow reserved close codes" option

Per this conversation with Tobias Oberstein: WebSocket plugin developers and server admins should have a switch which allows reserved+undefined opcodes in the range 1000-2999. This would allow developers to research new official extensions to the protocol.

This switch should default to "off", since most end users of the module will not be doing official development work on RFCs. Additionally, reserved opcodes that are defined as "MUST NOT be set as a status code" should continue to be rejected even if this mode is turned on.

Poor performance when receiving fragmented messages

Incoming frames are concatenated into a single contiguous block of memory, which is realloc'd once for every single frame. This craters performance for extremely fragmented messages (see for example Autobahn|TestSuite case 9.3.1).

Look into minimizing the number of reallocations that must be done (maybe keep a linked list of frames and concatenate once at the end?).

Non-conformant close frame handling

Autobahn flags a few issues in the way we handle close frames:

  • Close frame payloads with only one byte are not rejected (it has to either be empty or at least a two-byte status code)
  • Invalid UTF-8 close frame payloads are not rejected
  • Invalid close status codes are not rejected

MaxMessageSize applies only to frames, not messages

The MaxMessageSize directive only rejects frames that are longer than the payload_limit. If an adversary sends a huge number of frames that are smaller than the MaxMessageSize, the module will happily try to buffer all of them.

Side note: why is MaxMessageSize not named WebSocketMaxMessageSize?

Failing Python tests often result in a hang

A test that fails to conform to expectations usually results in a hang (since the test will end up waiting for an event that never actually occurs). This is annoying when debugging issues.

The test suite framework should be modified to understand the concept of a timeout.

One WebSocket connection monopolizes an entire Apache worker thread

The current threading architecture blocks an entire worker thread for the duration of a WebSocket connection. This means that once a certain number of WebSocket connections are established, the server will be completely unable to serve new requests.

We need some way to either change the architecture so that idle workers can be released back to the server, or provide a limit on the number of simultaneous WebSocket connections that can be made to the server, in order to avoid this denial-of-service situation.

Use of ap_get_conn_socket() breaks in Apache 2.2

Turns out ap_get_conn_socket is Apache 2.4 only. The "2.2 way" is to use

ap_get_core_module_config(state->r->connection->conn_config);

but it seems like that function isn't exported publicly...

No Origin checks are done on incoming handshakes

The Origin header (or Sec-WebSocket-Origin, for earlier draft versions) is never checked during the opening handshake, which means the server does not reject unauthorized cross-origin connections.

apr_int64_t is everywhere; length types need to be fixed

apr_int64_t is used almost everywhere. Sometimes it's not needed (i.e. the WebSocket protocol version), sometimes an apr_size_t should be there instead (i.e. when calculating buffer sizes), and sometimes we should probably use apr_uint64_t because negative values are unnecessary.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.