@@ -1301,30 +1301,33 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1301
1301
}
1302
1302
}
1303
1303
1304
- for (const std::string port_option : {
1305
- " -i2psam" ,
1306
- " -onion" ,
1307
- " -proxy" ,
1308
- " -rpcbind" ,
1309
- " -torcontrol" ,
1310
- " -whitebind" ,
1311
- " -zmqpubhashblock" ,
1312
- " -zmqpubhashtx" ,
1313
- " -zmqpubrawblock" ,
1314
- " -zmqpubrawtx" ,
1315
- " -zmqpubsequence" ,
1304
+ for (const auto &port_option : std::vector<std::pair<std::string, bool >>{
1305
+ // arg name UNIX socket support
1306
+ {" -i2psam" , false },
1307
+ {" -onion" , true },
1308
+ {" -proxy" , true },
1309
+ {" -rpcbind" , false },
1310
+ {" -torcontrol" , false },
1311
+ {" -whitebind" , false },
1312
+ {" -zmqpubhashblock" , true },
1313
+ {" -zmqpubhashtx" , true },
1314
+ {" -zmqpubrawblock" , true },
1315
+ {" -zmqpubrawtx" , true },
1316
+ {" -zmqpubsequence" , true }
1316
1317
}) {
1317
- for (const std::string& socket_addr : args.GetArgs (port_option)) {
1318
+ const std::string arg{port_option.first };
1319
+ const bool unix{port_option.second };
1320
+ for (const std::string& socket_addr : args.GetArgs (arg)) {
1318
1321
std::string host_out;
1319
1322
uint16_t port_out{0 };
1320
1323
if (!SplitHostPort (socket_addr, port_out, host_out)) {
1321
1324
#if HAVE_SOCKADDR_UN
1322
- // Allow unix domain sockets for -proxy and -onion e.g. unix:/some/file/path
1323
- if ((port_option != " -proxy " && port_option != " -onion " ) || socket_addr.find (ADDR_PREFIX_UNIX) != 0 ) {
1324
- return InitError (InvalidPortErrMsg (port_option , socket_addr));
1325
+ // Allow unix domain sockets for some options e.g. unix:/some/file/path
1326
+ if (!unix || socket_addr.find (ADDR_PREFIX_UNIX) != 0 ) {
1327
+ return InitError (InvalidPortErrMsg (arg , socket_addr));
1325
1328
}
1326
1329
#else
1327
- return InitError (InvalidPortErrMsg (port_option , socket_addr));
1330
+ return InitError (InvalidPortErrMsg (arg , socket_addr));
1328
1331
#endif
1329
1332
}
1330
1333
}
0 commit comments