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

Add the option to bind to a specific address

This commit is contained in:
ShadowNinja 2014-02-05 21:24:46 +01:00 committed by sapier
parent 7f743178db
commit 85fe75d1cb
12 changed files with 118 additions and 40 deletions

View file

@ -1024,6 +1024,21 @@ 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"))
@ -1270,7 +1285,7 @@ int main(int argc, char *argv[])
return 0;
}
server.start(port);
server.start(bind_addr);
// Run server
dedicated_server_loop(server, kill);