From 85fe75d1cbaf372f0a98558adcd5a612a0e19602 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Wed, 5 Feb 2014 21:24:46 +0100 Subject: Add the option to bind to a specific address --- src/game.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 56519d30a..b540e3314 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -909,8 +909,8 @@ bool nodePlacementPrediction(Client &client, // Dont place node when player would be inside new node // NOTE: This is to be eventually implemented by a mod as client-side Lua - if (!nodedef->get(n).walkable || - (client.checkPrivilege("noclip") && g_settings->getBool("noclip")) || + if (!nodedef->get(n).walkable || + (client.checkPrivilege("noclip") && g_settings->getBool("noclip")) || (nodedef->get(n).walkable && neighbourpos != player->getStandingNodePos() + v3s16(0,1,0) && neighbourpos != player->getStandingNodePos() + v3s16(0,2,0))) { @@ -1029,7 +1029,27 @@ void the_game( infostream<<"Creating server"<start(port); + + std::string bind_str = g_settings->get("bind_address"); + Address bind_addr(0,0,0,0, port); + + if (bind_str != "") + { + try { + bind_addr.Resolve(bind_str.c_str()); + address = bind_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); + } + } + } + + server->start(bind_addr); } do{ // Client scope (breakable do-while(0)) -- cgit v1.2.3