Merge pull request #8699 from Faless/ipv6_disabled

Fix Editor/Debugger connection problems.
This commit is contained in:
Rémi Verschelde 2017-05-12 18:19:24 +02:00 committed by GitHub
commit 5e318493d1
6 changed files with 35 additions and 16 deletions

View File

@ -77,7 +77,7 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
if (p_addr->sa_family == AF_INET) {
struct sockaddr_in *addr = (struct sockaddr_in *)p_addr;
ip.set_ipv4((uint8_t *)&(addr->sin_addr));
} else {
} else if (p_addr->sa_family == AF_INET6) {
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr;
ip.set_ipv6(addr6->sin6_addr.s6_addr);
};
@ -180,15 +180,16 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const {
SOCKADDR_IN *ipv4 = reinterpret_cast<SOCKADDR_IN *>(address->Address.lpSockaddr);
ip.set_ipv4((uint8_t *)&(ipv4->sin_addr));
} else { // ipv6
r_addresses->push_back(ip);
} else if (address->Address.lpSockaddr->sa_family == AF_INET6) { // ipv6
SOCKADDR_IN6 *ipv6 = reinterpret_cast<SOCKADDR_IN6 *>(address->Address.lpSockaddr);
ip.set_ipv6(ipv6->sin6_addr.s6_addr);
r_addresses->push_back(ip);
};
r_addresses->push_back(ip);
address = address->Next;
};
adapter = adapter->Next;
@ -205,6 +206,7 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const {
struct ifaddrs *ifAddrStruct = NULL;
struct ifaddrs *ifa = NULL;
int family;
getifaddrs(&ifAddrStruct);
@ -212,6 +214,11 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const {
if (!ifa->ifa_addr)
continue;
family = ifa->ifa_addr->sa_family;
if (family != AF_INET && family != AF_INET6)
continue;
IP_Address ip = _sockaddr2ip(ifa->ifa_addr);
r_addresses->push_back(ip);
}

View File

@ -100,13 +100,21 @@ static size_t _set_listen_sockaddr(struct sockaddr_storage *p_addr, int p_port,
};
};
static int _socket_create(IP::Type p_type, int type, int protocol) {
static int _socket_create(IP::Type &p_type, int type, int protocol) {
ERR_FAIL_COND_V(p_type > IP::TYPE_ANY || p_type < IP::TYPE_NONE, ERR_INVALID_PARAMETER);
int family = p_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6;
int sockfd = socket(family, type, protocol);
if (sockfd == -1 && p_type == IP::TYPE_ANY) {
// Careful here, changing the referenced parameter so the caller knows that we are using an IPv4 socket
// in place of a dual stack one, and further calls to _set_sock_addr will work as expected.
p_type = IP::TYPE_IPV4;
family = AF_INET;
sockfd = socket(family, type, protocol);
}
ERR_FAIL_COND_V(sockfd == -1, -1);
if (family == AF_INET6) {

View File

@ -210,7 +210,7 @@ EditorExportPreset::EditorExportPreset() {
void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) {
String host = EditorSettings::get_singleton()->get("network/debug_host");
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
host = "localhost";
@ -620,7 +620,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co
void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) {
String host = EditorSettings::get_singleton()->get("network/debug_host");
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
host = "localhost";
@ -2108,7 +2108,7 @@ static int _get_pad(int p_alignment, int p_n) {
void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) {
String host = EditorSettings::get_singleton()->get("network/debug_host");
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
if (p_flags&EXPORT_REMOTE_DEBUG_LOCALHOST)
host="localhost";

View File

@ -41,6 +41,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
List<String> args;
String resource_path = GlobalConfig::get_singleton()->get_resource_path();
String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
if (resource_path != "") {
args.push_back("-path");
@ -49,7 +50,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
if (true) {
args.push_back("-rdebug");
args.push_back("localhost:" + String::num(GLOBAL_GET("network/debug/remote_port")));
args.push_back(remote_host + ":" + String::num(GLOBAL_GET("network/debug/remote_port")));
}
args.push_back("-epid");

View File

@ -407,13 +407,12 @@ void EditorSettings::setup_network() {
IP::get_singleton()->get_local_addresses(&local_ip);
String lip;
String hint;
String current = has("network/debug_host") ? get("network/debug_host") : "";
String current = has("network/debug/remote_host") ? get("network/debug/remote_host") : "";
int port = has("network/debug/remote_port") ? (int)get("network/debug/remote_port") : 6007;
for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) {
String ip = E->get();
if (ip == "127.0.0.1")
continue;
if (lip == "")
lip = ip;
@ -424,8 +423,11 @@ void EditorSettings::setup_network() {
hint += ip;
}
set("network/debug_host", lip);
add_property_hint(PropertyInfo(Variant::STRING, "network/debug_host", PROPERTY_HINT_ENUM, hint));
set("network/debug/remote_host", lip);
add_property_hint(PropertyInfo(Variant::STRING, "network/debug/remote_host", PROPERTY_HINT_ENUM, hint));
set("network/debug/remote_port", port);
add_property_hint(PropertyInfo(Variant::INT, "network/debug/remote_port", PROPERTY_HINT_RANGE, "1,65535,1"));
}
void EditorSettings::save() {

View File

@ -588,8 +588,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
ScriptDebuggerRemote *sdr = memnew(ScriptDebuggerRemote);
uint16_t debug_port = GLOBAL_GET("network/debug/remote_port");
if (debug_host.find(":") != -1) {
debug_port = debug_host.get_slicec(':', 1).to_int();
debug_host = debug_host.get_slicec(':', 0);
int sep_pos = debug_host.find_last(":");
debug_port = debug_host.substr(sep_pos + 1, debug_host.length()).to_int();
debug_host = debug_host.substr(0, sep_pos);
}
Error derr = sdr->connect_to_host(debug_host, debug_port);