1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Infer ipv6_server from bind_address; fix client connect to IN(6)ADDR_ANY

This commit is contained in:
Kahrl 2014-03-07 01:00:03 +01:00 committed by sapier
parent edcad09dee
commit 6090e95cdc
7 changed files with 88 additions and 47 deletions

View file

@ -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")) {