diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/http_client.cpp | 4 | ||||
-rw-r--r-- | core/io/http_client.h | 4 | ||||
-rw-r--r-- | core/io/http_client_tcp.cpp | 72 | ||||
-rw-r--r-- | core/io/http_client_tcp.h | 6 | ||||
-rw-r--r-- | core/io/image.cpp | 10 | ||||
-rw-r--r-- | core/io/stream_peer_tls.cpp (renamed from core/io/stream_peer_ssl.cpp) | 34 | ||||
-rw-r--r-- | core/io/stream_peer_tls.h (renamed from core/io/stream_peer_ssl.h) | 20 | ||||
-rw-r--r-- | core/io/xml_parser.cpp | 2 |
8 files changed, 78 insertions, 74 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 52b1120b2a..93a310e83b 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -138,7 +138,7 @@ PackedStringArray HTTPClient::_get_response_headers() { } void HTTPClient::_bind_methods() { - ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(-1), DEFVAL(false), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_tls", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(-1), DEFVAL(false), DEFVAL(true)); ClassDB::bind_method(D_METHOD("set_connection", "connection"), &HTTPClient::set_connection); ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection); ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::_request_raw); @@ -190,7 +190,7 @@ void HTTPClient::_bind_methods() { BIND_ENUM_CONSTANT(STATUS_REQUESTING); // Request in progress BIND_ENUM_CONSTANT(STATUS_BODY); // Request resulted in body which must be read BIND_ENUM_CONSTANT(STATUS_CONNECTION_ERROR); - BIND_ENUM_CONSTANT(STATUS_SSL_HANDSHAKE_ERROR); + BIND_ENUM_CONSTANT(STATUS_TLS_HANDSHAKE_ERROR); BIND_ENUM_CONSTANT(RESPONSE_CONTINUE); BIND_ENUM_CONSTANT(RESPONSE_SWITCHING_PROTOCOLS); diff --git a/core/io/http_client.h b/core/io/http_client.h index de6045f647..0524b010f4 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -138,7 +138,7 @@ public: STATUS_REQUESTING, // Request in progress STATUS_BODY, // Request resulted in body, which must be read STATUS_CONNECTION_ERROR, - STATUS_SSL_HANDSHAKE_ERROR, + STATUS_TLS_HANDSHAKE_ERROR, }; @@ -168,7 +168,7 @@ public: Error verify_headers(const Vector<String> &p_headers); virtual Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_size) = 0; - virtual Error connect_to_host(const String &p_host, int p_port = -1, bool p_ssl = false, bool p_verify_host = true) = 0; + virtual Error connect_to_host(const String &p_host, int p_port = -1, bool p_tls = false, bool p_verify_host = true) = 0; virtual void set_connection(const Ref<StreamPeer> &p_connection) = 0; virtual Ref<StreamPeer> get_connection() const = 0; diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 9499a6f8e3..5c1d00a330 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -32,14 +32,14 @@ #include "http_client_tcp.h" -#include "core/io/stream_peer_ssl.h" +#include "core/io/stream_peer_tls.h" #include "core/version.h" HTTPClient *HTTPClientTCP::_create_func() { return memnew(HTTPClientTCP); } -Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) { +Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_tls, bool p_verify_host) { close(); conn_port = p_port; @@ -47,21 +47,21 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ss ip_candidates.clear(); - ssl = p_ssl; - ssl_verify_host = p_verify_host; + tls = p_tls; + tls_verify_host = p_verify_host; String host_lower = conn_host.to_lower(); if (host_lower.begins_with("http://")) { conn_host = conn_host.substr(7, conn_host.length() - 7); } else if (host_lower.begins_with("https://")) { - ssl = true; + tls = true; conn_host = conn_host.substr(8, conn_host.length() - 8); } ERR_FAIL_COND_V(conn_host.length() < HOST_MIN_LEN, ERR_INVALID_PARAMETER); if (conn_port < 0) { - if (ssl) { + if (tls) { conn_port = PORT_HTTPS; } else { conn_port = PORT_HTTP; @@ -70,11 +70,11 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ss connection = tcp_connection; - if (ssl && https_proxy_port != -1) { + if (tls && https_proxy_port != -1) { proxy_client.instantiate(); // Needs proxy negotiation. server_host = https_proxy_host; server_port = https_proxy_port; - } else if (!ssl && http_proxy_port != -1) { + } else if (!tls && http_proxy_port != -1) { server_host = http_proxy_host; server_port = http_proxy_port; } else { @@ -94,6 +94,10 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ss } else { // Host contains hostname and needs to be resolved to IP. resolving = IP::get_singleton()->resolve_hostname_queue_item(server_host); + if (resolving == IP::RESOLVER_INVALID_ID) { + status = STATUS_CANT_RESOLVE; + return ERR_CANT_RESOLVE; + } status = STATUS_RESOLVING; } @@ -103,9 +107,9 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ss void HTTPClientTCP::set_connection(const Ref<StreamPeer> &p_connection) { ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object."); - if (ssl) { - ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerSSL>(p_connection.ptr()), - "Connection is not a reference to a valid StreamPeerSSL object."); + if (tls) { + ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerTLS>(p_connection.ptr()), + "Connection is not a reference to a valid StreamPeerTLS object."); } if (connection == p_connection) { @@ -152,7 +156,7 @@ Error HTTPClientTCP::request(Method p_method, const String &p_url, const Vector< } String uri = p_url; - if (!ssl && http_proxy_port != -1) { + if (!tls && http_proxy_port != -1) { uri = vformat("http://%s:%d%s", conn_host, conn_port, p_url); } @@ -177,7 +181,7 @@ Error HTTPClientTCP::request(Method p_method, const String &p_url, const Vector< } } if (add_host) { - if ((ssl && conn_port == PORT_HTTPS) || (!ssl && conn_port == PORT_HTTP)) { + if ((tls && conn_port == PORT_HTTPS) || (!tls && conn_port == PORT_HTTP)) { // Don't append the standard ports. request += "Host: " + conn_host + "\r\n"; } else { @@ -312,7 +316,7 @@ Error HTTPClientTCP::poll() { return OK; } break; case StreamPeerTCP::STATUS_CONNECTED: { - if (ssl && proxy_client.is_valid()) { + if (tls && proxy_client.is_valid()) { Error err = proxy_client->poll(); if (err == ERR_UNCONFIGURED) { proxy_client->set_connection(tcp_connection); @@ -353,42 +357,42 @@ Error HTTPClientTCP::poll() { return ERR_CANT_CONNECT; } break; } - } else if (ssl) { - Ref<StreamPeerSSL> ssl; + } else if (tls) { + Ref<StreamPeerTLS> tls; if (!handshaking) { - // Connect the StreamPeerSSL and start handshaking. - ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create()); - ssl->set_blocking_handshake_enabled(false); - Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host); + // Connect the StreamPeerTLS and start handshaking. + tls = Ref<StreamPeerTLS>(StreamPeerTLS::create()); + tls->set_blocking_handshake_enabled(false); + Error err = tls->connect_to_stream(tcp_connection, tls_verify_host, conn_host); if (err != OK) { close(); - status = STATUS_SSL_HANDSHAKE_ERROR; + status = STATUS_TLS_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } - connection = ssl; + connection = tls; handshaking = true; } else { - // We are already handshaking, which means we can use your already active SSL connection. - ssl = static_cast<Ref<StreamPeerSSL>>(connection); - if (ssl.is_null()) { + // We are already handshaking, which means we can use your already active TLS connection. + tls = static_cast<Ref<StreamPeerTLS>>(connection); + if (tls.is_null()) { close(); - status = STATUS_SSL_HANDSHAKE_ERROR; + status = STATUS_TLS_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } - ssl->poll(); // Try to finish the handshake. + tls->poll(); // Try to finish the handshake. } - if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) { + if (tls->get_status() == StreamPeerTLS::STATUS_CONNECTED) { // Handshake has been successful. handshaking = false; ip_candidates.clear(); status = STATUS_CONNECTED; return OK; - } else if (ssl->get_status() != StreamPeerSSL::STATUS_HANDSHAKING) { + } else if (tls->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) { // Handshake has failed. close(); - status = STATUS_SSL_HANDSHAKE_ERROR; + status = STATUS_TLS_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } // ... we will need to poll more for handshake to finish. @@ -417,10 +421,10 @@ Error HTTPClientTCP::poll() { case STATUS_BODY: case STATUS_CONNECTED: { // Check if we are still connected. - if (ssl) { - Ref<StreamPeerSSL> tmp = connection; + if (tls) { + Ref<StreamPeerTLS> tmp = connection; tmp->poll(); - if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) { + if (tmp->get_status() != StreamPeerTLS::STATUS_CONNECTED) { status = STATUS_CONNECTION_ERROR; return ERR_CONNECTION_ERROR; } @@ -544,7 +548,7 @@ Error HTTPClientTCP::poll() { return ERR_UNCONFIGURED; } break; case STATUS_CONNECTION_ERROR: - case STATUS_SSL_HANDSHAKE_ERROR: { + case STATUS_TLS_HANDSHAKE_ERROR: { return ERR_CONNECTION_ERROR; } break; case STATUS_CANT_CONNECT: { diff --git a/core/io/http_client_tcp.h b/core/io/http_client_tcp.h index c10e0b1eca..744c15f7ab 100644 --- a/core/io/http_client_tcp.h +++ b/core/io/http_client_tcp.h @@ -46,8 +46,8 @@ private: String http_proxy_host; int https_proxy_port = -1; // Proxy server for https requests. String https_proxy_host; - bool ssl = false; - bool ssl_verify_host = false; + bool tls = false; + bool tls_verify_host = false; bool blocking = false; bool handshaking = false; bool head_request = false; @@ -79,7 +79,7 @@ public: Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_size) override; - Error connect_to_host(const String &p_host, int p_port = -1, bool p_ssl = false, bool p_verify_host = true) override; + Error connect_to_host(const String &p_host, int p_port = -1, bool p_tls = false, bool p_verify_host = true) override; void set_connection(const Ref<StreamPeer> &p_connection) override; Ref<StreamPeer> get_connection() const override; void close() override; diff --git a/core/io/image.cpp b/core/io/image.cpp index dee751eec5..812bfa8263 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2671,7 +2671,7 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2i &p_src_rect, const P Rect2i src_rect; Rect2i dest_rect; _get_clipped_src_and_dest_rects(p_src, p_src_rect, p_dest, src_rect, dest_rect); - if (src_rect.has_no_area() || dest_rect.has_no_area()) { + if (!src_rect.has_area() || !dest_rect.has_area()) { return; } @@ -2717,7 +2717,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co Rect2i src_rect; Rect2i dest_rect; _get_clipped_src_and_dest_rects(p_src, p_src_rect, p_dest, src_rect, dest_rect); - if (src_rect.has_no_area() || dest_rect.has_no_area()) { + if (!src_rect.has_area() || !dest_rect.has_area()) { return; } @@ -2762,7 +2762,7 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2i &p_src_rect, const Rect2i src_rect; Rect2i dest_rect; _get_clipped_src_and_dest_rects(p_src, p_src_rect, p_dest, src_rect, dest_rect); - if (src_rect.has_no_area() || dest_rect.has_no_area()) { + if (!src_rect.has_area() || !dest_rect.has_area()) { return; } @@ -2802,7 +2802,7 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c Rect2i src_rect; Rect2i dest_rect; _get_clipped_src_and_dest_rects(p_src, p_src_rect, p_dest, src_rect, dest_rect); - if (src_rect.has_no_area() || dest_rect.has_no_area()) { + if (!src_rect.has_area() || !dest_rect.has_area()) { return; } @@ -2862,7 +2862,7 @@ void Image::fill_rect(const Rect2i &p_rect, const Color &p_color) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill rect in compressed or custom image formats."); Rect2i r = Rect2i(0, 0, width, height).intersection(p_rect.abs()); - if (r.has_no_area()) { + if (!r.has_area()) { return; } diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_tls.cpp index 5b90fb52a6..b1adde018a 100644 --- a/core/io/stream_peer_ssl.cpp +++ b/core/io/stream_peer_tls.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* stream_peer_ssl.cpp */ +/* stream_peer_tls.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,42 +28,42 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "stream_peer_ssl.h" +#include "stream_peer_tls.h" #include "core/config/engine.h" -StreamPeerSSL *(*StreamPeerSSL::_create)() = nullptr; +StreamPeerTLS *(*StreamPeerTLS::_create)() = nullptr; -StreamPeerSSL *StreamPeerSSL::create() { +StreamPeerTLS *StreamPeerTLS::create() { if (_create) { return _create(); } return nullptr; } -bool StreamPeerSSL::available = false; +bool StreamPeerTLS::available = false; -bool StreamPeerSSL::is_available() { +bool StreamPeerTLS::is_available() { return available; } -void StreamPeerSSL::set_blocking_handshake_enabled(bool p_enabled) { +void StreamPeerTLS::set_blocking_handshake_enabled(bool p_enabled) { blocking_handshake = p_enabled; } -bool StreamPeerSSL::is_blocking_handshake_enabled() const { +bool StreamPeerTLS::is_blocking_handshake_enabled() const { return blocking_handshake; } -void StreamPeerSSL::_bind_methods() { - ClassDB::bind_method(D_METHOD("poll"), &StreamPeerSSL::poll); - ClassDB::bind_method(D_METHOD("accept_stream", "stream", "private_key", "certificate", "chain"), &StreamPeerSSL::accept_stream, DEFVAL(Ref<X509Certificate>())); - ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname", "valid_certificate"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()), DEFVAL(Ref<X509Certificate>())); - ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerSSL::get_status); - ClassDB::bind_method(D_METHOD("get_stream"), &StreamPeerSSL::get_stream); - ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerSSL::disconnect_from_stream); - ClassDB::bind_method(D_METHOD("set_blocking_handshake_enabled", "enabled"), &StreamPeerSSL::set_blocking_handshake_enabled); - ClassDB::bind_method(D_METHOD("is_blocking_handshake_enabled"), &StreamPeerSSL::is_blocking_handshake_enabled); +void StreamPeerTLS::_bind_methods() { + ClassDB::bind_method(D_METHOD("poll"), &StreamPeerTLS::poll); + ClassDB::bind_method(D_METHOD("accept_stream", "stream", "private_key", "certificate", "chain"), &StreamPeerTLS::accept_stream, DEFVAL(Ref<X509Certificate>())); + ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname", "valid_certificate"), &StreamPeerTLS::connect_to_stream, DEFVAL(false), DEFVAL(String()), DEFVAL(Ref<X509Certificate>())); + ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerTLS::get_status); + ClassDB::bind_method(D_METHOD("get_stream"), &StreamPeerTLS::get_stream); + ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerTLS::disconnect_from_stream); + ClassDB::bind_method(D_METHOD("set_blocking_handshake_enabled", "enabled"), &StreamPeerTLS::set_blocking_handshake_enabled); + ClassDB::bind_method(D_METHOD("is_blocking_handshake_enabled"), &StreamPeerTLS::is_blocking_handshake_enabled); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_handshake"), "set_blocking_handshake_enabled", "is_blocking_handshake_enabled"); diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_tls.h index fe68667adc..ed7334fab3 100644 --- a/core/io/stream_peer_ssl.h +++ b/core/io/stream_peer_tls.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* stream_peer_ssl.h */ +/* stream_peer_tls.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,17 +28,17 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef STREAM_PEER_SSL_H -#define STREAM_PEER_SSL_H +#ifndef STREAM_PEER_TLS_H +#define STREAM_PEER_TLS_H #include "core/crypto/crypto.h" #include "core/io/stream_peer.h" -class StreamPeerSSL : public StreamPeer { - GDCLASS(StreamPeerSSL, StreamPeer); +class StreamPeerTLS : public StreamPeer { + GDCLASS(StreamPeerTLS, StreamPeer); protected: - static StreamPeerSSL *(*_create)(); + static StreamPeerTLS *(*_create)(); static void _bind_methods(); static bool available; @@ -65,13 +65,13 @@ public: virtual void disconnect_from_stream() = 0; - static StreamPeerSSL *create(); + static StreamPeerTLS *create(); static bool is_available(); - StreamPeerSSL() {} + StreamPeerTLS() {} }; -VARIANT_ENUM_CAST(StreamPeerSSL::Status); +VARIANT_ENUM_CAST(StreamPeerTLS::Status); -#endif // STREAM_PEER_SSL_H +#endif // STREAM_PEER_TLS_H diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 154b55f5e7..abae48fdd8 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -137,7 +137,7 @@ bool XMLParser::_parse_cdata() { next_char(); } - if (cDataEnd) { + if (!cDataEnd) { cDataEnd = P; } node_name = String::utf8(cDataBegin, (int)(cDataEnd - cDataBegin)); |