@@ -1301,30 +1301,33 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13011301 }
13021302 }
13031303
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 }
13161317 }) {
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)) {
13181321 std::string host_out;
13191322 uint16_t port_out{0 };
13201323 if (!SplitHostPort (socket_addr, port_out, host_out)) {
13211324#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));
13251328 }
13261329#else
1327- return InitError (InvalidPortErrMsg (port_option , socket_addr));
1330+ return InitError (InvalidPortErrMsg (arg , socket_addr));
13281331#endif
13291332 }
13301333 }
0 commit comments