summaryrefslogtreecommitdiffstats
path: root/modules/websocket/wsl_peer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix copyright headers referring to GodotSpartan3222024-10-271-2/+2
|
* Fix websocket dropping messages for WSLPeerradenthefolf2024-10-141-1/+17
| | | | | | | Allows WSLPeer to grab the length of incoming messages Only accept them if they fit in in_buffer (cherry picked from commit godotengine/godot@e11d58189e1cc161e76cfb816c3eebda66f917ff)
* Rebrand preambles to RedotSpartan3222024-10-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | (cherry picked from commit e8542b06acca3c1bdeee4b528411771f0819f084) Credits: Co-authored-by: Skogi <skogi.b@gmail.com> Co-authored-by: Spartan322 <Megacake1234@gmail.com> Co-authored-by: swashberry <swashdev@pm.me> Co-authored-by: Christoffer Sundbom <christoffer_karlsson@live.se> Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: McDubh <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com> Co-authored-by: radenthefolf <radenthefolf@gmail.com> Co-authored-by: John Knight <80524176+Tekisasu-JohnK@users.noreply.github.com> Co-authored-by: Adam Vondersaar <adam.vondersaar@uphold.com> Co-authored-by: decryptedchaos <nixgod@gmail.com> Co-authored-by: zaftnotameni <122100803+zaftnotameni@users.noreply.github.com> Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com> Co-authored-by: wesam <108880473+wesamdev@users.noreply.github.com> Co-authored-by: Mister Puma <MisterPuma80@gmail.com> Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com> Co-authored-by: SingleError <isaaconeoneone@gmail.com> Co-authored-by: Bioblaze Payne <BioblazePayne@gmail.com>
* [WS] Fix set_no_delay on WindowsFabio Alessandrelli2024-08-071-2/+3
| | | | | | | | | | | Windows socket implementation is, as usual, broken in many ways. This includes `setsockopt` failing to set `TCP_NODELAY` if the socket is still in a connecting state. This also means we need to keep polling the IP resolver until the socket reaches the CONNECTED state (so it can set the TCP_NODELAY after the connection is successful).
* Merge pull request #94168 from Faless/net/wsl_peer_reuseRémi Verschelde2024-08-011-2/+2
|\ | | | | | | [WebSocket] Allow reusing closing and closed peers
| * [WebSocket] Allow reusing closing and closed peersFabio Alessandrelli2024-07-101-2/+2
| |
* | [WebSocket] Ensure TCP_NODELAY is always setFabio Alessandrelli2024-07-221-1/+2
|/ | | | | | | | | | | Almost all WebSocket implementations (including all major browsers) disable Nagle's algorithm to favor low latency over packet overhead. This was also the case in Godot 3.x, while in Godot 4.0 this was only being done for clients and wasn't even always working due to a bug. This commit fixes the aforementioned bug, and forces TCP_NODELAY when accepting a stream as a server.
* [Modules] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicableA Thousand Ships2023-09-261-2/+2
|
* Style: Harmonize header includes in modulesRémi Verschelde2023-06-151-3/+1
| | | | | | | | | | | | | | | | | | | | This applies our existing style guide, and adds a new rule to that style guide for modular components such as platform ports and modules: Includes from the platform port or module ("local" includes) should be listed first in their own block using relative paths, before Godot's "core" includes which use "absolute" (project folder relative) paths, and finally thirdparty includes. Includes in `#ifdef`s come after their relevant section, i.e. the overall structure is: - Local includes * Conditional local includes - Core includes * Conditional core includes - Thirdparty includes * Conditional thirdparty includes
* [TLS] Fix crashes trying to use TLS when not available.Fabio Alessandrelli2023-05-121-1/+3
| | | | | | | | | If no StreamPeerTLS implementation is available, HTTPClient and WebSocketPeer will now correctly refuse to connect using TLS returning ERR_UNAVAILABLE. Similarly, ENetConnection will refuse to setup DTLS when PacketPeerDTLS is not available.
* Fix misuses of error macrosDanil Alexeev2023-04-181-3/+0
|
* [Net] Remove StreamPeerTLS.blocking_handshake option.Fabio Alessandrelli2023-01-281-1/+0
| | | | | | | | | Which was unused internally, and can be replaced by: ``` while tls.get_status() == tls.STATUS_HANDSHAKING: tls.poll() ```
* [NET] Refactor TLS configuration.Fabio Alessandrelli2023-01-281-4/+10
| | | | | | | | | | | | | Use a TLSOptions configuration object which is created via static functions. - "TLSOptions.client": uses the standard CA and common name verification. - "TLSOptions.client_unsafe": uses optional CA verification (i.e. if specified) - "TLSOptions.server": is the standard server configuration (chain + key) This will allow us to expand the TLS configuration options to include e.g. mutual authentication without bloating the classes that uses StreamPeerTLS and PacketPeerDTLS as underlying peers.
* One Copyright Update to rule them allRémi Verschelde2023-01-051-29/+29
| | | | | | | | | | | | | | | | | | | | As many open source projects have started doing it, we're removing the current year from the copyright notice, so that we don't need to bump it every year. It seems like only the first year of publication is technically relevant for copyright notices, and even that seems to be something that many companies stopped listing altogether (in a version controlled codebase, the commits are a much better source of date of publication than a hardcoded copyright statement). We also now list Godot Engine contributors first as we're collectively the current maintainers of the project, and we clarify that the "exclusive" copyright of the co-founders covers the timespan before opensourcing (their further contributions are included as part of Godot Engine contributors). Also fixed "cf." Frenchism - it's meant as "refer to / see".
* [WebSocket] Fix client failing to connect to direct IP.Fabio Alessandrelli2022-10-171-2/+4
| | | | | | | The bug was caused by not checking the TCP CONNECTING state appropriately during the client handshake, and not checking the TCP CONNECTED state during connection (which is unlikely, but might still happen).
* [WebSocket] Fix TCP connection being closed while connecting.Fabio Alessandrelli2022-10-131-0/+2
| | | | | Fix a bug causing the WebSocketPeer to fail connecting to a remote server when the TCP 3-way handshake took more than a few milliseconds.
* [WebSocket] Refactor websocket module.Fabio Alessandrelli2022-10-111-177/+668
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a huge refactor of the websocket module. The module is really old, and some design choices had to be re-evaluated. The WebSocketClient and WebSocketServer classes are now gone, and WebSocketPeer can act as either client or server. The WebSocketMultiplayerPeer class is no longer abstract, and implements the Multiplayer API on top of the lower level WebSocketPeer. WebSocketPeer is now a "raw" peer, like StreamPeerTCP and StreamPeerTLS, so it emits no signal, and just needs polling to update its internal state. To use it as a client, simply call WebSocketPeer.coonect_to_url, then frequently poll the peer until STATE_OPEN is reached and then you can write or read from it, or STATE_CLOSED and then you can check the disconnect code and reason). To implement a server instead, a TCPServer must be created, and the accepted connections needs to be provided to WebSocketPeer.accept_stream (which will perform the HTTP handshake). A full example of a WebSocketServer using TLS will be provided in the demo repository.
* [Web] Rename JavaScript platform to Web.Fabio Alessandrelli2022-08-291-2/+2
| | | | Also rename export name from "HTML5" to "Web".
* Fix some issues found by cppcheck.bruvzg2022-04-061-5/+5
|
* Update copyright statements to 2022Rémi Verschelde2022-01-031-2/+2
| | | | Happy new year to the wonderful Godot community!
* Websockets: Fix buffer size checks in put_packet()Max Hilbrunner2021-10-291-4/+4
| | | | Also check the error return value of wslay_event_queue_msg()
* Websocket peer outbound buffer fixes. Expose outbound buffered amount.Jordan Schidlowsky2021-07-311-1/+11
|
* Rename `IP_Unix`, `IP_Address` and `TCP_Server` to remove underscoresHugo Locurcio2021-05-061-2/+2
|
* Initialize class/struct variables with default values in modules/Rafał Mikrut2021-02-081-4/+0
|
* Update copyright statements to 2021Rémi Verschelde2021-01-011-2/+2
| | | | | | | | | | | | | | Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
* Style: Enforce braces around if blocks and loopsRémi Verschelde2020-05-141-8/+15
| | | | | Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
* Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde2020-05-141-9/+0
| | | | | | | | | | | | | | Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
* Replace NULL with nullptrlupoDharkael2020-04-021-10/+10
|
* PoolVector is gone, replaced by VectorJuan Linietsky2020-02-181-5/+5
| | | | | Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
* Disable Nagle's algorithm for WebSocket TCP.Fabio Alessandrelli2020-01-281-0/+6
| | | | | | This should greatly decrease latency for the most common use cases. A new function WebSocketPeer::set_no_delay will allow to configure it if so desired.
* Lower WebSocket latency, fixes.Fabio Alessandrelli2020-01-241-0/+4
| | | | | WSLPeer now tries to flush packet queue after put_packet call. WSLServer::listen correctly returns TCP_Server::listen return value.
* Update copyright statements to 2020Rémi Verschelde2020-01-011-2/+2
| | | | | | | | | | | Happy new year to the wonderful Godot community! We're starting a new decade with a well-established, non-profit, free and open source game engine, and tons of further improvements in the pipeline from hundreds of contributors. Godot will keep getting better, and we're looking forward to all the games that the community will keep developing and releasing with it.
* WSLPeer now prevents receiving data after close.Fabio Alessandrelli2019-12-211-1/+2
| | | | | Used to spit error and report empty packets when connection was still half-closed (waiting for confirmation from other end).
* Fix Visual Studio throwing C4334 warning.Marcel Admiraal2019-11-151-1/+1
|
* Re-implement WebSocket get host/port.Fabio Alessandrelli2019-10-091-7/+4
| | | | Was lost during library switch
* Style: Fix copyright headers in new filesRémi Verschelde2019-08-281-1/+1
|
* Move CryptoCore to it's own folder.Fabio Alessandrelli2019-08-191-1/+1
| | | | Crypto classes will be placed in core/crypto.
* WebSocket module now uses wslay library.Fabio Alessandrelli2019-07-041-0/+339
Both client and server are supported on native builds (as usual). SSL server is still not supported, but will soon be possible with this new library. The API stays the same, we just need to work out potential issues due to this big library switch.