diff --git a/config.ini b/config.ini index 5247d81..66fbbd1 100644 --- a/config.ini +++ b/config.ini @@ -102,5 +102,8 @@ eventmode=0 enabled=false # the port to listen for connections on port=8003 +# The local IP to listen on. +# Do not change this unless you know what you're doing. +listenip=127.0.0.1 # how often the listeners should be updated (in milliseconds) interval=5000 diff --git a/src/servers/Monitor.cpp b/src/servers/Monitor.cpp index 5a28719..687eab1 100644 --- a/src/servers/Monitor.cpp +++ b/src/servers/Monitor.cpp @@ -180,9 +180,14 @@ SOCKET Monitor::init() { } address.sin_family = AF_INET; - address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons(settings::MONITORPORT); + if (!inet_pton(AF_INET, settings::MONITORLISTENIP.c_str(), &address.sin_addr)) { + std::cout << "Failed to set monitor listen address" << std::endl; + printSocketError("inet_pton"); + exit(1); + } + if (SOCKETERROR(bind(listener, (struct sockaddr*)&address, sizeof(address)))) { std::cout << "Failed to bind to monitor port" << std::endl; printSocketError("bind"); @@ -206,7 +211,7 @@ SOCKET Monitor::init() { exit(EXIT_FAILURE); } - std::cout << "Monitor listening on *:" << settings::MONITORPORT << std::endl; + std::cout << "Monitor listening on " << settings::MONITORLISTENIP << ":" << settings::MONITORPORT << std::endl; REGISTER_SHARD_TIMER(tick, settings::MONITORINTERVAL); diff --git a/src/settings.cpp b/src/settings.cpp index 19c9b13..4445f8b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -64,6 +64,7 @@ bool settings::DISABLEFIRSTUSEFLAG = true; // monitor settings bool settings::MONITORENABLED = false; int settings::MONITORPORT = 8003; +std::string settings::MONITORLISTENIP = "127.0.0.1"; int settings::MONITORINTERVAL = 5000; // event mode settings @@ -121,5 +122,6 @@ void settings::init() { IZRACESCORECAPPED = reader.GetBoolean("shard", "izracescorecapped", IZRACESCORECAPPED); MONITORENABLED = reader.GetBoolean("monitor", "enabled", MONITORENABLED); MONITORPORT = reader.GetInteger("monitor", "port", MONITORPORT); + MONITORLISTENIP = reader.Get("monitor", "listenip", MONITORLISTENIP); MONITORINTERVAL = reader.GetInteger("monitor", "interval", MONITORINTERVAL); } diff --git a/src/settings.hpp b/src/settings.hpp index eb17c8d..2709932 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -38,6 +38,7 @@ namespace settings { extern int EVENTMODE; extern bool MONITORENABLED; extern int MONITORPORT; + extern std::string MONITORLISTENIP; extern int MONITORINTERVAL; extern bool DISABLEFIRSTUSEFLAG; extern bool IZRACESCORECAPPED;