mirror of
https://github.com/godotengine/godot.git
synced 2024-11-15 00:23:27 +00:00
Merge pull request #37700 from Calinou/rename-ip-unix-tcp-server
Rename `IP_Unix`, `IP_Address` and `TCP_Server` to remove underscores
This commit is contained in:
commit
42b07f713f
@ -152,7 +152,7 @@ void RemoteDebuggerPeerTCP::_read_in() {
|
||||
}
|
||||
|
||||
Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_port) {
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
if (p_host.is_valid_ip_address()) {
|
||||
ip = p_host;
|
||||
} else {
|
||||
|
@ -171,7 +171,7 @@ void FileAccessNetworkClient::_thread_func(void *s) {
|
||||
}
|
||||
|
||||
Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const String &p_password) {
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
|
||||
if (p_host.is_valid_ip_address()) {
|
||||
ip = p_host;
|
||||
|
@ -77,7 +77,7 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
|
||||
|
||||
if (conn_host.is_valid_ip_address()) {
|
||||
// Host contains valid IP
|
||||
Error err = tcp_connection->connect_to_host(IP_Address(conn_host), p_port);
|
||||
Error err = tcp_connection->connect_to_host(IPAddress(conn_host), p_port);
|
||||
if (err) {
|
||||
status = STATUS_CANT_CONNECT;
|
||||
return err;
|
||||
@ -328,7 +328,7 @@ Error HTTPClient::poll() {
|
||||
return OK; // Still resolving
|
||||
|
||||
case IP::RESOLVER_STATUS_DONE: {
|
||||
IP_Address host = IP::get_singleton()->get_resolve_item_address(resolving);
|
||||
IPAddress host = IP::get_singleton()->get_resolve_item_address(resolving);
|
||||
Error err = tcp_connection->connect_to_host(host, conn_port);
|
||||
IP::get_singleton()->erase_resolve_item(resolving);
|
||||
resolving = IP::RESOLVER_INVALID_ID;
|
||||
|
@ -41,13 +41,13 @@ VARIANT_ENUM_CAST(IP::ResolverStatus);
|
||||
struct _IP_ResolverPrivate {
|
||||
struct QueueItem {
|
||||
SafeNumeric<IP::ResolverStatus> status;
|
||||
IP_Address response;
|
||||
IPAddress response;
|
||||
String hostname;
|
||||
IP::Type type;
|
||||
|
||||
void clear() {
|
||||
status.set(IP::RESOLVER_STATUS_NONE);
|
||||
response = IP_Address();
|
||||
response = IPAddress();
|
||||
type = IP::TYPE_NONE;
|
||||
hostname = "";
|
||||
};
|
||||
@ -101,23 +101,23 @@ struct _IP_ResolverPrivate {
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, IP_Address> cache;
|
||||
HashMap<String, IPAddress> cache;
|
||||
|
||||
static String get_cache_key(String p_hostname, IP::Type p_type) {
|
||||
return itos(p_type) + p_hostname;
|
||||
}
|
||||
};
|
||||
|
||||
IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
|
||||
IPAddress IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
|
||||
MutexLock lock(resolver->mutex);
|
||||
|
||||
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
||||
if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
|
||||
IP_Address res = resolver->cache[key];
|
||||
IPAddress res = resolver->cache[key];
|
||||
return res;
|
||||
}
|
||||
|
||||
IP_Address res = _resolve_hostname(p_hostname, p_type);
|
||||
IPAddress res = _resolve_hostname(p_hostname, p_type);
|
||||
resolver->cache[key] = res;
|
||||
return res;
|
||||
}
|
||||
@ -139,7 +139,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
|
||||
resolver->queue[id].response = resolver->cache[key];
|
||||
resolver->queue[id].status.set(IP::RESOLVER_STATUS_DONE);
|
||||
} else {
|
||||
resolver->queue[id].response = IP_Address();
|
||||
resolver->queue[id].response = IPAddress();
|
||||
resolver->queue[id].status.set(IP::RESOLVER_STATUS_WAITING);
|
||||
if (resolver->thread.is_started()) {
|
||||
resolver->sem.post();
|
||||
@ -164,15 +164,15 @@ IP::ResolverStatus IP::get_resolve_item_status(ResolverID p_id) const {
|
||||
return resolver->queue[p_id].status.get();
|
||||
}
|
||||
|
||||
IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
|
||||
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP_Address());
|
||||
IPAddress IP::get_resolve_item_address(ResolverID p_id) const {
|
||||
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IPAddress());
|
||||
|
||||
MutexLock lock(resolver->mutex);
|
||||
|
||||
if (resolver->queue[p_id].status.get() != IP::RESOLVER_STATUS_DONE) {
|
||||
ERR_PRINT("Resolve of '" + resolver->queue[p_id].hostname + "'' didn't complete yet.");
|
||||
resolver->mutex.unlock();
|
||||
return IP_Address();
|
||||
return IPAddress();
|
||||
}
|
||||
|
||||
return resolver->queue[p_id].response;
|
||||
@ -201,9 +201,9 @@ void IP::clear_cache(const String &p_hostname) {
|
||||
|
||||
Array IP::_get_local_addresses() const {
|
||||
Array addresses;
|
||||
List<IP_Address> ip_addresses;
|
||||
List<IPAddress> ip_addresses;
|
||||
get_local_addresses(&ip_addresses);
|
||||
for (List<IP_Address>::Element *E = ip_addresses.front(); E; E = E->next()) {
|
||||
for (List<IPAddress>::Element *E = ip_addresses.front(); E; E = E->next()) {
|
||||
addresses.push_back(E->get());
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ Array IP::_get_local_interfaces() const {
|
||||
rc["index"] = c.index;
|
||||
|
||||
Array ips;
|
||||
for (const List<IP_Address>::Element *F = c.ip_addresses.front(); F; F = F->next()) {
|
||||
for (const List<IPAddress>::Element *F = c.ip_addresses.front(); F; F = F->next()) {
|
||||
ips.push_front(F->get());
|
||||
}
|
||||
rc["addresses"] = ips;
|
||||
@ -233,11 +233,11 @@ Array IP::_get_local_interfaces() const {
|
||||
return results;
|
||||
}
|
||||
|
||||
void IP::get_local_addresses(List<IP_Address> *r_addresses) const {
|
||||
void IP::get_local_addresses(List<IPAddress> *r_addresses) const {
|
||||
Map<String, Interface_Info> interfaces;
|
||||
get_local_interfaces(&interfaces);
|
||||
for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) {
|
||||
for (const List<IP_Address>::Element *F = E->get().ip_addresses.front(); F; F = F->next()) {
|
||||
for (const List<IPAddress>::Element *F = E->get().ip_addresses.front(); F; F = F->next()) {
|
||||
r_addresses->push_front(F->get());
|
||||
}
|
||||
}
|
||||
|
10
core/io/ip.h
10
core/io/ip.h
@ -69,7 +69,7 @@ protected:
|
||||
static IP *singleton;
|
||||
static void _bind_methods();
|
||||
|
||||
virtual IP_Address _resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY) = 0;
|
||||
virtual IPAddress _resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY) = 0;
|
||||
Array _get_local_addresses() const;
|
||||
Array _get_local_interfaces() const;
|
||||
|
||||
@ -80,15 +80,15 @@ public:
|
||||
String name;
|
||||
String name_friendly;
|
||||
String index;
|
||||
List<IP_Address> ip_addresses;
|
||||
List<IPAddress> ip_addresses;
|
||||
};
|
||||
|
||||
IP_Address resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY);
|
||||
IPAddress resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY);
|
||||
// async resolver hostname
|
||||
ResolverID resolve_hostname_queue_item(const String &p_hostname, Type p_type = TYPE_ANY);
|
||||
ResolverStatus get_resolve_item_status(ResolverID p_id) const;
|
||||
IP_Address get_resolve_item_address(ResolverID p_id) const;
|
||||
virtual void get_local_addresses(List<IP_Address> *r_addresses) const;
|
||||
IPAddress get_resolve_item_address(ResolverID p_id) const;
|
||||
virtual void get_local_addresses(List<IPAddress> *r_addresses) const;
|
||||
virtual void get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const = 0;
|
||||
void erase_resolve_item(ResolverID p_id);
|
||||
|
||||
|
@ -30,14 +30,14 @@
|
||||
|
||||
#include "ip_address.h"
|
||||
/*
|
||||
IP_Address::operator Variant() const {
|
||||
IPAddress::operator Variant() const {
|
||||
return operator String();
|
||||
}*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
IP_Address::operator String() const {
|
||||
IPAddress::operator String() const {
|
||||
if (wildcard) {
|
||||
return "*";
|
||||
}
|
||||
@ -90,7 +90,7 @@ static void _parse_hex(const String &p_string, int p_start, uint8_t *p_dst) {
|
||||
p_dst[1] = ret & 0xff;
|
||||
}
|
||||
|
||||
void IP_Address::_parse_ipv6(const String &p_string) {
|
||||
void IPAddress::_parse_ipv6(const String &p_string) {
|
||||
static const int parts_total = 8;
|
||||
int parts[parts_total] = { 0 };
|
||||
int parts_count = 0;
|
||||
@ -146,7 +146,7 @@ void IP_Address::_parse_ipv6(const String &p_string) {
|
||||
}
|
||||
}
|
||||
|
||||
void IP_Address::_parse_ipv4(const String &p_string, int p_start, uint8_t *p_ret) {
|
||||
void IPAddress::_parse_ipv4(const String &p_string, int p_start, uint8_t *p_ret) {
|
||||
String ip;
|
||||
if (p_start != 0) {
|
||||
ip = p_string.substr(p_start, p_string.length() - p_start);
|
||||
@ -161,33 +161,33 @@ void IP_Address::_parse_ipv4(const String &p_string, int p_start, uint8_t *p_ret
|
||||
}
|
||||
}
|
||||
|
||||
void IP_Address::clear() {
|
||||
void IPAddress::clear() {
|
||||
memset(&field8[0], 0, sizeof(field8));
|
||||
valid = false;
|
||||
wildcard = false;
|
||||
}
|
||||
|
||||
bool IP_Address::is_ipv4() const {
|
||||
bool IPAddress::is_ipv4() const {
|
||||
return (field32[0] == 0 && field32[1] == 0 && field16[4] == 0 && field16[5] == 0xffff);
|
||||
}
|
||||
|
||||
const uint8_t *IP_Address::get_ipv4() const {
|
||||
const uint8_t *IPAddress::get_ipv4() const {
|
||||
ERR_FAIL_COND_V_MSG(!is_ipv4(), &(field8[12]), "IPv4 requested, but current IP is IPv6."); // Not the correct IPv4 (it's an IPv6), but we don't want to return a null pointer risking an engine crash.
|
||||
return &(field8[12]);
|
||||
}
|
||||
|
||||
void IP_Address::set_ipv4(const uint8_t *p_ip) {
|
||||
void IPAddress::set_ipv4(const uint8_t *p_ip) {
|
||||
clear();
|
||||
valid = true;
|
||||
field16[5] = 0xffff;
|
||||
field32[3] = *((const uint32_t *)p_ip);
|
||||
}
|
||||
|
||||
const uint8_t *IP_Address::get_ipv6() const {
|
||||
const uint8_t *IPAddress::get_ipv6() const {
|
||||
return field8;
|
||||
}
|
||||
|
||||
void IP_Address::set_ipv6(const uint8_t *p_buf) {
|
||||
void IPAddress::set_ipv6(const uint8_t *p_buf) {
|
||||
clear();
|
||||
valid = true;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
@ -195,7 +195,7 @@ void IP_Address::set_ipv6(const uint8_t *p_buf) {
|
||||
}
|
||||
}
|
||||
|
||||
IP_Address::IP_Address(const String &p_string) {
|
||||
IPAddress::IPAddress(const String &p_string) {
|
||||
clear();
|
||||
|
||||
if (p_string == "*") {
|
||||
@ -225,7 +225,7 @@ _FORCE_INLINE_ static void _32_to_buf(uint8_t *p_dst, uint32_t p_n) {
|
||||
p_dst[3] = (p_n >> 0) & 0xff;
|
||||
}
|
||||
|
||||
IP_Address::IP_Address(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, bool is_v6) {
|
||||
IPAddress::IPAddress(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, bool is_v6) {
|
||||
clear();
|
||||
valid = true;
|
||||
if (!is_v6) {
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
struct IP_Address {
|
||||
struct IPAddress {
|
||||
private:
|
||||
union {
|
||||
uint8_t field8[16];
|
||||
@ -50,7 +50,7 @@ protected:
|
||||
|
||||
public:
|
||||
//operator Variant() const;
|
||||
bool operator==(const IP_Address &p_ip) const {
|
||||
bool operator==(const IPAddress &p_ip) const {
|
||||
if (p_ip.valid != valid) {
|
||||
return false;
|
||||
}
|
||||
@ -65,7 +65,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const IP_Address &p_ip) const {
|
||||
bool operator!=(const IPAddress &p_ip) const {
|
||||
if (p_ip.valid != valid) {
|
||||
return true;
|
||||
}
|
||||
@ -91,9 +91,9 @@ public:
|
||||
void set_ipv6(const uint8_t *p_buf);
|
||||
|
||||
operator String() const;
|
||||
IP_Address(const String &p_string);
|
||||
IP_Address(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, bool is_v6 = false);
|
||||
IP_Address() { clear(); }
|
||||
IPAddress(const String &p_string);
|
||||
IPAddress(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, bool is_v6 = false);
|
||||
IPAddress() { clear(); }
|
||||
};
|
||||
|
||||
#endif // IP_ADDRESS_H
|
||||
|
@ -55,27 +55,27 @@ public:
|
||||
|
||||
virtual Error open(Type p_type, IP::Type &ip_type) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual Error bind(IP_Address p_addr, uint16_t p_port) = 0;
|
||||
virtual Error bind(IPAddress p_addr, uint16_t p_port) = 0;
|
||||
virtual Error listen(int p_max_pending) = 0;
|
||||
virtual Error connect_to_host(IP_Address p_addr, uint16_t p_port) = 0;
|
||||
virtual Error connect_to_host(IPAddress p_addr, uint16_t p_port) = 0;
|
||||
virtual Error poll(PollType p_type, int timeout) const = 0;
|
||||
virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read) = 0;
|
||||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek = false) = 0;
|
||||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port, bool p_peek = false) = 0;
|
||||
virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent) = 0;
|
||||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0;
|
||||
virtual Ref<NetSocket> accept(IP_Address &r_ip, uint16_t &r_port) = 0;
|
||||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) = 0;
|
||||
virtual Ref<NetSocket> accept(IPAddress &r_ip, uint16_t &r_port) = 0;
|
||||
|
||||
virtual bool is_open() const = 0;
|
||||
virtual int get_available_bytes() const = 0;
|
||||
virtual Error get_socket_address(IP_Address *r_ip, uint16_t *r_port) const = 0;
|
||||
virtual Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) const = 0;
|
||||
|
||||
virtual Error set_broadcasting_enabled(bool p_enabled) = 0; // Returns OK if the socket option has been set successfully.
|
||||
virtual void set_blocking_enabled(bool p_enabled) = 0;
|
||||
virtual void set_ipv6_only_enabled(bool p_enabled) = 0;
|
||||
virtual void set_tcp_no_delay_enabled(bool p_enabled) = 0;
|
||||
virtual void set_reuse_address_enabled(bool p_enabled) = 0;
|
||||
virtual Error join_multicast_group(const IP_Address &p_multi_address, String p_if_name) = 0;
|
||||
virtual Error leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) = 0;
|
||||
virtual Error join_multicast_group(const IPAddress &p_multi_address, String p_if_name) = 0;
|
||||
virtual Error leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) = 0;
|
||||
};
|
||||
|
||||
#endif // NET_SOCKET_H
|
||||
|
@ -45,7 +45,7 @@ void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_if_name) {
|
||||
Error PacketPeerUDP::join_multicast_group(IPAddress p_multi_address, String p_if_name) {
|
||||
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(!p_multi_address.is_valid(), ERR_INVALID_PARAMETER);
|
||||
@ -60,7 +60,7 @@ Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_i
|
||||
return _sock->join_multicast_group(p_multi_address, p_if_name);
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::leave_multicast_group(IP_Address p_multi_address, String p_if_name) {
|
||||
Error PacketPeerUDP::leave_multicast_group(IPAddress p_multi_address, String p_if_name) {
|
||||
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(!_sock->is_open(), ERR_UNCONFIGURED);
|
||||
@ -72,7 +72,7 @@ String PacketPeerUDP::_get_packet_ip() const {
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
if (p_address.is_valid_ip_address()) {
|
||||
ip = p_address;
|
||||
} else {
|
||||
@ -159,7 +159,7 @@ int PacketPeerUDP::get_max_packet_size() const {
|
||||
return 512; // uhm maybe not
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::bind(int p_port, const IP_Address &p_bind_address, int p_recv_buffer_size) {
|
||||
Error PacketPeerUDP::bind(int p_port, const IPAddress &p_bind_address, int p_recv_buffer_size) {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
|
||||
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
|
||||
@ -190,7 +190,7 @@ Error PacketPeerUDP::bind(int p_port, const IP_Address &p_bind_address, int p_re
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::connect_shared_socket(Ref<NetSocket> p_sock, IP_Address p_ip, uint16_t p_port, UDPServer *p_server) {
|
||||
Error PacketPeerUDP::connect_shared_socket(Ref<NetSocket> p_sock, IPAddress p_ip, uint16_t p_port, UDPServer *p_server) {
|
||||
udp_server = p_server;
|
||||
connected = true;
|
||||
_sock = p_sock;
|
||||
@ -207,7 +207,7 @@ void PacketPeerUDP::disconnect_shared_socket() {
|
||||
close();
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::connect_to_host(const IP_Address &p_host, int p_port) {
|
||||
Error PacketPeerUDP::connect_to_host(const IPAddress &p_host, int p_port) {
|
||||
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER);
|
||||
@ -276,7 +276,7 @@ Error PacketPeerUDP::_poll() {
|
||||
|
||||
Error err;
|
||||
int read;
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
uint16_t port;
|
||||
|
||||
while (true) {
|
||||
@ -306,7 +306,7 @@ Error PacketPeerUDP::_poll() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error PacketPeerUDP::store_packet(IP_Address p_ip, uint32_t p_port, uint8_t *p_buf, int p_buf_size) {
|
||||
Error PacketPeerUDP::store_packet(IPAddress p_ip, uint32_t p_port, uint8_t *p_buf, int p_buf_size) {
|
||||
if (rb.space_left() < p_buf_size + 24) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -322,7 +322,7 @@ bool PacketPeerUDP::is_bound() const {
|
||||
return _sock.is_valid() && _sock->is_open();
|
||||
}
|
||||
|
||||
IP_Address PacketPeerUDP::get_packet_address() const {
|
||||
IPAddress PacketPeerUDP::get_packet_address() const {
|
||||
return packet_ip;
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ int PacketPeerUDP::get_local_port() const {
|
||||
return local_port;
|
||||
}
|
||||
|
||||
void PacketPeerUDP::set_dest_address(const IP_Address &p_address, int p_port) {
|
||||
void PacketPeerUDP::set_dest_address(const IPAddress &p_address, int p_port) {
|
||||
ERR_FAIL_COND_MSG(connected, "Destination address cannot be set for connected sockets");
|
||||
peer_addr = p_address;
|
||||
peer_port = p_port;
|
||||
|
@ -48,11 +48,11 @@ protected:
|
||||
RingBuffer<uint8_t> rb;
|
||||
uint8_t recv_buffer[PACKET_BUFFER_SIZE];
|
||||
uint8_t packet_buffer[PACKET_BUFFER_SIZE];
|
||||
IP_Address packet_ip;
|
||||
IPAddress packet_ip;
|
||||
int packet_port = 0;
|
||||
int queue_count = 0;
|
||||
|
||||
IP_Address peer_addr;
|
||||
IPAddress peer_addr;
|
||||
int peer_port = 0;
|
||||
bool connected = false;
|
||||
bool blocking = true;
|
||||
@ -70,29 +70,29 @@ protected:
|
||||
public:
|
||||
void set_blocking_mode(bool p_enable);
|
||||
|
||||
Error bind(int p_port, const IP_Address &p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536);
|
||||
Error bind(int p_port, const IPAddress &p_bind_address = IPAddress("*"), int p_recv_buffer_size = 65536);
|
||||
void close();
|
||||
Error wait();
|
||||
bool is_bound() const;
|
||||
|
||||
Error connect_shared_socket(Ref<NetSocket> p_sock, IP_Address p_ip, uint16_t p_port, UDPServer *ref); // Used by UDPServer
|
||||
Error connect_shared_socket(Ref<NetSocket> p_sock, IPAddress p_ip, uint16_t p_port, UDPServer *ref); // Used by UDPServer
|
||||
void disconnect_shared_socket(); // Used by UDPServer
|
||||
Error store_packet(IP_Address p_ip, uint32_t p_port, uint8_t *p_buf, int p_buf_size); // Used internally and by UDPServer
|
||||
Error connect_to_host(const IP_Address &p_host, int p_port);
|
||||
Error store_packet(IPAddress p_ip, uint32_t p_port, uint8_t *p_buf, int p_buf_size); // Used internally and by UDPServer
|
||||
Error connect_to_host(const IPAddress &p_host, int p_port);
|
||||
bool is_connected_to_host() const;
|
||||
|
||||
IP_Address get_packet_address() const;
|
||||
IPAddress get_packet_address() const;
|
||||
int get_packet_port() const;
|
||||
int get_local_port() const;
|
||||
void set_dest_address(const IP_Address &p_address, int p_port);
|
||||
void set_dest_address(const IPAddress &p_address, int p_port);
|
||||
|
||||
Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
|
||||
Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
|
||||
int get_available_packet_count() const override;
|
||||
int get_max_packet_size() const override;
|
||||
void set_broadcast_enabled(bool p_enabled);
|
||||
Error join_multicast_group(IP_Address p_multi_address, String p_if_name);
|
||||
Error leave_multicast_group(IP_Address p_multi_address, String p_if_name);
|
||||
Error join_multicast_group(IPAddress p_multi_address, String p_if_name);
|
||||
Error leave_multicast_group(IPAddress p_multi_address, String p_if_name);
|
||||
|
||||
PacketPeerUDP();
|
||||
~PacketPeerUDP();
|
||||
|
@ -56,7 +56,7 @@ Error StreamPeerTCP::_poll_connection() {
|
||||
return ERR_CONNECTION_ERROR;
|
||||
}
|
||||
|
||||
void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint16_t p_port) {
|
||||
void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IPAddress p_host, uint16_t p_port) {
|
||||
_sock = p_sock;
|
||||
_sock->set_blocking_enabled(false);
|
||||
|
||||
@ -67,7 +67,7 @@ void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint
|
||||
peer_port = p_port;
|
||||
}
|
||||
|
||||
Error StreamPeerTCP::bind(int p_port, const IP_Address &p_host) {
|
||||
Error StreamPeerTCP::bind(int p_port, const IPAddress &p_host) {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
|
||||
ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive).");
|
||||
@ -84,7 +84,7 @@ Error StreamPeerTCP::bind(int p_port, const IP_Address &p_host) {
|
||||
return _sock->bind(p_host, p_port);
|
||||
}
|
||||
|
||||
Error StreamPeerTCP::connect_to_host(const IP_Address &p_host, int p_port) {
|
||||
Error StreamPeerTCP::connect_to_host(const IPAddress &p_host, int p_port) {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(status != STATUS_NONE, ERR_ALREADY_IN_USE);
|
||||
ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER);
|
||||
@ -283,7 +283,7 @@ void StreamPeerTCP::disconnect_from_host() {
|
||||
|
||||
timeout = 0;
|
||||
status = STATUS_NONE;
|
||||
peer_host = IP_Address();
|
||||
peer_host = IPAddress();
|
||||
peer_port = 0;
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ int StreamPeerTCP::get_available_bytes() const {
|
||||
return _sock->get_available_bytes();
|
||||
}
|
||||
|
||||
IP_Address StreamPeerTCP::get_connected_host() const {
|
||||
IPAddress StreamPeerTCP::get_connected_host() const {
|
||||
return peer_host;
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ int StreamPeerTCP::get_local_port() const {
|
||||
}
|
||||
|
||||
Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
if (p_address.is_valid_ip_address()) {
|
||||
ip = p_address;
|
||||
} else {
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
Ref<NetSocket> _sock;
|
||||
uint64_t timeout = 0;
|
||||
Status status = STATUS_NONE;
|
||||
IP_Address peer_host;
|
||||
IPAddress peer_host;
|
||||
uint16_t peer_port = 0;
|
||||
|
||||
Error _connect(const String &p_address, int p_port);
|
||||
@ -63,12 +63,12 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint16_t p_port);
|
||||
void accept_socket(Ref<NetSocket> p_sock, IPAddress p_host, uint16_t p_port);
|
||||
|
||||
Error bind(int p_port, const IP_Address &p_host);
|
||||
Error connect_to_host(const IP_Address &p_host, int p_port);
|
||||
Error bind(int p_port, const IPAddress &p_host);
|
||||
Error connect_to_host(const IPAddress &p_host, int p_port);
|
||||
bool is_connected_to_host() const;
|
||||
IP_Address get_connected_host() const;
|
||||
IPAddress get_connected_host() const;
|
||||
int get_connected_port() const;
|
||||
int get_local_port() const;
|
||||
void disconnect_from_host();
|
||||
|
@ -30,16 +30,16 @@
|
||||
|
||||
#include "tcp_server.h"
|
||||
|
||||
void TCP_Server::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
|
||||
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available);
|
||||
ClassDB::bind_method(D_METHOD("is_listening"), &TCP_Server::is_listening);
|
||||
ClassDB::bind_method(D_METHOD("get_local_port"), &TCP_Server::get_local_port);
|
||||
ClassDB::bind_method(D_METHOD("take_connection"), &TCP_Server::take_connection);
|
||||
ClassDB::bind_method(D_METHOD("stop"), &TCP_Server::stop);
|
||||
void TCPServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCPServer::listen, DEFVAL("*"));
|
||||
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCPServer::is_connection_available);
|
||||
ClassDB::bind_method(D_METHOD("is_listening"), &TCPServer::is_listening);
|
||||
ClassDB::bind_method(D_METHOD("get_local_port"), &TCPServer::get_local_port);
|
||||
ClassDB::bind_method(D_METHOD("take_connection"), &TCPServer::take_connection);
|
||||
ClassDB::bind_method(D_METHOD("stop"), &TCPServer::stop);
|
||||
}
|
||||
|
||||
Error TCP_Server::listen(uint16_t p_port, const IP_Address &p_bind_address) {
|
||||
Error TCPServer::listen(uint16_t p_port, const IPAddress &p_bind_address) {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
|
||||
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
|
||||
@ -76,19 +76,19 @@ Error TCP_Server::listen(uint16_t p_port, const IP_Address &p_bind_address) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int TCP_Server::get_local_port() const {
|
||||
int TCPServer::get_local_port() const {
|
||||
uint16_t local_port;
|
||||
_sock->get_socket_address(nullptr, &local_port);
|
||||
return local_port;
|
||||
}
|
||||
|
||||
bool TCP_Server::is_listening() const {
|
||||
bool TCPServer::is_listening() const {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), false);
|
||||
|
||||
return _sock->is_open();
|
||||
}
|
||||
|
||||
bool TCP_Server::is_connection_available() const {
|
||||
bool TCPServer::is_connection_available() const {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), false);
|
||||
|
||||
if (!_sock->is_open()) {
|
||||
@ -99,14 +99,14 @@ bool TCP_Server::is_connection_available() const {
|
||||
return (err == OK);
|
||||
}
|
||||
|
||||
Ref<StreamPeerTCP> TCP_Server::take_connection() {
|
||||
Ref<StreamPeerTCP> TCPServer::take_connection() {
|
||||
Ref<StreamPeerTCP> conn;
|
||||
if (!is_connection_available()) {
|
||||
return conn;
|
||||
}
|
||||
|
||||
Ref<NetSocket> ns;
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
uint16_t port = 0;
|
||||
ns = _sock->accept(ip, port);
|
||||
if (!ns.is_valid()) {
|
||||
@ -118,16 +118,16 @@ Ref<StreamPeerTCP> TCP_Server::take_connection() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
void TCP_Server::stop() {
|
||||
void TCPServer::stop() {
|
||||
if (_sock.is_valid()) {
|
||||
_sock->close();
|
||||
}
|
||||
}
|
||||
|
||||
TCP_Server::TCP_Server() :
|
||||
TCPServer::TCPServer() :
|
||||
_sock(Ref<NetSocket>(NetSocket::create())) {
|
||||
}
|
||||
|
||||
TCP_Server::~TCP_Server() {
|
||||
TCPServer::~TCPServer() {
|
||||
stop();
|
||||
}
|
||||
|
@ -36,8 +36,8 @@
|
||||
#include "core/io/stream_peer.h"
|
||||
#include "core/io/stream_peer_tcp.h"
|
||||
|
||||
class TCP_Server : public Reference {
|
||||
GDCLASS(TCP_Server, Reference);
|
||||
class TCPServer : public Reference {
|
||||
GDCLASS(TCPServer, Reference);
|
||||
|
||||
protected:
|
||||
enum {
|
||||
@ -48,7 +48,7 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*"));
|
||||
Error listen(uint16_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
|
||||
int get_local_port() const;
|
||||
bool is_listening() const;
|
||||
bool is_connection_available() const;
|
||||
@ -56,8 +56,8 @@ public:
|
||||
|
||||
void stop(); // Stop listening
|
||||
|
||||
TCP_Server();
|
||||
~TCP_Server();
|
||||
TCPServer();
|
||||
~TCPServer();
|
||||
};
|
||||
|
||||
#endif // TCP_SERVER_H
|
||||
|
@ -50,7 +50,7 @@ Error UDPServer::poll() {
|
||||
}
|
||||
Error err;
|
||||
int read;
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
uint16_t port;
|
||||
while (true) {
|
||||
err = _sock->recvfrom(recv_buffer, sizeof(recv_buffer), read, ip, port);
|
||||
@ -87,7 +87,7 @@ Error UDPServer::poll() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error UDPServer::listen(uint16_t p_port, const IP_Address &p_bind_address) {
|
||||
Error UDPServer::listen(uint16_t p_port, const IPAddress &p_bind_address) {
|
||||
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
|
||||
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
|
||||
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
|
||||
@ -168,7 +168,7 @@ Ref<PacketPeerUDP> UDPServer::take_connection() {
|
||||
return peer.peer;
|
||||
}
|
||||
|
||||
void UDPServer::remove_peer(IP_Address p_ip, int p_port) {
|
||||
void UDPServer::remove_peer(IPAddress p_ip, int p_port) {
|
||||
Peer peer;
|
||||
peer.ip = p_ip;
|
||||
peer.port = p_port;
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
|
||||
struct Peer {
|
||||
PacketPeerUDP *peer;
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
uint16_t port = 0;
|
||||
|
||||
bool operator==(const Peer &p_other) const {
|
||||
@ -61,8 +61,8 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void remove_peer(IP_Address p_ip, int p_port);
|
||||
Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*"));
|
||||
void remove_peer(IPAddress p_ip, int p_port);
|
||||
Error listen(uint16_t p_port, const IPAddress &p_bind_address = IPAddress("*"));
|
||||
Error poll();
|
||||
int get_local_port() const;
|
||||
bool is_listening() const;
|
||||
|
@ -156,7 +156,7 @@ void register_core_types() {
|
||||
ClassDB::register_virtual_class<StreamPeer>();
|
||||
ClassDB::register_class<StreamPeerBuffer>();
|
||||
ClassDB::register_class<StreamPeerTCP>();
|
||||
ClassDB::register_class<TCP_Server>();
|
||||
ClassDB::register_class<TCPServer>();
|
||||
ClassDB::register_class<PacketPeerUDP>();
|
||||
ClassDB::register_class<UDPServer>();
|
||||
ClassDB::register_custom_instance_class<PacketPeerDTLS>();
|
||||
|
@ -364,7 +364,7 @@ MAKE_VECARR(Plane);
|
||||
} \
|
||||
}
|
||||
|
||||
// Special case for IP_Address.
|
||||
// Special case for IPAddress.
|
||||
|
||||
#define MAKE_STRINGCONV_BY_REFERENCE(m_type) \
|
||||
template <> \
|
||||
@ -387,7 +387,7 @@ MAKE_VECARR(Plane);
|
||||
} \
|
||||
}
|
||||
|
||||
MAKE_STRINGCONV_BY_REFERENCE(IP_Address);
|
||||
MAKE_STRINGCONV_BY_REFERENCE(IPAddress);
|
||||
|
||||
template <>
|
||||
struct PtrToArg<Vector<Face3>> {
|
||||
|
@ -168,7 +168,7 @@ MAKE_TYPE_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY)
|
||||
MAKE_TYPE_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY)
|
||||
MAKE_TYPE_INFO(PackedColorArray, Variant::PACKED_COLOR_ARRAY)
|
||||
|
||||
MAKE_TYPE_INFO(IP_Address, Variant::STRING)
|
||||
MAKE_TYPE_INFO(IPAddress, Variant::STRING)
|
||||
|
||||
//objectID
|
||||
template <>
|
||||
|
@ -2346,15 +2346,15 @@ Variant::operator Orientation() const {
|
||||
return (Orientation) operator int();
|
||||
}
|
||||
|
||||
Variant::operator IP_Address() const {
|
||||
Variant::operator IPAddress() const {
|
||||
if (type == PACKED_FLOAT32_ARRAY || type == PACKED_INT32_ARRAY || type == PACKED_FLOAT64_ARRAY || type == PACKED_INT64_ARRAY || type == PACKED_BYTE_ARRAY) {
|
||||
Vector<int> addr = operator Vector<int>();
|
||||
if (addr.size() == 4) {
|
||||
return IP_Address(addr.get(0), addr.get(1), addr.get(2), addr.get(3));
|
||||
return IPAddress(addr.get(0), addr.get(1), addr.get(2), addr.get(3));
|
||||
}
|
||||
}
|
||||
|
||||
return IP_Address(operator String());
|
||||
return IPAddress(operator String());
|
||||
}
|
||||
|
||||
Variant::Variant(bool p_bool) {
|
||||
@ -2831,7 +2831,7 @@ void Variant::operator=(const Variant &p_variant) {
|
||||
}
|
||||
}
|
||||
|
||||
Variant::Variant(const IP_Address &p_address) {
|
||||
Variant::Variant(const IPAddress &p_address) {
|
||||
type = STRING;
|
||||
memnew_placement(_data._mem, String(p_address));
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ public:
|
||||
operator Side() const;
|
||||
operator Orientation() const;
|
||||
|
||||
operator IP_Address() const;
|
||||
operator IPAddress() const;
|
||||
|
||||
Object *get_validated_object() const;
|
||||
Object *get_validated_object_with_check(bool &r_previously_freed) const;
|
||||
@ -421,7 +421,7 @@ public:
|
||||
Variant(const Vector<::RID> &p_array); // helper
|
||||
Variant(const Vector<Vector2> &p_array); // helper
|
||||
|
||||
Variant(const IP_Address &p_address);
|
||||
Variant(const IPAddress &p_address);
|
||||
|
||||
// If this changes the table in variant_op must be updated
|
||||
enum Operator {
|
||||
|
@ -4,7 +4,7 @@
|
||||
Internet protocol (IP) support functions such as DNS resolution.
|
||||
</brief_description>
|
||||
<description>
|
||||
IP contains support functions for the Internet Protocol (IP). TCP/IP support is in different classes (see [StreamPeerTCP] and [TCP_Server]). IP provides DNS hostname resolution support, both blocking and threaded.
|
||||
IP contains support functions for the Internet Protocol (IP). TCP/IP support is in different classes (see [StreamPeerTCP] and [TCPServer]). IP provides DNS hostname resolution support, both blocking and threaded.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="TCP_Server" inherits="Reference" version="4.0">
|
||||
<class name="TCPServer" inherits="Reference" version="4.0">
|
||||
<brief_description>
|
||||
A TCP server.
|
||||
</brief_description>
|
@ -75,8 +75,8 @@
|
||||
#include <net/if.h> // Order is important on OpenBSD, leave as last
|
||||
#endif
|
||||
|
||||
static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
|
||||
IP_Address ip;
|
||||
static IPAddress _sockaddr2ip(struct sockaddr *p_addr) {
|
||||
IPAddress ip;
|
||||
|
||||
if (p_addr->sa_family == AF_INET) {
|
||||
struct sockaddr_in *addr = (struct sockaddr_in *)p_addr;
|
||||
@ -89,7 +89,7 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
|
||||
return ip;
|
||||
};
|
||||
|
||||
IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
|
||||
IPAddress IPUnix::_resolve_hostname(const String &p_hostname, Type p_type) {
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *result = nullptr;
|
||||
|
||||
@ -108,7 +108,7 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
|
||||
int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result);
|
||||
if (s != 0) {
|
||||
ERR_PRINT("getaddrinfo failed! Cannot resolve hostname.");
|
||||
return IP_Address();
|
||||
return IPAddress();
|
||||
};
|
||||
|
||||
if (result == nullptr || result->ai_addr == nullptr) {
|
||||
@ -116,10 +116,10 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
|
||||
if (result) {
|
||||
freeaddrinfo(result);
|
||||
}
|
||||
return IP_Address();
|
||||
return IPAddress();
|
||||
};
|
||||
|
||||
IP_Address ip = _sockaddr2ip(result->ai_addr);
|
||||
IPAddress ip = _sockaddr2ip(result->ai_addr);
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
@ -130,7 +130,7 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
|
||||
|
||||
#if defined(UWP_ENABLED)
|
||||
|
||||
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
|
||||
void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
|
||||
using namespace Windows::Networking;
|
||||
using namespace Windows::Networking::Connectivity;
|
||||
|
||||
@ -156,14 +156,14 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
|
||||
|
||||
Interface_Info &info = E->get();
|
||||
|
||||
IP_Address ip = IP_Address(hostname->CanonicalName->Data());
|
||||
IPAddress ip = IPAddress(hostname->CanonicalName->Data());
|
||||
info.ip_addresses.push_front(ip);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
|
||||
void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
|
||||
ULONG buf_size = 1024;
|
||||
IP_ADAPTER_ADDRESSES *addrs;
|
||||
|
||||
@ -211,7 +211,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
|
||||
|
||||
#else // UNIX
|
||||
|
||||
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
|
||||
void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
|
||||
struct ifaddrs *ifAddrStruct = nullptr;
|
||||
struct ifaddrs *ifa = nullptr;
|
||||
int family;
|
||||
@ -249,15 +249,15 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
|
||||
}
|
||||
#endif
|
||||
|
||||
void IP_Unix::make_default() {
|
||||
void IPUnix::make_default() {
|
||||
_create = _create_unix;
|
||||
}
|
||||
|
||||
IP *IP_Unix::_create_unix() {
|
||||
return memnew(IP_Unix);
|
||||
IP *IPUnix::_create_unix() {
|
||||
return memnew(IPUnix);
|
||||
}
|
||||
|
||||
IP_Unix::IP_Unix() {
|
||||
IPUnix::IPUnix() {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -35,10 +35,10 @@
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED)
|
||||
|
||||
class IP_Unix : public IP {
|
||||
GDCLASS(IP_Unix, IP);
|
||||
class IPUnix : public IP {
|
||||
GDCLASS(IPUnix, IP);
|
||||
|
||||
virtual IP_Address _resolve_hostname(const String &p_hostname, IP::Type p_type) override;
|
||||
virtual IPAddress _resolve_hostname(const String &p_hostname, IP::Type p_type) override;
|
||||
|
||||
static IP *_create_unix();
|
||||
|
||||
@ -46,7 +46,7 @@ public:
|
||||
virtual void get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const override;
|
||||
|
||||
static void make_default();
|
||||
IP_Unix();
|
||||
IPUnix();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -95,7 +95,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const IP_Address &p_ip, uint16_t p_port, IP::Type p_ip_type) {
|
||||
size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const IPAddress &p_ip, uint16_t p_port, IP::Type p_ip_type) {
|
||||
memset(p_addr, 0, sizeof(struct sockaddr_storage));
|
||||
if (p_ip_type == IP::TYPE_IPV6 || p_ip_type == IP::TYPE_ANY) { // IPv6 socket
|
||||
|
||||
@ -130,7 +130,7 @@ size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const
|
||||
}
|
||||
}
|
||||
|
||||
void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IP_Address *r_ip, uint16_t *r_port) {
|
||||
void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ip, uint16_t *r_port) {
|
||||
if (p_addr->ss_family == AF_INET) {
|
||||
struct sockaddr_in *addr4 = (struct sockaddr_in *)p_addr;
|
||||
if (r_ip) {
|
||||
@ -233,7 +233,7 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
bool NetSocketPosix::_can_use_ip(const IP_Address &p_ip, const bool p_for_bind) const {
|
||||
bool NetSocketPosix::_can_use_ip(const IPAddress &p_ip, const bool p_for_bind) const {
|
||||
if (p_for_bind && !(p_ip.is_valid() || p_ip.is_wildcard())) {
|
||||
return false;
|
||||
} else if (!p_for_bind && !p_ip.is_valid()) {
|
||||
@ -244,7 +244,7 @@ bool NetSocketPosix::_can_use_ip(const IP_Address &p_ip, const bool p_for_bind)
|
||||
return !(_ip_type != IP::TYPE_ANY && !p_ip.is_wildcard() && _ip_type != type);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, String p_if_name, bool p_add) {
|
||||
_FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, String p_if_name, bool p_add) {
|
||||
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V(!_can_use_ip(p_ip, false), ERR_INVALID_PARAMETER);
|
||||
|
||||
@ -254,7 +254,7 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
|
||||
int level = type == IP::TYPE_IPV4 ? IPPROTO_IP : IPPROTO_IPV6;
|
||||
int ret = -1;
|
||||
|
||||
IP_Address if_ip;
|
||||
IPAddress if_ip;
|
||||
uint32_t if_v6id = 0;
|
||||
Map<String, IP::Interface_Info> if_info;
|
||||
IP::get_singleton()->get_local_interfaces(&if_info);
|
||||
@ -269,7 +269,7 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
|
||||
break; // IPv6 uses index.
|
||||
}
|
||||
|
||||
for (List<IP_Address>::Element *F = c.ip_addresses.front(); F; F = F->next()) {
|
||||
for (List<IPAddress>::Element *F = c.ip_addresses.front(); F; F = F->next()) {
|
||||
if (!F->get().is_ipv4()) {
|
||||
continue; // Wrong IP type
|
||||
}
|
||||
@ -395,7 +395,7 @@ void NetSocketPosix::close() {
|
||||
_is_stream = false;
|
||||
}
|
||||
|
||||
Error NetSocketPosix::bind(IP_Address p_addr, uint16_t p_port) {
|
||||
Error NetSocketPosix::bind(IPAddress p_addr, uint16_t p_port) {
|
||||
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V(!_can_use_ip(p_addr, true), ERR_INVALID_PARAMETER);
|
||||
|
||||
@ -425,7 +425,7 @@ Error NetSocketPosix::listen(int p_max_pending) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
|
||||
Error NetSocketPosix::connect_to_host(IPAddress p_host, uint16_t p_port) {
|
||||
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V(!_can_use_ip(p_host, false), ERR_INVALID_PARAMETER);
|
||||
|
||||
@ -559,7 +559,7 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek) {
|
||||
Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port, bool p_peek) {
|
||||
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
|
||||
|
||||
struct sockaddr_storage from;
|
||||
@ -616,7 +616,7 @@ Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) {
|
||||
Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) {
|
||||
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
@ -735,7 +735,7 @@ int NetSocketPosix::get_available_bytes() const {
|
||||
return len;
|
||||
}
|
||||
|
||||
Error NetSocketPosix::get_socket_address(IP_Address *r_ip, uint16_t *r_port) const {
|
||||
Error NetSocketPosix::get_socket_address(IPAddress *r_ip, uint16_t *r_port) const {
|
||||
ERR_FAIL_COND_V(!is_open(), FAILED);
|
||||
|
||||
struct sockaddr_storage saddr;
|
||||
@ -749,7 +749,7 @@ Error NetSocketPosix::get_socket_address(IP_Address *r_ip, uint16_t *r_port) con
|
||||
return OK;
|
||||
}
|
||||
|
||||
Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) {
|
||||
Ref<NetSocket> NetSocketPosix::accept(IPAddress &r_ip, uint16_t &r_port) {
|
||||
Ref<NetSocket> out;
|
||||
ERR_FAIL_COND_V(!is_open(), out);
|
||||
|
||||
@ -770,11 +770,11 @@ Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) {
|
||||
return Ref<NetSocket>(ns);
|
||||
}
|
||||
|
||||
Error NetSocketPosix::join_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
|
||||
Error NetSocketPosix::join_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
return _change_multicast_group(p_multi_address, p_if_name, true);
|
||||
}
|
||||
|
||||
Error NetSocketPosix::leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
|
||||
Error NetSocketPosix::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
return _change_multicast_group(p_multi_address, p_if_name, false);
|
||||
}
|
||||
#endif
|
||||
|
@ -61,35 +61,35 @@ private:
|
||||
|
||||
NetError _get_socket_error() const;
|
||||
void _set_socket(SOCKET_TYPE p_sock, IP::Type p_ip_type, bool p_is_stream);
|
||||
_FORCE_INLINE_ Error _change_multicast_group(IP_Address p_ip, String p_if_name, bool p_add);
|
||||
_FORCE_INLINE_ Error _change_multicast_group(IPAddress p_ip, String p_if_name, bool p_add);
|
||||
_FORCE_INLINE_ void _set_close_exec_enabled(bool p_enabled);
|
||||
|
||||
protected:
|
||||
static NetSocket *_create_func();
|
||||
|
||||
bool _can_use_ip(const IP_Address &p_ip, const bool p_for_bind) const;
|
||||
bool _can_use_ip(const IPAddress &p_ip, const bool p_for_bind) const;
|
||||
|
||||
public:
|
||||
static void make_default();
|
||||
static void cleanup();
|
||||
static void _set_ip_port(struct sockaddr_storage *p_addr, IP_Address *r_ip, uint16_t *r_port);
|
||||
static size_t _set_addr_storage(struct sockaddr_storage *p_addr, const IP_Address &p_ip, uint16_t p_port, IP::Type p_ip_type);
|
||||
static void _set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ip, uint16_t *r_port);
|
||||
static size_t _set_addr_storage(struct sockaddr_storage *p_addr, const IPAddress &p_ip, uint16_t p_port, IP::Type p_ip_type);
|
||||
|
||||
virtual Error open(Type p_sock_type, IP::Type &ip_type);
|
||||
virtual void close();
|
||||
virtual Error bind(IP_Address p_addr, uint16_t p_port);
|
||||
virtual Error bind(IPAddress p_addr, uint16_t p_port);
|
||||
virtual Error listen(int p_max_pending);
|
||||
virtual Error connect_to_host(IP_Address p_host, uint16_t p_port);
|
||||
virtual Error connect_to_host(IPAddress p_host, uint16_t p_port);
|
||||
virtual Error poll(PollType p_type, int timeout) const;
|
||||
virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read);
|
||||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek = false);
|
||||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port, bool p_peek = false);
|
||||
virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent);
|
||||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port);
|
||||
virtual Ref<NetSocket> accept(IP_Address &r_ip, uint16_t &r_port);
|
||||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port);
|
||||
virtual Ref<NetSocket> accept(IPAddress &r_ip, uint16_t &r_port);
|
||||
|
||||
virtual bool is_open() const;
|
||||
virtual int get_available_bytes() const;
|
||||
virtual Error get_socket_address(IP_Address *r_ip, uint16_t *r_port) const;
|
||||
virtual Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) const;
|
||||
|
||||
virtual Error set_broadcasting_enabled(bool p_enabled);
|
||||
virtual void set_blocking_enabled(bool p_enabled);
|
||||
@ -97,8 +97,8 @@ public:
|
||||
virtual void set_tcp_no_delay_enabled(bool p_enabled);
|
||||
virtual void set_reuse_address_enabled(bool p_enabled);
|
||||
virtual void set_reuse_port_enabled(bool p_enabled);
|
||||
virtual Error join_multicast_group(const IP_Address &p_multi_address, String p_if_name);
|
||||
virtual Error leave_multicast_group(const IP_Address &p_multi_address, String p_if_name);
|
||||
virtual Error join_multicast_group(const IPAddress &p_multi_address, String p_if_name);
|
||||
virtual Error leave_multicast_group(const IPAddress &p_multi_address, String p_if_name);
|
||||
|
||||
NetSocketPosix();
|
||||
~NetSocketPosix();
|
||||
|
@ -129,7 +129,7 @@ void OS_Unix::initialize_core() {
|
||||
|
||||
#ifndef NO_NETWORK
|
||||
NetSocketPosix::make_default();
|
||||
IP_Unix::make_default();
|
||||
IPUnix::make_default();
|
||||
#endif
|
||||
|
||||
_setup_clock();
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
class EditorDebuggerServerTCP : public EditorDebuggerServer {
|
||||
private:
|
||||
Ref<TCP_Server> server;
|
||||
Ref<TCPServer> server;
|
||||
|
||||
public:
|
||||
static EditorDebuggerServer *create(const String &p_protocol);
|
||||
|
@ -1138,14 +1138,14 @@ void EditorSettings::setup_language() {
|
||||
}
|
||||
|
||||
void EditorSettings::setup_network() {
|
||||
List<IP_Address> local_ip;
|
||||
List<IPAddress> local_ip;
|
||||
IP::get_singleton()->get_local_addresses(&local_ip);
|
||||
String hint;
|
||||
String current = has_setting("network/debug/remote_host") ? get("network/debug/remote_host") : "";
|
||||
String selected = "127.0.0.1";
|
||||
|
||||
// Check that current remote_host is a valid interface address and populate hints.
|
||||
for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) {
|
||||
for (List<IPAddress>::Element *E = local_ip.front(); E; E = E->next()) {
|
||||
String ip = E->get();
|
||||
|
||||
// link-local IPv6 addresses don't work, skipping them
|
||||
|
@ -54,7 +54,7 @@ class EditorFileServer : public Object {
|
||||
bool quit = false;
|
||||
};
|
||||
|
||||
Ref<TCP_Server> server;
|
||||
Ref<TCPServer> server;
|
||||
Set<Thread *> to_wait;
|
||||
|
||||
static void _close_client(ClientData *cd);
|
||||
|
@ -157,7 +157,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
|
||||
|
||||
_setup_compressor();
|
||||
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
if (p_address.is_valid_ip_address()) {
|
||||
ip = p_address;
|
||||
} else {
|
||||
@ -749,12 +749,12 @@ void NetworkedMultiplayerENet::enet_compressor_destroy(void *context) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const {
|
||||
ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IP_Address(), vformat("Peer ID %d not found in the list of peers.", p_peer_id));
|
||||
ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IP_Address(), "Can't get the address of peers other than the server (ID -1) when acting as a client.");
|
||||
ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
|
||||
IPAddress NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const {
|
||||
ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IPAddress(), vformat("Peer ID %d not found in the list of peers.", p_peer_id));
|
||||
ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IPAddress(), "Can't get the address of peers other than the server (ID -1) when acting as a client.");
|
||||
ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, IPAddress(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
|
||||
|
||||
IP_Address out;
|
||||
IPAddress out;
|
||||
#ifdef GODOT_ENET
|
||||
out.set_ipv6((uint8_t *)&(peer_map[p_peer_id]->address.host));
|
||||
#else
|
||||
@ -877,7 +877,7 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
|
||||
enet_compressor.decompress = enet_decompress;
|
||||
enet_compressor.destroy = enet_compressor_destroy;
|
||||
|
||||
bind_ip = IP_Address("*");
|
||||
bind_ip = IPAddress("*");
|
||||
}
|
||||
|
||||
NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
|
||||
@ -888,7 +888,7 @@ NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
|
||||
|
||||
// Sets IP for ENet to bind when using create_server or create_client
|
||||
// if no IP is set, then ENet bind to ENET_HOST_ANY
|
||||
void NetworkedMultiplayerENet::set_bind_ip(const IP_Address &p_ip) {
|
||||
void NetworkedMultiplayerENet::set_bind_ip(const IPAddress &p_ip) {
|
||||
ERR_FAIL_COND_MSG(!p_ip.is_valid() && !p_ip.is_wildcard(), vformat("Invalid bind IP address: %s", String(p_ip)));
|
||||
|
||||
bind_ip = p_ip;
|
||||
|
@ -108,7 +108,7 @@ private:
|
||||
static void enet_compressor_destroy(void *context);
|
||||
void _setup_compressor();
|
||||
|
||||
IP_Address bind_ip;
|
||||
IPAddress bind_ip;
|
||||
|
||||
bool dtls_enabled = false;
|
||||
Ref<CryptoKey> dtls_key;
|
||||
@ -125,7 +125,7 @@ public:
|
||||
|
||||
virtual int get_packet_peer() const override;
|
||||
|
||||
virtual IP_Address get_peer_address(int p_peer_id) const;
|
||||
virtual IPAddress get_peer_address(int p_peer_id) const;
|
||||
virtual int get_peer_port(int p_peer_id) const;
|
||||
virtual int get_local_port() const;
|
||||
void set_peer_timeout(int p_peer_id, int p_timeout_limit, int p_timeout_min, int p_timeout_max);
|
||||
@ -171,7 +171,7 @@ public:
|
||||
NetworkedMultiplayerENet();
|
||||
~NetworkedMultiplayerENet();
|
||||
|
||||
void set_bind_ip(const IP_Address &p_ip);
|
||||
void set_bind_ip(const IPAddress &p_ip);
|
||||
void set_dtls_enabled(bool p_enabled);
|
||||
bool is_dtls_enabled() const;
|
||||
void set_dtls_verify_enabled(bool p_enabled);
|
||||
|
@ -255,7 +255,7 @@ void GDScriptLanguageProtocol::poll() {
|
||||
}
|
||||
}
|
||||
|
||||
Error GDScriptLanguageProtocol::start(int p_port, const IP_Address &p_bind_ip) {
|
||||
Error GDScriptLanguageProtocol::start(int p_port, const IPAddress &p_bind_ip) {
|
||||
return server->listen(p_port, p_bind_ip);
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
static GDScriptLanguageProtocol *singleton;
|
||||
|
||||
HashMap<int, Ref<LSPeer>> clients;
|
||||
Ref<TCP_Server> server;
|
||||
Ref<TCPServer> server;
|
||||
int latest_client_id = 0;
|
||||
int next_client_id = 0;
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
_FORCE_INLINE_ bool is_initialized() const { return _initialized; }
|
||||
|
||||
void poll();
|
||||
Error start(int p_port, const IP_Address &p_bind_ip);
|
||||
Error start(int p_port, const IPAddress &p_bind_ip);
|
||||
void stop();
|
||||
|
||||
void notify_client(const String &p_method, const Variant &p_params = Variant(), int p_client_id = -1);
|
||||
|
@ -78,7 +78,7 @@ void GDScriptLanguageServer::thread_main(void *p_userdata) {
|
||||
void GDScriptLanguageServer::start() {
|
||||
port = (int)_EDITOR_GET("network/language_server/remote_port");
|
||||
use_thread = (bool)_EDITOR_GET("network/language_server/use_thread");
|
||||
if (protocol.start(port, IP_Address("127.0.0.1")) == OK) {
|
||||
if (protocol.start(port, IPAddress("127.0.0.1")) == OK) {
|
||||
EditorNode::get_log()->add_message("--- GDScript language server started ---", EditorLog::MSG_TYPE_EDITOR);
|
||||
if (use_thread) {
|
||||
thread_running = true;
|
||||
|
@ -87,7 +87,7 @@ void PacketPeerMbedDTLS::_cleanup() {
|
||||
int PacketPeerMbedDTLS::_set_cookie() {
|
||||
// Setup DTLS session cookie for this client
|
||||
uint8_t client_id[18];
|
||||
IP_Address addr = base->get_packet_address();
|
||||
IPAddress addr = base->get_packet_address();
|
||||
uint16_t port = base->get_packet_port();
|
||||
memcpy(client_id, addr.get_ipv6(), 16);
|
||||
memcpy(&client_id[16], (uint8_t *)&port, 2);
|
||||
|
@ -121,8 +121,8 @@ void EMWSClient::disconnect_from_host(int p_code, String p_reason) {
|
||||
_peer->close(p_code, p_reason);
|
||||
}
|
||||
|
||||
IP_Address EMWSClient::get_connected_host() const {
|
||||
ERR_FAIL_V_MSG(IP_Address(), "Not supported in HTML5 export.");
|
||||
IPAddress EMWSClient::get_connected_host() const {
|
||||
ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export.");
|
||||
}
|
||||
|
||||
uint16_t EMWSClient::get_connected_port() const {
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocol = Vector<String>(), const Vector<String> p_custom_headers = Vector<String>());
|
||||
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
|
||||
void disconnect_from_host(int p_code = 1000, String p_reason = "");
|
||||
IP_Address get_connected_host() const;
|
||||
IPAddress get_connected_host() const;
|
||||
uint16_t get_connected_port() const;
|
||||
virtual ConnectionStatus get_connection_status() const;
|
||||
int get_max_packet_size() const;
|
||||
|
@ -93,8 +93,8 @@ void EMWSPeer::close(int p_code, String p_reason) {
|
||||
peer_sock = -1;
|
||||
};
|
||||
|
||||
IP_Address EMWSPeer::get_connected_host() const {
|
||||
ERR_FAIL_V_MSG(IP_Address(), "Not supported in HTML5 export.");
|
||||
IPAddress EMWSPeer::get_connected_host() const {
|
||||
ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export.");
|
||||
};
|
||||
|
||||
uint16_t EMWSPeer::get_connected_port() const {
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
|
||||
virtual void close(int p_code = 1000, String p_reason = "");
|
||||
virtual bool is_connected_to_host() const;
|
||||
virtual IP_Address get_connected_host() const;
|
||||
virtual IPAddress get_connected_host() const;
|
||||
virtual uint16_t get_connected_port() const;
|
||||
|
||||
virtual WriteMode get_write_mode() const;
|
||||
|
@ -58,8 +58,8 @@ Vector<String> EMWSServer::get_protocols() const {
|
||||
return out;
|
||||
}
|
||||
|
||||
IP_Address EMWSServer::get_peer_address(int p_peer_id) const {
|
||||
return IP_Address();
|
||||
IPAddress EMWSServer::get_peer_address(int p_peer_id) const {
|
||||
return IPAddress();
|
||||
}
|
||||
|
||||
int EMWSServer::get_peer_port(int p_peer_id) const {
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
bool is_listening() const;
|
||||
bool has_peer(int p_id) const;
|
||||
Ref<WebSocketPeer> get_peer(int p_id) const;
|
||||
IP_Address get_peer_address(int p_peer_id) const;
|
||||
IPAddress get_peer_address(int p_peer_id) const;
|
||||
int get_peer_port(int p_peer_id) const;
|
||||
void disconnect_peer(int p_peer_id, int p_code = 1000, String p_reason = "");
|
||||
int get_max_packet_size() const;
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
virtual Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocol = Vector<String>(), const Vector<String> p_custom_headers = Vector<String>()) = 0;
|
||||
virtual void disconnect_from_host(int p_code = 1000, String p_reason = "") = 0;
|
||||
virtual IP_Address get_connected_host() const = 0;
|
||||
virtual IPAddress get_connected_host() const = 0;
|
||||
virtual uint16_t get_connected_port() const = 0;
|
||||
|
||||
virtual bool is_server() const override;
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
virtual void close(int p_code = 1000, String p_reason = "") = 0;
|
||||
|
||||
virtual bool is_connected_to_host() const = 0;
|
||||
virtual IP_Address get_connected_host() const = 0;
|
||||
virtual IPAddress get_connected_host() const = 0;
|
||||
virtual uint16_t get_connected_port() const = 0;
|
||||
virtual bool was_string_packet() const = 0;
|
||||
virtual void set_no_delay(bool p_enabled) = 0;
|
||||
|
@ -34,7 +34,7 @@ GDCINULL(WebSocketServer);
|
||||
|
||||
WebSocketServer::WebSocketServer() {
|
||||
_peer_id = 1;
|
||||
bind_ip = IP_Address("*");
|
||||
bind_ip = IPAddress("*");
|
||||
}
|
||||
|
||||
WebSocketServer::~WebSocketServer() {
|
||||
@ -71,11 +71,11 @@ void WebSocketServer::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("data_received", PropertyInfo(Variant::INT, "id")));
|
||||
}
|
||||
|
||||
IP_Address WebSocketServer::get_bind_ip() const {
|
||||
IPAddress WebSocketServer::get_bind_ip() const {
|
||||
return bind_ip;
|
||||
}
|
||||
|
||||
void WebSocketServer::set_bind_ip(const IP_Address &p_bind_ip) {
|
||||
void WebSocketServer::set_bind_ip(const IPAddress &p_bind_ip) {
|
||||
ERR_FAIL_COND(is_listening());
|
||||
ERR_FAIL_COND(!p_bind_ip.is_valid() && !p_bind_ip.is_wildcard());
|
||||
bind_ip = p_bind_ip;
|
||||
|
@ -40,7 +40,7 @@ class WebSocketServer : public WebSocketMultiplayerPeer {
|
||||
GDCLASS(WebSocketServer, WebSocketMultiplayerPeer);
|
||||
GDCICLASS(WebSocketServer);
|
||||
|
||||
IP_Address bind_ip;
|
||||
IPAddress bind_ip;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -57,7 +57,7 @@ public:
|
||||
virtual bool is_server() const override;
|
||||
ConnectionStatus get_connection_status() const override;
|
||||
|
||||
virtual IP_Address get_peer_address(int p_peer_id) const = 0;
|
||||
virtual IPAddress get_peer_address(int p_peer_id) const = 0;
|
||||
virtual int get_peer_port(int p_peer_id) const = 0;
|
||||
virtual void disconnect_peer(int p_peer_id, int p_code = 1000, String p_reason = "") = 0;
|
||||
|
||||
@ -66,8 +66,8 @@ public:
|
||||
void _on_disconnect(int32_t p_peer_id, bool p_was_clean);
|
||||
void _on_close_request(int32_t p_peer_id, int p_code, String p_reason);
|
||||
|
||||
IP_Address get_bind_ip() const;
|
||||
void set_bind_ip(const IP_Address &p_bind_ip);
|
||||
IPAddress get_bind_ip() const;
|
||||
void set_bind_ip(const IPAddress &p_bind_ip);
|
||||
|
||||
Ref<CryptoKey> get_private_key() const;
|
||||
void set_private_key(Ref<CryptoKey> p_key);
|
||||
|
@ -160,7 +160,7 @@ Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
|
||||
ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE);
|
||||
|
||||
_peer = Ref<WSLPeer>(memnew(WSLPeer));
|
||||
IP_Address addr;
|
||||
IPAddress addr;
|
||||
|
||||
if (!p_host.is_valid_ip_address()) {
|
||||
addr = IP::get_singleton()->resolve_hostname(p_host);
|
||||
@ -316,8 +316,8 @@ void WSLClient::disconnect_from_host(int p_code, String p_reason) {
|
||||
_resp_pos = 0;
|
||||
}
|
||||
|
||||
IP_Address WSLClient::get_connected_host() const {
|
||||
ERR_FAIL_COND_V(!_peer->is_connected_to_host(), IP_Address());
|
||||
IPAddress WSLClient::get_connected_host() const {
|
||||
ERR_FAIL_COND_V(!_peer->is_connected_to_host(), IPAddress());
|
||||
return _peer->get_connected_host();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
int get_max_packet_size() const;
|
||||
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
|
||||
void disconnect_from_host(int p_code = 1000, String p_reason = "");
|
||||
IP_Address get_connected_host() const;
|
||||
IPAddress get_connected_host() const;
|
||||
uint16_t get_connected_port() const;
|
||||
virtual ConnectionStatus get_connection_status() const;
|
||||
virtual void poll();
|
||||
|
@ -305,8 +305,8 @@ void WSLPeer::close(int p_code, String p_reason) {
|
||||
_packet_buffer.resize(0);
|
||||
}
|
||||
|
||||
IP_Address WSLPeer::get_connected_host() const {
|
||||
ERR_FAIL_COND_V(!is_connected_to_host() || _data->tcp.is_null(), IP_Address());
|
||||
IPAddress WSLPeer::get_connected_host() const {
|
||||
ERR_FAIL_COND_V(!is_connected_to_host() || _data->tcp.is_null(), IPAddress());
|
||||
|
||||
return _data->tcp->get_connected_host();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
virtual void close_now();
|
||||
virtual void close(int p_code = 1000, String p_reason = "");
|
||||
virtual bool is_connected_to_host() const;
|
||||
virtual IP_Address get_connected_host() const;
|
||||
virtual IPAddress get_connected_host() const;
|
||||
virtual uint16_t get_connected_port() const;
|
||||
|
||||
virtual WriteMode get_write_mode() const;
|
||||
|
@ -272,8 +272,8 @@ Ref<WebSocketPeer> WSLServer::get_peer(int p_id) const {
|
||||
return _peer_map[p_id];
|
||||
}
|
||||
|
||||
IP_Address WSLServer::get_peer_address(int p_peer_id) const {
|
||||
ERR_FAIL_COND_V(!has_peer(p_peer_id), IP_Address());
|
||||
IPAddress WSLServer::get_peer_address(int p_peer_id) const {
|
||||
ERR_FAIL_COND_V(!has_peer(p_peer_id), IPAddress());
|
||||
|
||||
return _peer_map[p_peer_id]->get_connected_host();
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ private:
|
||||
int _out_pkt_size = DEF_PKT_SHIFT;
|
||||
|
||||
List<Ref<PendingPeer>> _pending;
|
||||
Ref<TCP_Server> _server;
|
||||
Ref<TCPServer> _server;
|
||||
Vector<String> _protocols;
|
||||
|
||||
public:
|
||||
@ -84,7 +84,7 @@ public:
|
||||
int get_max_packet_size() const;
|
||||
bool has_peer(int p_id) const;
|
||||
Ref<WebSocketPeer> get_peer(int p_id) const;
|
||||
IP_Address get_peer_address(int p_peer_id) const;
|
||||
IPAddress get_peer_address(int p_peer_id) const;
|
||||
int get_peer_port(int p_peer_id) const;
|
||||
void disconnect_peer(int p_peer_id, int p_code = 1000, String p_reason = "");
|
||||
virtual void poll();
|
||||
|
@ -103,7 +103,7 @@ Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error NetSocketAndroid::join_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
|
||||
Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name);
|
||||
if (err != OK)
|
||||
return err;
|
||||
@ -115,7 +115,7 @@ Error NetSocketAndroid::join_multicast_group(const IP_Address &p_multi_address,
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error NetSocketAndroid::leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
|
||||
Error NetSocketAndroid::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name);
|
||||
if (err != OK)
|
||||
return err;
|
||||
|
@ -67,8 +67,8 @@ public:
|
||||
virtual void close();
|
||||
|
||||
virtual Error set_broadcasting_enabled(bool p_enabled);
|
||||
virtual Error join_multicast_group(const IP_Address &p_multi_address, String p_if_name);
|
||||
virtual Error leave_multicast_group(const IP_Address &p_multi_address, String p_if_name);
|
||||
virtual Error join_multicast_group(const IPAddress &p_multi_address, String p_if_name);
|
||||
virtual Error leave_multicast_group(const IPAddress &p_multi_address, String p_if_name);
|
||||
|
||||
NetSocketAndroid() {}
|
||||
~NetSocketAndroid();
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
class EditorHTTPServer : public Reference {
|
||||
private:
|
||||
Ref<TCP_Server> server;
|
||||
Ref<TCPServer> server;
|
||||
Map<String, String> mimes;
|
||||
Ref<StreamPeerTCP> tcp;
|
||||
Ref<StreamPeerSSL> ssl;
|
||||
@ -100,7 +100,7 @@ public:
|
||||
_clear_client();
|
||||
}
|
||||
|
||||
Error listen(int p_port, IP_Address p_address, bool p_use_ssl, String p_ssl_key, String p_ssl_cert) {
|
||||
Error listen(int p_port, IPAddress p_address, bool p_use_ssl, String p_ssl_key, String p_ssl_cert) {
|
||||
use_ssl = p_use_ssl;
|
||||
if (use_ssl) {
|
||||
Ref<Crypto> crypto = Crypto::create();
|
||||
@ -919,7 +919,7 @@ Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_prese
|
||||
const uint16_t bind_port = EDITOR_GET("export/web/http_port");
|
||||
// Resolve host if needed.
|
||||
const String bind_host = EDITOR_GET("export/web/http_host");
|
||||
IP_Address bind_ip;
|
||||
IPAddress bind_ip;
|
||||
if (bind_host.is_valid_ip_address()) {
|
||||
bind_ip = bind_host;
|
||||
} else {
|
||||
|
@ -147,7 +147,7 @@ void OS_UWP::initialize_core() {
|
||||
ticks_start = 0;
|
||||
ticks_start = get_ticks_usec();
|
||||
|
||||
IP_Unix::make_default();
|
||||
IPUnix::make_default();
|
||||
|
||||
cursor_shape = CURSOR_ARROW;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ void OS_Windows::initialize() {
|
||||
current_pi.pi.hProcess = GetCurrentProcess();
|
||||
process_map->insert(GetCurrentProcessId(), current_pi);
|
||||
|
||||
IP_Unix::make_default();
|
||||
IPUnix::make_default();
|
||||
main_loop = nullptr;
|
||||
}
|
||||
|
||||
|
@ -860,10 +860,10 @@ TEST_CASE("[String] match") {
|
||||
}
|
||||
|
||||
TEST_CASE("[String] IPVX address to string") {
|
||||
IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
IP_Address ip(0x0123, 0x4567, 0x89ab, 0xcdef, true);
|
||||
IP_Address ip2("fe80::52e5:49ff:fe93:1baf");
|
||||
IP_Address ip3("::ffff:192.168.0.1");
|
||||
IPAddress ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
IPAddress ip(0x0123, 0x4567, 0x89ab, 0xcdef, true);
|
||||
IPAddress ip2("fe80::52e5:49ff:fe93:1baf");
|
||||
IPAddress ip3("::ffff:192.168.0.1");
|
||||
String ip4 = "192.168.0.1";
|
||||
CHECK(ip4.is_valid_ip_address());
|
||||
|
||||
|
52
thirdparty/enet/godot.cpp
vendored
52
thirdparty/enet/godot.cpp
vendored
@ -45,10 +45,10 @@
|
||||
/// Abstract ENet interface for UDP/DTLS.
|
||||
class ENetGodotSocket {
|
||||
public:
|
||||
virtual Error bind(IP_Address p_ip, uint16_t p_port) = 0;
|
||||
virtual Error get_socket_address(IP_Address *r_ip, uint16_t *r_port) = 0;
|
||||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0;
|
||||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0;
|
||||
virtual Error bind(IPAddress p_ip, uint16_t p_port) = 0;
|
||||
virtual Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) = 0;
|
||||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) = 0;
|
||||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port) = 0;
|
||||
virtual int set_option(ENetSocketOption p_option, int p_value) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void set_refuse_new_connections(bool p_enable) {} /* Only used by dtls server */
|
||||
@ -65,7 +65,7 @@ class ENetUDP : public ENetGodotSocket {
|
||||
|
||||
private:
|
||||
Ref<NetSocket> sock;
|
||||
IP_Address local_address;
|
||||
IPAddress local_address;
|
||||
bool bound = false;
|
||||
|
||||
public:
|
||||
@ -79,21 +79,21 @@ public:
|
||||
sock->close();
|
||||
}
|
||||
|
||||
Error bind(IP_Address p_ip, uint16_t p_port) {
|
||||
Error bind(IPAddress p_ip, uint16_t p_port) {
|
||||
local_address = p_ip;
|
||||
bound = true;
|
||||
return sock->bind(p_ip, p_port);
|
||||
}
|
||||
|
||||
Error get_socket_address(IP_Address *r_ip, uint16_t *r_port) {
|
||||
Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) {
|
||||
return sock->get_socket_address(r_ip, r_port);
|
||||
}
|
||||
|
||||
Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) {
|
||||
Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) {
|
||||
return sock->sendto(p_buffer, p_len, r_sent, p_ip, p_port);
|
||||
}
|
||||
|
||||
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) {
|
||||
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port) {
|
||||
Error err = sock->poll(NetSocket::POLL_TYPE_IN, 0);
|
||||
if (err != OK) {
|
||||
return err;
|
||||
@ -157,7 +157,7 @@ class ENetDTLSClient : public ENetGodotSocket {
|
||||
bool verify = false;
|
||||
String for_hostname;
|
||||
Ref<X509Certificate> cert;
|
||||
IP_Address local_address;
|
||||
IPAddress local_address;
|
||||
|
||||
public:
|
||||
ENetDTLSClient(ENetUDP *p_base, Ref<X509Certificate> p_cert, bool p_verify, String p_for_hostname) {
|
||||
@ -178,12 +178,12 @@ public:
|
||||
close();
|
||||
}
|
||||
|
||||
Error bind(IP_Address p_ip, uint16_t p_port) {
|
||||
Error bind(IPAddress p_ip, uint16_t p_port) {
|
||||
local_address = p_ip;
|
||||
return udp->bind(p_port, p_ip);
|
||||
}
|
||||
|
||||
Error get_socket_address(IP_Address *r_ip, uint16_t *r_port) {
|
||||
Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) {
|
||||
if (!udp->is_bound()) {
|
||||
return ERR_UNCONFIGURED;
|
||||
}
|
||||
@ -192,7 +192,7 @@ public:
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) {
|
||||
Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) {
|
||||
if (!connected) {
|
||||
udp->connect_to_host(p_ip, p_port);
|
||||
dtls->connect_to_peer(udp, verify, for_hostname, cert);
|
||||
@ -208,7 +208,7 @@ public:
|
||||
return dtls->put_packet(p_buffer, p_len);
|
||||
}
|
||||
|
||||
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) {
|
||||
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port) {
|
||||
dtls->poll();
|
||||
if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) {
|
||||
return ERR_BUSY;
|
||||
@ -250,7 +250,7 @@ class ENetDTLSServer : public ENetGodotSocket {
|
||||
Ref<UDPServer> udp_server;
|
||||
Map<String, Ref<PacketPeerDTLS>> peers;
|
||||
int last_service = 0;
|
||||
IP_Address local_address;
|
||||
IPAddress local_address;
|
||||
|
||||
public:
|
||||
ENetDTLSServer(ENetUDP *p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert) {
|
||||
@ -273,12 +273,12 @@ public:
|
||||
udp_server->set_max_pending_connections(p_refuse ? 0 : 16);
|
||||
}
|
||||
|
||||
Error bind(IP_Address p_ip, uint16_t p_port) {
|
||||
Error bind(IPAddress p_ip, uint16_t p_port) {
|
||||
local_address = p_ip;
|
||||
return udp_server->listen(p_port, p_ip);
|
||||
}
|
||||
|
||||
Error get_socket_address(IP_Address *r_ip, uint16_t *r_port) {
|
||||
Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) {
|
||||
if (!udp_server->is_listening()) {
|
||||
return ERR_UNCONFIGURED;
|
||||
}
|
||||
@ -287,7 +287,7 @@ public:
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) {
|
||||
Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) {
|
||||
String key = String(p_ip) + ":" + itos(p_port);
|
||||
ERR_FAIL_COND_V(!peers.has(key), ERR_UNAVAILABLE);
|
||||
Ref<PacketPeerDTLS> peer = peers[key];
|
||||
@ -302,12 +302,12 @@ public:
|
||||
return err;
|
||||
}
|
||||
|
||||
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) {
|
||||
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IPAddress &r_ip, uint16_t &r_port) {
|
||||
udp_server->poll();
|
||||
// TODO limits? Maybe we can better enforce allowed connections!
|
||||
if (udp_server->is_connection_available()) {
|
||||
Ref<PacketPeerUDP> udp = udp_server->take_connection();
|
||||
IP_Address peer_ip = udp->get_packet_address();
|
||||
IPAddress peer_ip = udp->get_packet_address();
|
||||
int peer_port = udp->get_packet_port();
|
||||
Ref<PacketPeerDTLS> peer = server->take_connection(udp);
|
||||
PacketPeerDTLS::Status status = peer->get_status();
|
||||
@ -397,7 +397,7 @@ void enet_time_set(enet_uint32 newTimeBase) {
|
||||
}
|
||||
|
||||
int enet_address_set_host(ENetAddress *address, const char *name) {
|
||||
IP_Address ip = IP::get_singleton()->resolve_hostname(name);
|
||||
IPAddress ip = IP::get_singleton()->resolve_hostname(name);
|
||||
ERR_FAIL_COND_V(!ip.is_valid(), -1);
|
||||
|
||||
enet_address_set_ip(address, ip.get_ipv6(), 16);
|
||||
@ -442,9 +442,9 @@ void enet_host_refuse_new_connections(ENetHost *host, int p_refuse) {
|
||||
}
|
||||
|
||||
int enet_socket_bind(ENetSocket socket, const ENetAddress *address) {
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
if (address->wildcard) {
|
||||
ip = IP_Address("*");
|
||||
ip = IPAddress("*");
|
||||
} else {
|
||||
ip.set_ipv6(address->host);
|
||||
}
|
||||
@ -466,7 +466,7 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu
|
||||
ERR_FAIL_COND_V(address == nullptr, -1);
|
||||
|
||||
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
|
||||
IP_Address dest;
|
||||
IPAddress dest;
|
||||
Error err;
|
||||
size_t i = 0;
|
||||
|
||||
@ -508,7 +508,7 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf
|
||||
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
|
||||
|
||||
int read;
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
|
||||
Error err = sock->recvfrom((uint8_t *)buffers[0].data, buffers[0].dataLength, read, ip, address->port);
|
||||
if (err == ERR_BUSY) {
|
||||
@ -525,7 +525,7 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf
|
||||
}
|
||||
|
||||
int enet_socket_get_address (ENetSocket socket, ENetAddress * address) {
|
||||
IP_Address ip;
|
||||
IPAddress ip;
|
||||
uint16_t port;
|
||||
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user