Skip to content

Commit

Permalink
Merge branch 'godotengine:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GNSS-Stylist authored Dec 6, 2021
2 parents fed96c4 + 608c9f8 commit 5f9e2fc
Show file tree
Hide file tree
Showing 78 changed files with 362 additions and 194 deletions.
1 change: 1 addition & 0 deletions core/doc_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class DocData {
String setter, getter;
String default_value;
bool overridden = false;
String overrides;
bool operator<(const PropertyDoc &p_prop) const {
return name < p_prop.name;
}
Expand Down
11 changes: 11 additions & 0 deletions core/io/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ HTTPClient *HTTPClient::create() {
return nullptr;
}

void HTTPClient::set_http_proxy(const String &p_host, int p_port) {
WARN_PRINT("HTTP proxy feature is not available");
}

void HTTPClient::set_https_proxy(const String &p_host, int p_port) {
WARN_PRINT("HTTPS proxy feature is not available");
}

Error HTTPClient::_request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
int size = p_body.size();
return request(p_method, p_url, p_headers, size > 0 ? p_body.ptr() : nullptr, size);
Expand Down Expand Up @@ -142,6 +150,9 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_status"), &HTTPClient::get_status);
ClassDB::bind_method(D_METHOD("poll"), &HTTPClient::poll);

ClassDB::bind_method(D_METHOD("set_http_proxy", "host", "port"), &HTTPClient::set_http_proxy);
ClassDB::bind_method(D_METHOD("set_https_proxy", "host", "port"), &HTTPClient::set_https_proxy);

ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled");
Expand Down
4 changes: 4 additions & 0 deletions core/io/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class HTTPClient : public RefCounted {

virtual Error poll() = 0;

// Use empty string or -1 to unset
virtual void set_http_proxy(const String &p_host, int p_port);
virtual void set_https_proxy(const String &p_host, int p_port);

HTTPClient() {}
virtual ~HTTPClient() {}
};
Expand Down
93 changes: 86 additions & 7 deletions core/io/http_client_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,21 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ss

connection = tcp_connection;

if (conn_host.is_valid_ip_address()) {
if (ssl && 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) {
server_host = http_proxy_host;
server_port = http_proxy_port;
} else {
server_host = conn_host;
server_port = conn_port;
}

if (server_host.is_valid_ip_address()) {
// Host contains valid IP
Error err = tcp_connection->connect_to_host(IPAddress(conn_host), p_port);
Error err = tcp_connection->connect_to_host(IPAddress(server_host), server_port);
if (err) {
status = STATUS_CANT_CONNECT;
return err;
Expand All @@ -81,7 +93,7 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, bool p_ss
status = STATUS_CONNECTING;
} else {
// Host contains hostname and needs to be resolved to IP
resolving = IP::get_singleton()->resolve_hostname_queue_item(conn_host);
resolving = IP::get_singleton()->resolve_hostname_queue_item(server_host);
status = STATUS_RESOLVING;
}

Expand Down Expand Up @@ -134,7 +146,12 @@ Error HTTPClientTCP::request(Method p_method, const String &p_url, const Vector<
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(connection.is_null(), ERR_INVALID_DATA);

String request = String(_methods[p_method]) + " " + p_url + " HTTP/1.1\r\n";
String uri = p_url;
if (!ssl && http_proxy_port != -1) {
uri = vformat("http://%s:%d%s", conn_host, conn_port, p_url);
}

String request = String(_methods[p_method]) + " " + uri + " HTTP/1.1\r\n";
bool add_host = true;
bool add_clen = p_body_size > 0;
bool add_uagent = true;
Expand Down Expand Up @@ -229,6 +246,7 @@ void HTTPClientTCP::close() {
}

connection.unref();
proxy_client.unref();
status = STATUS_DISCONNECTED;
head_request = false;
if (resolving != IP::RESOLVER_INVALID_ID) {
Expand Down Expand Up @@ -265,7 +283,7 @@ Error HTTPClientTCP::poll() {

Error err = ERR_BUG; // Should be at least one entry.
while (ip_candidates.size() > 0) {
err = tcp_connection->connect_to_host(ip_candidates.front(), conn_port);
err = tcp_connection->connect_to_host(ip_candidates.pop_front(), server_port);
if (err == OK) {
break;
}
Expand Down Expand Up @@ -294,7 +312,48 @@ Error HTTPClientTCP::poll() {
return OK;
} break;
case StreamPeerTCP::STATUS_CONNECTED: {
if (ssl) {
if (ssl && proxy_client.is_valid()) {
Error err = proxy_client->poll();
if (err == ERR_UNCONFIGURED) {
proxy_client->set_connection(tcp_connection);
const Vector<String> headers;
err = proxy_client->request(METHOD_CONNECT, vformat("%s:%d", conn_host, conn_port), headers, nullptr, 0);
if (err != OK) {
status = STATUS_CANT_CONNECT;
return err;
}
} else if (err != OK) {
status = STATUS_CANT_CONNECT;
return err;
}
switch (proxy_client->get_status()) {
case STATUS_REQUESTING: {
return OK;
} break;
case STATUS_BODY: {
proxy_client->read_response_body_chunk();
return OK;
} break;
case STATUS_CONNECTED: {
if (proxy_client->get_response_code() != RESPONSE_OK) {
status = STATUS_CANT_CONNECT;
return ERR_CANT_CONNECT;
}
proxy_client.unref();
return OK;
}
case STATUS_DISCONNECTED:
case STATUS_RESOLVING:
case STATUS_CONNECTING: {
status = STATUS_CANT_CONNECT;
ERR_FAIL_V(ERR_BUG);
} break;
default: {
status = STATUS_CANT_CONNECT;
return ERR_CANT_CONNECT;
} break;
}
} else if (ssl) {
Ref<StreamPeerSSL> ssl;
if (!handshaking) {
// Connect the StreamPeerSSL and start handshaking
Expand Down Expand Up @@ -344,7 +403,7 @@ Error HTTPClientTCP::poll() {
Error err = ERR_CANT_CONNECT;
while (ip_candidates.size() > 0) {
tcp_connection->disconnect_from_host();
err = tcp_connection->connect_to_host(ip_candidates.pop_front(), conn_port);
err = tcp_connection->connect_to_host(ip_candidates.pop_front(), server_port);
if (err == OK) {
return OK;
}
Expand Down Expand Up @@ -678,6 +737,26 @@ int HTTPClientTCP::get_read_chunk_size() const {
return read_chunk_size;
}

void HTTPClientTCP::set_http_proxy(const String &p_host, int p_port) {
if (p_host.is_empty() || p_port == -1) {
http_proxy_host = "";
http_proxy_port = -1;
} else {
http_proxy_host = p_host;
http_proxy_port = p_port;
}
}

void HTTPClientTCP::set_https_proxy(const String &p_host, int p_port) {
if (p_host.is_empty() || p_port == -1) {
https_proxy_host = "";
https_proxy_port = -1;
} else {
https_proxy_host = p_host;
https_proxy_port = p_port;
}
}

HTTPClientTCP::HTTPClientTCP() {
tcp_connection.instantiate();
}
Expand Down
11 changes: 10 additions & 1 deletion core/io/http_client_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ class HTTPClientTCP : public HTTPClient {
Status status = STATUS_DISCONNECTED;
IP::ResolverID resolving = IP::RESOLVER_INVALID_ID;
Array ip_candidates;
int conn_port = -1;
int conn_port = -1; // Server to make requests to
String conn_host;
int server_port = -1; // Server to connect to (might be a proxy server)
String server_host;
int http_proxy_port = -1; // Proxy server for http requests
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 blocking = false;
Expand All @@ -58,6 +64,7 @@ class HTTPClientTCP : public HTTPClient {

Ref<StreamPeerTCP> tcp_connection;
Ref<StreamPeer> connection;
Ref<HTTPClientTCP> proxy_client; // Negotiate with proxy server

int response_num = 0;
Vector<String> response_headers;
Expand Down Expand Up @@ -87,6 +94,8 @@ class HTTPClientTCP : public HTTPClient {
void set_read_chunk_size(int p_size) override;
int get_read_chunk_size() const override;
Error poll() override;
void set_http_proxy(const String &p_host, int p_port) override;
void set_https_proxy(const String &p_host, int p_port) override;
HTTPClientTCP();
};

Expand Down
10 changes: 5 additions & 5 deletions doc/classes/AcceptDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
<member name="dialog_text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
The text displayed by the dialog.
</member>
<member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" override="true" default="true" />
<member name="title" type="String" setter="set_title" getter="get_title" override="true" default="&quot;Alert!&quot;" />
<member name="transient" type="bool" setter="set_transient" getter="is_transient" override="true" default="true" />
<member name="visible" type="bool" setter="set_visible" getter="is_visible" override="true" default="false" />
<member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" override="true" default="true" />
<member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" overrides="Window" default="true" />
<member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Alert!&quot;" />
<member name="transient" type="bool" setter="set_transient" getter="is_transient" overrides="Window" default="true" />
<member name="visible" type="bool" setter="set_visible" getter="is_visible" overrides="Window" default="false" />
<member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" overrides="Window" default="true" />
</members>
<signals>
<signal name="cancelled">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/AnimationNodeStateMachinePlayback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
</method>
</methods>
<members>
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" />
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="true" />
</members>
</class>
2 changes: 1 addition & 1 deletion doc/classes/BaseButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false">
If [code]true[/code], the button is in disabled state and can't be clicked or toggled.
</member>
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" />
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
<member name="keep_pressed_outside" type="bool" setter="set_keep_pressed_outside" getter="is_keep_pressed_outside" default="false">
If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it.
[b]Note:[/b] This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/ButtonGroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</method>
</methods>
<members>
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" />
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="true" />
</members>
<signals>
<signal name="pressed">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/CheckBox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<tutorials>
</tutorials>
<members>
<member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" />
<member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" />
<member name="align" type="int" setter="set_text_align" getter="get_text_align" overrides="Button" enum="Button.TextAlign" default="0" />
<member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" />
</members>
<theme_items>
<theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/CheckButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<tutorials>
</tutorials>
<members>
<member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" />
<member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" />
<member name="align" type="int" setter="set_text_align" getter="get_text_align" overrides="Button" enum="Button.TextAlign" default="0" />
<member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" />
</members>
<theme_items>
<theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/CodeEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
<member name="indent_use_spaces" type="bool" setter="set_indent_using_spaces" getter="is_indent_using_spaces" default="false">
Use spaces instead of tabs for indentation.
</member>
<member name="layout_direction" type="int" setter="set_layout_direction" getter="get_layout_direction" override="true" enum="Control.LayoutDirection" default="2" />
<member name="layout_direction" type="int" setter="set_layout_direction" getter="get_layout_direction" overrides="Control" enum="Control.LayoutDirection" default="2" />
<member name="line_folding" type="bool" setter="set_line_folding_enabled" getter="is_line_folding_enabled" default="false">
Sets whether line folding is allowed.
</member>
Expand All @@ -497,7 +497,7 @@
<member name="symbol_lookup_on_click" type="bool" setter="set_symbol_lookup_on_click_enabled" getter="is_symbol_lookup_on_click_enabled" default="false">
Set when a validated word from [signal symbol_validate] is clicked, the [signal symbol_lookup] should be emitted.
</member>
<member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" override="true" enum="Control.TextDirection" default="1" />
<member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" overrides="TextEdit" enum="Control.TextDirection" default="1" />
</members>
<signals>
<signal name="breakpoint_toggled">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/ColorPickerButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha" default="true">
If [code]true[/code], the alpha channel in the displayed [ColorPicker] will be visible.
</member>
<member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" />
<member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" />
</members>
<signals>
<signal name="color_changed">
Expand Down
6 changes: 3 additions & 3 deletions doc/classes/ConfirmationDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</method>
</methods>
<members>
<member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i(200, 70)" />
<member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i(200, 100)" />
<member name="title" type="String" setter="set_title" getter="get_title" override="true" default="&quot;Please Confirm...&quot;" />
<member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" overrides="Window" default="Vector2i(200, 70)" />
<member name="size" type="Vector2i" setter="set_size" getter="get_size" overrides="Window" default="Vector2i(200, 100)" />
<member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Please Confirm...&quot;" />
</members>
</class>
2 changes: 1 addition & 1 deletion doc/classes/Container.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</method>
</methods>
<members>
<member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" />
<member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="1" />
</members>
<signals>
<signal name="pre_sort_children">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/DirectionalLight3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<member name="directional_shadow_split_3" type="float" setter="set_param" getter="get_param" default="0.5">
The distance from shadow split 2 to split 3. Relative to [member directional_shadow_max_distance]. Only used when [member directional_shadow_mode] is [constant SHADOW_PARALLEL_4_SPLITS].
</member>
<member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.1" />
<member name="shadow_bias" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="0.1" />
<member name="use_in_sky_only" type="bool" setter="set_sky_only" getter="is_sky_only" default="false">
If [code]true[/code], this [DirectionalLight3D] will not be used for anything except sky shaders. Use this for lights that impact your sky shader that you may want to hide from affecting the rest of the scene. For example, you may want to enable this when the sun in your sky shader falls below the horizon.
</member>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorCommandPalette.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
</method>
</methods>
<members>
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" />
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" />
</members>
</class>
4 changes: 2 additions & 2 deletions doc/classes/EditorFileDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<member name="current_path" type="String" setter="set_current_path" getter="get_current_path" default="&quot;res://&quot;">
The file system path in the address bar.
</member>
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" />
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" />
<member name="disable_overwrite_warning" type="bool" setter="set_disable_overwrite_warning" getter="is_overwrite_warning_disabled" default="false">
If [code]true[/code], the [EditorFileDialog] will not warn the user before overwriting files.
</member>
Expand All @@ -62,7 +62,7 @@
<member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false">
If [code]true[/code], hidden files and directories will be visible in the [EditorFileDialog].
</member>
<member name="title" type="String" setter="set_title" getter="get_title" override="true" default="&quot;Save a File&quot;" />
<member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Save a File&quot;" />
</members>
<signals>
<signal name="dir_selected">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorInspector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<tutorials>
</tutorials>
<members>
<member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" override="true" default="false" />
<member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" overrides="ScrollContainer" default="false" />
</members>
<signals>
<signal name="object_id_selected">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorSpinSlider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<members>
<member name="flat" type="bool" setter="set_flat" getter="is_flat" default="false">
</member>
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" />
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
<member name="label" type="String" setter="set_label" getter="get_label" default="&quot;&quot;">
</member>
<member name="read_only" type="bool" setter="set_read_only" getter="is_read_only" default="false">
Expand Down
Loading

0 comments on commit 5f9e2fc

Please sign in to comment.