Skip to content

Commit 42cff0c

Browse files
authored
Merge pull request #387 from JohnnyLawDGB/fix/zmq-ipc-socket-validation
fix: restore ZMQ ipc:// Unix domain socket support
2 parents 425e91c + b0639cf commit 42cff0c

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/init.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,17 +1425,37 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14251425
"-rpcbind",
14261426
"-torcontrol",
14271427
"-whitebind",
1428+
}) {
1429+
for (const std::string& socket_addr : args.GetArgs(port_option)) {
1430+
std::string host_out;
1431+
uint16_t port_out{0};
1432+
if (!SplitHostPort(socket_addr, port_out, host_out)) {
1433+
return InitError(InvalidPortErrMsg(port_option, socket_addr));
1434+
}
1435+
}
1436+
}
1437+
1438+
// ZMQ options support both TCP (tcp://host:port) and Unix domain sockets
1439+
// (ipc:///path/to/socket). Skip port validation for ipc:// addresses since
1440+
// they use filesystem paths, not host:port format. This restores support
1441+
// that was inadvertently broken when port validation was added.
1442+
// See: https://github.com/DigiByte-Core/digibyte/issues/340
1443+
for (const std::string zmq_option : {
14281444
"-zmqpubhashblock",
14291445
"-zmqpubhashtx",
14301446
"-zmqpubrawblock",
14311447
"-zmqpubrawtx",
14321448
"-zmqpubsequence",
14331449
}) {
1434-
for (const std::string& socket_addr : args.GetArgs(port_option)) {
1450+
for (const std::string& socket_addr : args.GetArgs(zmq_option)) {
1451+
// libzmq natively supports ipc:// for Unix domain sockets
1452+
if (socket_addr.substr(0, 6) == "ipc://") {
1453+
continue;
1454+
}
14351455
std::string host_out;
14361456
uint16_t port_out{0};
14371457
if (!SplitHostPort(socket_addr, port_out, host_out)) {
1438-
return InitError(InvalidPortErrMsg(port_option, socket_addr));
1458+
return InitError(InvalidPortErrMsg(zmq_option, socket_addr));
14391459
}
14401460
}
14411461
}

0 commit comments

Comments
 (0)