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:
parent
7f743178db
commit
85fe75d1cb
12 changed files with 118 additions and 40 deletions
17
src/main.cpp
17
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue