summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-02-05 21:24:46 +0100
committersapier <Sapier at GMX dot net>2014-02-05 21:24:46 +0100
commit85fe75d1cbaf372f0a98558adcd5a612a0e19602 (patch)
tree8a552ca0e7bb69b192568037bb2857501abe0674 /src/game.cpp
parent7f743178db2a45bd3f68ef2c9c7df6deca1f3ab6 (diff)
downloadminetest-85fe75d1cbaf372f0a98558adcd5a612a0e19602.tar.gz
minetest-85fe75d1cbaf372f0a98558adcd5a612a0e19602.tar.bz2
minetest-85fe75d1cbaf372f0a98558adcd5a612a0e19602.zip
Add the option to bind to a specific address
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp26
1 files changed, 23 insertions, 3 deletions
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"<<std::endl;
server = new Server(map_dir, gamespec,
simple_singleplayer_mode);
- 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))