diff options
author | Kahrl <kahrl@gmx.net> | 2014-03-07 01:00:03 +0100 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-04-10 22:03:42 +0200 |
commit | 6090e95cdcea7c0600ea75941289494505295cf2 (patch) | |
tree | 83745714b25e66fe087c8abdef08d18d5bcd8576 /src/main.cpp | |
parent | edcad09dee6daf119f3e29b0a63837500e7b8b85 (diff) | |
download | minetest-6090e95cdcea7c0600ea75941289494505295cf2.tar.gz minetest-6090e95cdcea7c0600ea75941289494505295cf2.tar.bz2 minetest-6090e95cdcea7c0600ea75941289494505295cf2.zip |
Infer ipv6_server from bind_address; fix client connect to IN(6)ADDR_ANY
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/main.cpp b/src/main.cpp index e52002772..baaf8ebde 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1023,21 +1023,6 @@ int main(int argc, char *argv[]) if(port == 0) port = 30000; - // Bind address - std::string bind_str = g_settings->get("bind_address"); - Address bind_addr(0,0,0,0, port); - try { - bind_addr.Resolve(bind_str.c_str()); - } catch (ResolveError &e) { - infostream << "Resolving bind address \"" << bind_str - << "\" failed: " << e.what() - << " -- Listening on all addresses." << std::endl; - - if (g_settings->getBool("ipv6_server")) { - bind_addr.setAddress((IPv6AddressBytes*) NULL); - } - } - // World directory std::string commanded_world = ""; if(cmd_args.exists("world")) @@ -1223,8 +1208,29 @@ int main(int argc, char *argv[]) } verbosestream<<_("Using gameid")<<" ["<<gamespec.id<<"]"<<std::endl; + // Bind address + std::string bind_str = g_settings->get("bind_address"); + Address bind_addr(0,0,0,0, port); + + if (g_settings->getBool("ipv6_server")) { + bind_addr.setAddress((IPv6AddressBytes*) NULL); + } + try { + bind_addr.Resolve(bind_str.c_str()); + } catch (ResolveError &e) { + infostream << "Resolving bind address \"" << bind_str + << "\" failed: " << e.what() + << " -- Listening on all addresses." << std::endl; + } + if(bind_addr.isIPv6() && !g_settings->getBool("enable_ipv6")) { + errorstream << "Unable to listen on " + << bind_addr.serializeString() + << L" because IPv6 is disabled" << std::endl; + return 1; + } + // Create server - Server server(world_path, gamespec, false); + Server server(world_path, gamespec, false, bind_addr.isIPv6()); // Database migration if (cmd_args.exists("migrate")) { |