1313#include < unordered_map>
1414#include < unordered_set>
1515
16+ #include < folly/SocketAddress.h>
1617#include < folly/String.h>
1718
1819namespace openmoq ::moqx::config {
@@ -169,6 +170,28 @@ std::string makeCompositeKey(
169170
170171// --- Listener validation ---
171172
173+ // Validate a bind address so an empty or unresolvable value fails as a clean
174+ // config error rather than letting folly::SocketAddress throw uncaught at
175+ // resolution time, which aborts the process (#459). Literal IPs cost nothing;
176+ // a hostname is resolved once here.
177+ void validateBindAddress (
178+ const std::string& address,
179+ uint16_t port,
180+ const std::string& context,
181+ std::vector<std::string>& errors
182+ ) {
183+ if (address.empty ()) {
184+ errors.push_back (context + " : address must be non-empty" );
185+ return ;
186+ }
187+ try {
188+ folly::SocketAddress probe (address, port);
189+ (void )probe;
190+ } catch (const std::exception& e) {
191+ errors.push_back (context + " : invalid bind address '" + address + " ': " + e.what ());
192+ }
193+ }
194+
172195void validateListener (
173196 const ParsedListenerConfig& listener,
174197 std::vector<std::string>& errors,
@@ -178,6 +201,12 @@ void validateListener(
178201 if (sock.port .value () == 0 ) {
179202 errors.push_back (" Listener '" + listener.name .value () + " ' port must be 1-65535, got 0" );
180203 }
204+ validateBindAddress (
205+ sock.address .value (),
206+ sock.port .value (),
207+ " Listener '" + listener.name .value () + " '" ,
208+ errors
209+ );
181210
182211 // TLS validation
183212 validateListenerTlsConfig (
@@ -212,6 +241,12 @@ void validateAdmin(const ParsedConfig& config, std::vector<std::string>& errors)
212241 if (adminOptional->port .value () == 0 ) {
213242 errors.push_back (" admin.port must be 1-65535, got 0" );
214243 }
244+ validateBindAddress (
245+ adminOptional->address .value (),
246+ adminOptional->port .value (),
247+ " admin" ,
248+ errors
249+ );
215250 bool hasTls = adminOptional->tls .value ().has_value ();
216251 bool hasPlaintext = adminOptional->plaintext .value ();
217252 if (hasTls && hasPlaintext) {
0 commit comments