summaryrefslogtreecommitdiff
path: root/src/main.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/main.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/main.cpp')
-rw-r--r--src/main.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 8186e26c8..b5de4b93f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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);