Commit graph

130 commits

Author SHA1 Message Date
Hugo Locurcio 37ff524d8c
Improve error reporting in WebSocketServer
This should make troubleshooting easier.

(cherry picked from commit 58455b18b5)
2021-07-06 13:38:54 +02:00
Fabio Alessandrelli 63f6b29f51
[Net] Add WebSocketServer handshake_timeout property.
Allows customization of the maximum time a client is allowed to stay in
the the "pending" state (i.e. awaiting HTTP handshake).

This used to be 1 second by before, the new default is 3 seconds.

(cherry picked from commit 458437edef)
2021-06-29 14:02:23 +02:00
Fabio Alessandrelli 4994b3a99e
[Net] Fix WebSocketClient path parsing.
Recent changes to parse_url caused the client to make invalid HTTP
requests if no path was specified.

(cherry picked from commit d244dda597)
2021-06-29 14:02:23 +02:00
Rémi Verschelde 140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde 6e600cb3f0
Style: Set clang-format Standard to c++14 2021-05-04 14:45:15 +02:00
MaxStgs 1fc0fb7a5e
Add WebSocketMultiplayerPeer _incoming_packets check bound
(cherry picked from commit 05ad08941b)
2021-05-03 21:39:43 +02:00
Fabio Alessandrelli 77e3514315
[Net] Implement String::parse_url for parsing URLs.
Splits the URL into (scheme, host, port, path).
Supports both literal IPv4 and IPv6.
Strip credentials when present (e.g. http://user:pass@example.com/).

Use that function in both HTTPRequest and WebSocketClient.

(cherry picked from commit 3bb40669d5)
2021-05-03 21:39:43 +02:00
Rémi Verschelde e94161dada
SCons: Add explicit dependencies on thirdparty code in cloned env
Since we clone the environments to build thirdparty code, we don't get an
explicit dependency on the build objects produced by that environment.

So when we update thirdparty code, Godot code using it is not necessarily
rebuilt (I think it is for changed headers, but not for changed .c/.cpp files),
which can lead to an invalid compilation output (linking old Godot .o files
with a newer, potentially ABI breaking version of thirdparty code).

This was only seen as really problematic with bullet updates (leading to
crashes when rebuilding Godot after a bullet update without cleaning .o files),
but it's safer to fix it everywhere, even if it's a LOT of hacky boilerplate.

(cherry picked from commit c7b53c03ae)
2021-04-29 16:57:00 +02:00
Rémi Verschelde 70ae90e0e8
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.

Backport of #48239.
2021-04-29 12:34:11 +02:00
Rémi Verschelde c3272997cd
doc: Update classref headers with 3.4 version 2021-04-26 13:15:29 +02:00
Hugo Locurcio cd4906ee0b
Document secure wss:// caveats for WebSocketClient
See https://github.com/godotengine/godot/issues/37739.

(cherry picked from commit a56e37545b)
2021-04-12 00:23:44 +02:00
Rémi Verschelde 1aba997d75
doc: Sync classref with 3.3 version bump 2021-03-23 13:40:34 +01:00
Rémi Verschelde 49646383f1
Update copyright statements to 2021
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 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Fabio Alessandrelli 8ebb52fad6 [HTML5] Add function signatures to JS libraries. 2020-12-04 23:37:41 +01:00
Fabio Alessandrelli f316a1719d [HTML5] Run eslint --fix.
Should I write a poem about this whole new world? ;)
2020-11-23 13:27:13 +01:00
Fabio Alessandrelli e4cdae3624 [HTML5] Libraries refactor for linting.
Initial work to make liniting easier.

This includes:
- Rename http_request.js to library_godot_http_request.js.
- Rename externs.js to engine.externs.js.
- New library_godot_runtime.js (GodotRuntime) wraps around emscripten
  functions.
- Refactor of XMLHttpRequest handler in engine/preloader.js.
- Few fixes to bugs spotted by early stage linting.
2020-11-21 14:23:32 +01:00
Marcel Admiraal 04103db6bd
Fix godot_js_websocket_send function unused assignment.
(cherry picked from commit 112e2fdfc3)
2020-11-17 22:25:49 +01:00
Fabio Alessandrelli e52ed6d89e [HTML5] Port JavaScript inline code to libraries.
The API is implemented in javascript, and generates C functions that can
be called from godot.
This allows much cleaner code replacing all `EM_ASM` calls in our C++
code with plain C function calls.
This also gets rid of few hacks and comes with few optimizations (e.g.
custom cursor shapes should be much faster now).
2020-11-10 10:56:13 +01:00
Fabio Alessandrelli 806b23208f Fix modules with closure compiler. 2020-06-18 09:21:14 +02:00
Rémi Verschelde 7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Rajat Goswami 19e71f94d8 Adding missing include guards to header files identified by LGTM.
This addresses the issue godotengine/godot#37143

(cherry picked from commit 2ecf928ae3)
2020-03-25 11:38:54 +01:00
Fabio Alessandrelli 50763ecac4 Fix EMWSClient::get_connection_status(), try catch
(cherry picked from commit ebeeb67224)
2020-02-18 14:20:34 +01:00
Fabio Alessandrelli a48d0b5eef Disable Nagle's algorithm for WebSocket TCP.
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.
2020-01-28 14:10:46 +01:00
Rémi Verschelde f0f0f38d1a
Merge pull request #35516 from Faless/ws/fix_latency_32
Lower WebSocket latency, fixes.
2020-01-26 19:03:00 +01:00
Rémi Verschelde 2d20fc39aa doc: Drop unused 'category' property from header
We already removed it from the online docs with #35132.

Currently it can only be "Built-In Types" (Variant types) or "Core"
(everything else), which is of limited use.

We might also want to consider dropping it from `ClassDB` altogether
in Godot 4.0.
2020-01-26 16:02:39 +01:00
Fabio Alessandrelli 5bd9f14ad9 Lower WebSocket latency, fixes.
WSLPeer now tries to flush packet queue after put_packet call.
WSLServer::listen correctly returns TCP_Server::listen return value.
2020-01-24 14:50:53 +01:00
Rémi Verschelde ba177ccaec doc: Misc updates for AnimationNode* and others
- Add some missing descriptions.
- Add links to tutorials for ARVR and AnimationTree.
- Style fixes.
- Engine changes:
  * Make `AnimationNodeTransition.input_<number>` properties internal
    so that they don't appear in the docs. They still appear in the
    inspector based on the actual number of inputs requested.
  * Drop unimplemented `CPUParticles.flatness`. It's only used for 3D
    particles in `ParticlesMaterial`, and thus only relevant for
    `CPUParticles3D`.
2020-01-23 12:37:33 +01:00
Fabio Alessandrelli 50f1b035b8 Fix MultiplayerAPI crash when peer impl misbehave.
Also fix WebSocketMultiplayer::get_available_packet_count() return value
when peer is not configured to use the multiplayer API.
2020-01-21 20:46:32 +01:00
Rémi Verschelde 1de633205f Validate input in (CPU)Particles set_emission_shape()
Fixes #29777.

Co-authored-by: Cameron Reikes <cameronreikes@gmail.com>
2020-01-16 11:08:51 +01:00
Houkime e1a0ce5af9 Prevent GDScript language server from listening to external hosts by default
* Add bind_ip property to WebSocketServer defaulting to "*" (listen to everyone)
* Set default for GDscript Language Server to listen only to localhost

Fixes potential security issue with GDScript language server being exposed to the
broad net by default.
Since it is the server which primary usage is to provide utility to the local
editor there is no need to expose it.
2020-01-15 00:29:59 +00:00
Fabio Alessandrelli aa744aee7d Update documentation to reflect HTML5 limitations. 2020-01-14 15:42:47 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
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.
2020-01-01 11:16:22 +01:00
Fabio Alessandrelli 9afdb9dcd3 WSLPeer now prevents receiving data after close.
Used to spit error and report empty packets when connection was still
half-closed (waiting for confirmation from other end).
2019-12-21 16:38:36 +01:00
Marcel Admiraal 8fa72a20f3 Fix Visual Studio throwing C4334 warning. 2019-11-15 14:11:12 +01:00
Fabio Alessandrelli 2bb3e358e0 Trim protocol field from spaces in WS classes. 2019-10-16 16:16:27 +02:00
Fabio Alessandrelli d75e0de729 Fix HTML5 build after 67a4c30.
I messed up a rebase and a commit was partly skipped
2019-10-15 14:15:02 +02:00
Rémi Verschelde d655a7c097 doc: Sync classref with current source 2019-10-11 08:45:03 +02:00
Fabio Alessandrelli 2c557787c1 Document all this new improvements. 2019-10-09 13:53:04 +02:00
Fabio Alessandrelli 67a4c3033b Custom headers support in WebSocketClient.
This commit also converts all PoolVector<String> parameters to
`const Vector<String>` in both WebSocketServer and WebSocketClient.
2019-10-09 13:53:04 +02:00
Fabio Alessandrelli c723a8b6aa Implement WebSocketServer SSL support. 2019-10-09 13:53:04 +02:00
Fabio Alessandrelli 33644d7118 WebSocketClient can now use custom SSL certificate
Via the `trusted_ssl_certificate` property.
2019-10-09 13:53:04 +02:00
Fabio Alessandrelli 025cc04d9e Re-implement WebSocket get host/port.
Was lost during library switch
2019-10-09 13:53:04 +02:00
Rémi Verschelde a7ac8ec876 doc: Fix parsing of self-closing XML tags
Follow-up to #31925, `<member />` tags just before `</members>` would cause
a parsing issue, and we'd never notice that we're no longer parsing members.

Also added space before closing `/>`.
2019-09-24 13:34:05 +02:00
Bojidar Marinov b397bcf4a1
Run doctool after overridden properties changes 2019-09-04 15:26:08 +03:00
Rémi Verschelde 538328898b Style: Fix copyright headers in new files 2019-08-28 09:19:52 +02:00
Rémi Verschelde 99980d856b
Merge pull request #29871 from Faless/crypto/initial_pr
More Crypto, SSL server, crt/key as Resource, HashingContext
2019-08-21 18:03:03 +02:00
Rémi Verschelde f2c9252b6e
Merge pull request #31483 from Faless/ws/fix_double_relay
Fix WebSocketServer relaying message twice.
2019-08-20 12:49:15 +02:00
Fabio Alessandrelli d1539db2c6 Fix WebSocketServer relaying message 2 times.
The WebSocketMultiplayerPeer was relaying the same message two times,
both in _server_relay and _process_multiplayer (which was only supposed
to store the packet, given the server was one of the destination).

_process_multiplayer now only store the packet, and calls _server_relay
which will relay the message to other clients if needed.
2019-08-19 18:18:13 +02:00