aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli2017-01-18 12:47:12 +0100
committerFabio Alessandrelli2017-03-22 21:00:23 +0100
commitd9525082feb6165944082fb80ae7785b23a2250c (patch)
tree1191470efc7ecc96499a3eecbcfded56ebe670d8
parent0b9684a085f244210f166070a9589bdd70876196 (diff)
downloadgodot-d9525082feb6165944082fb80ae7785b23a2250c.tar.gz
godot-d9525082feb6165944082fb80ae7785b23a2250c.tar.zst
godot-d9525082feb6165944082fb80ae7785b23a2250c.zip
-rw-r--r--core/io/http_client.cpp9
-rw-r--r--core/io/http_client.h2
-rw-r--r--core/io/packet_peer_udp.cpp9
-rw-r--r--core/io/packet_peer_udp.h3
-rw-r--r--core/io/stream_peer_tcp.cpp10
-rw-r--r--core/io/stream_peer_tcp.h1
-rw-r--r--core/io/tcp_server.cpp7
-rw-r--r--core/io/tcp_server.h3
-rw-r--r--drivers/unix/packet_peer_udp_posix.cpp3
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp6
-rw-r--r--drivers/unix/stream_peer_tcp_posix.h2
-rw-r--r--drivers/unix/tcp_server_posix.cpp3
-rw-r--r--platform/windows/packet_peer_udp_winsock.cpp3
-rw-r--r--platform/windows/stream_peer_winsock.cpp6
-rw-r--r--platform/windows/stream_peer_winsock.h2
-rw-r--r--platform/windows/tcp_server_winsock.cpp3
-rw-r--r--scene/main/http_request.cpp5
-rw-r--r--scene/main/http_request.h1
18 files changed, 13 insertions, 65 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index adc95e962..dc541a513 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -29,14 +29,9 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
-void HTTPClient::set_ip_type(IP::Type p_type) {
- ip_type = p_type;
-}
-
Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
close();
- tcp_connection->set_ip_type(ip_type);
conn_port = p_port;
conn_host = p_host;
@@ -63,7 +58,7 @@ Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl, bool p_v
status = STATUS_CONNECTING;
} else {
//is hostname
- resolving = IP::get_singleton()->resolve_hostname_queue_item(conn_host, ip_type);
+ resolving = IP::get_singleton()->resolve_hostname_queue_item(conn_host);
status = STATUS_RESOLVING;
}
@@ -618,7 +613,6 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
void HTTPClient::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_ip_type", "ip_type"), &HTTPClient::set_ip_type);
ObjectTypeDB::bind_method(_MD("connect:Error", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect, DEFVAL(false), DEFVAL(true));
ObjectTypeDB::bind_method(_MD("set_connection", "connection:StreamPeer"), &HTTPClient::set_connection);
ObjectTypeDB::bind_method(_MD("get_connection:StreamPeer"), &HTTPClient::get_connection);
@@ -742,7 +736,6 @@ String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
HTTPClient::HTTPClient() {
- ip_type = IP::TYPE_ANY;
tcp_connection = StreamPeerTCP::create_ref();
resolving = IP::RESOLVER_INVALID_ID;
status = STATUS_DISCONNECTED;
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 43d6dc721..ac2bd7417 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -130,7 +130,6 @@ public:
};
private:
- IP::Type ip_type;
Status status;
IP::ResolverID resolving;
int conn_port;
@@ -161,7 +160,6 @@ private:
Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
public:
- void set_ip_type(IP::Type p_type);
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
Error connect(const String &p_host, int p_port, bool p_ssl = false, bool p_verify_host = true);
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 0c008b6dc..067c1c1bd 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -42,7 +42,7 @@ Error PacketPeerUDP::_set_send_address(const String &p_address, int p_port) {
if (p_address.is_valid_ip_address()) {
ip = p_address;
} else {
- ip = IP::get_singleton()->resolve_hostname(p_address, ip_type);
+ ip = IP::get_singleton()->resolve_hostname(p_address);
if (!ip.is_valid())
return ERR_CANT_RESOLVE;
}
@@ -51,14 +51,8 @@ Error PacketPeerUDP::_set_send_address(const String &p_address, int p_port) {
return OK;
}
-void PacketPeerUDP::set_ip_type(IP::Type p_type) {
- close();
- ip_type = p_type;
-}
-
void PacketPeerUDP::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_ip_type", "ip_type"), &PacketPeerUDP::set_ip_type);
ObjectTypeDB::bind_method(_MD("listen:Error", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
ObjectTypeDB::bind_method(_MD("close"), &PacketPeerUDP::close);
ObjectTypeDB::bind_method(_MD("wait:Error"), &PacketPeerUDP::wait);
@@ -84,5 +78,4 @@ PacketPeerUDP *PacketPeerUDP::create() {
}
PacketPeerUDP::PacketPeerUDP() {
- ip_type = IP::TYPE_ANY;
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index e20863045..8fcbc9472 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -36,8 +36,6 @@ class PacketPeerUDP : public PacketPeer {
OBJ_TYPE(PacketPeerUDP, PacketPeer);
protected:
- IP::Type ip_type;
-
static PacketPeerUDP *(*_create)();
static void _bind_methods();
@@ -46,7 +44,6 @@ protected:
Error _set_send_address(const String &p_address, int p_port);
public:
- virtual void set_ip_type(IP::Type p_type);
virtual Error listen(int p_port, IP_Address p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536) = 0;
virtual void close() = 0;
virtual Error wait() = 0;
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index f303d8fd1..032f58a4c 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -36,7 +36,7 @@ Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
if (p_address.is_valid_ip_address()) {
ip = p_address;
} else {
- ip = IP::get_singleton()->resolve_hostname(p_address, ip_type);
+ ip = IP::get_singleton()->resolve_hostname(p_address);
if (!ip.is_valid())
return ERR_CANT_RESOLVE;
}
@@ -45,14 +45,8 @@ Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
return OK;
}
-void StreamPeerTCP::set_ip_type(IP::Type p_type) {
- disconnect();
- ip_type = p_type;
-}
-
void StreamPeerTCP::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_ip_type", "ip_type"), &StreamPeerTCP::set_ip_type);
ObjectTypeDB::bind_method(_MD("connect", "host", "port"), &StreamPeerTCP::_connect);
ObjectTypeDB::bind_method(_MD("is_connected"), &StreamPeerTCP::is_connected);
ObjectTypeDB::bind_method(_MD("get_status"), &StreamPeerTCP::get_status);
@@ -81,8 +75,6 @@ StreamPeerTCP *StreamPeerTCP::create() {
}
StreamPeerTCP::StreamPeerTCP() {
-
- ip_type = IP::TYPE_ANY;
}
StreamPeerTCP::~StreamPeerTCP(){
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index a97f42937..36ed9d1d7 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -56,7 +56,6 @@ protected:
static void _bind_methods();
public:
- virtual void set_ip_type(IP::Type p_type);
virtual Error connect(const IP_Address &p_host, uint16_t p_port) = 0;
//read/write from streampeer
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 393dd363a..4514a0289 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -44,14 +44,8 @@ TCP_Server *TCP_Server::create() {
return _create();
}
-void TCP_Server::set_ip_type(IP::Type p_type) {
- stop();
- ip_type = p_type;
-}
-
void TCP_Server::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_ip_type", "ip_type"), &TCP_Server::set_ip_type);
ObjectTypeDB::bind_method(_MD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ObjectTypeDB::bind_method(_MD("is_connection_available"), &TCP_Server::is_connection_available);
ObjectTypeDB::bind_method(_MD("take_connection"), &TCP_Server::take_connection);
@@ -59,5 +53,4 @@ void TCP_Server::_bind_methods() {
}
TCP_Server::TCP_Server() {
- ip_type = IP::TYPE_ANY;
}
diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h
index 671b03308..13cc590ed 100644
--- a/core/io/tcp_server.h
+++ b/core/io/tcp_server.h
@@ -38,15 +38,12 @@ class TCP_Server : public Reference {
OBJ_TYPE(TCP_Server, Reference);
protected:
- IP::Type ip_type;
-
static TCP_Server *(*_create)();
//bind helper
static void _bind_methods();
public:
- virtual void set_ip_type(IP::Type p_type);
virtual Error listen(uint16_t p_port, const IP_Address p_bind_address = IP_Address("*")) = 0;
virtual bool is_connection_available() const = 0;
virtual Ref<StreamPeerTCP> take_connection() = 0;
diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp
index ea900062f..bfbbf6cce 100644
--- a/drivers/unix/packet_peer_udp_posix.cpp
+++ b/drivers/unix/packet_peer_udp_posix.cpp
@@ -127,7 +127,7 @@ Error PacketPeerUDPPosix::listen(int p_port, IP_Address p_bind_address, int p_re
ERR_FAIL_COND_V(sockfd != -1, ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
- sock_type = ip_type;
+ sock_type = IP::TYPE_ANY;
if (p_bind_address.is_valid())
sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
@@ -265,7 +265,6 @@ PacketPeerUDPPosix::PacketPeerUDPPosix() {
queue_count = 0;
peer_port = 0;
sock_type = IP::TYPE_NONE;
- ip_type = IP::TYPE_ANY;
}
PacketPeerUDPPosix::~PacketPeerUDPPosix() {
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index 779d9e427..9f551a8f4 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -122,10 +122,9 @@ Error StreamPeerTCPPosix::_poll_connection(bool p_block) const {
return OK;
};
-void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type) {
+void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type) {
- ip_type = p_ip_type;
- sock_type = p_ip_type;
+ sock_type = p_sock_type;
sockfd = p_sockfd;
#ifndef NO_FCNTL
fcntl(sockfd, F_SETFL, O_NONBLOCK);
@@ -395,7 +394,6 @@ StreamPeerTCPPosix::StreamPeerTCPPosix() {
sockfd = -1;
status = STATUS_NONE;
peer_port = 0;
- ip_type = IP::TYPE_ANY;
};
StreamPeerTCPPosix::~StreamPeerTCPPosix() {
diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h
index c0ce62a7d..cd50d4167 100644
--- a/drivers/unix/stream_peer_tcp_posix.h
+++ b/drivers/unix/stream_peer_tcp_posix.h
@@ -66,7 +66,7 @@ public:
virtual int get_available_bytes() const;
- void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type);
+ void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type);
virtual IP_Address get_connected_host() const;
virtual uint16_t get_connected_port() const;
diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp
index 79ebf1873..6aec5ad31 100644
--- a/drivers/unix/tcp_server_posix.cpp
+++ b/drivers/unix/tcp_server_posix.cpp
@@ -74,7 +74,7 @@ Error TCPServerPosix::listen(uint16_t p_port, const IP_Address p_bind_address) {
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
int sockfd;
- sock_type = ip_type;
+ sock_type = IP::TYPE_ANY;
// If the bind address is valid use its type as the socket type
if (p_bind_address.is_valid())
@@ -182,7 +182,6 @@ void TCPServerPosix::stop() {
TCPServerPosix::TCPServerPosix() {
listen_sockfd = -1;
- ip_type = IP::TYPE_ANY;
sock_type = IP::TYPE_NONE;
};
diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp
index 4ee94c264..e326a5a6f 100644
--- a/platform/windows/packet_peer_udp_winsock.cpp
+++ b/platform/windows/packet_peer_udp_winsock.cpp
@@ -122,7 +122,7 @@ Error PacketPeerUDPWinsock::listen(int p_port, IP_Address p_bind_address, int p_
ERR_FAIL_COND_V(sockfd != -1, ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
- sock_type = ip_type;
+ sock_type = IP::TYPE_ANY;
if (p_bind_address.is_valid())
sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
@@ -277,7 +277,6 @@ PacketPeerUDPWinsock::PacketPeerUDPWinsock() {
packet_port = 0;
queue_count = 0;
peer_port = 0;
- ip_type = IP::TYPE_ANY;
sock_type = IP::TYPE_NONE;
}
diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp
index 6723a6d0f..de79941e2 100644
--- a/platform/windows/stream_peer_winsock.cpp
+++ b/platform/windows/stream_peer_winsock.cpp
@@ -285,11 +285,10 @@ void StreamPeerWinsock::disconnect() {
peer_port = 0;
};
-void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type) {
+void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type) {
- ip_type = p_ip_type;
sockfd = p_sockfd;
- sock_type = p_ip_type;
+ sock_type = p_sock_type;
status = STATUS_CONNECTING;
peer_host = p_host;
peer_port = p_port;
@@ -366,7 +365,6 @@ StreamPeerWinsock::StreamPeerWinsock() {
sockfd = INVALID_SOCKET;
status = STATUS_NONE;
peer_port = 0;
- ip_type = IP::TYPE_ANY;
};
StreamPeerWinsock::~StreamPeerWinsock() {
diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h
index 7bea3c564..db27001c6 100644
--- a/platform/windows/stream_peer_winsock.h
+++ b/platform/windows/stream_peer_winsock.h
@@ -67,7 +67,7 @@ public:
virtual int get_available_bytes() const;
- void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type);
+ void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type);
virtual IP_Address get_connected_host() const;
virtual uint16_t get_connected_port() const;
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
index 0f117bc6b..67713f5d1 100644
--- a/platform/windows/tcp_server_winsock.cpp
+++ b/platform/windows/tcp_server_winsock.cpp
@@ -68,7 +68,7 @@ Error TCPServerWinsock::listen(uint16_t p_port, const IP_Address p_bind_address)
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
int sockfd;
- sock_type = ip_type;
+ sock_type = IP::TYPE_ANY;
// If the bind address is valid use its type as the socket type
if (p_bind_address.is_valid())
@@ -173,7 +173,6 @@ void TCPServerWinsock::stop() {
TCPServerWinsock::TCPServerWinsock() {
listen_sockfd = INVALID_SOCKET;
- ip_type = IP::TYPE_ANY;
sock_type = IP::TYPE_NONE;
};
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index d977548d6..97832521c 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -28,10 +28,6 @@
/*************************************************************************/
#include "http_request.h"
-void HTTPRequest::set_ip_type(IP::Type p_type) {
- client->set_ip_type(p_type);
-}
-
void HTTPRequest::_redirect_request(const String &p_new_url) {
}
@@ -519,7 +515,6 @@ int HTTPRequest::get_body_size() const {
void HTTPRequest::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_ip_type", "ip_type"), &HTTPRequest::set_ip_type);
ObjectTypeDB::bind_method(_MD("request", "url", "custom_headers", "ssl_validate_domain", "method", "request_data"), &HTTPRequest::request, DEFVAL(StringArray()), DEFVAL(true), DEFVAL(HTTPClient::METHOD_GET), DEFVAL(String()));
ObjectTypeDB::bind_method(_MD("cancel_request"), &HTTPRequest::cancel_request);
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 6a63fa66a..e7da0e1e3 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -113,7 +113,6 @@ protected:
static void _bind_methods();
public:
- void set_ip_type(IP::Type p_type);
Error request(const String &p_url, const Vector<String> &p_custom_headers = Vector<String>(), bool p_ssl_validate_domain = true, HTTPClient::Method p_method = HTTPClient::METHOD_GET, const String &p_request_data = ""); //connects to a full url and perform request
void cancel_request();
HTTPClient::Status get_http_client_status() const;