|
29 | 29 | #include <init/common.h>
|
30 | 30 | #include <interfaces/chain.h>
|
31 | 31 | #include <interfaces/init.h>
|
| 32 | +#include <interfaces/ipc.h> |
32 | 33 | #include <interfaces/mining.h>
|
33 | 34 | #include <interfaces/node.h>
|
34 | 35 | #include <kernel/context.h>
|
@@ -441,7 +442,7 @@ static void OnRPCStopped()
|
441 | 442 | LogDebug(BCLog::RPC, "RPC stopped.\n");
|
442 | 443 | }
|
443 | 444 |
|
444 |
| -void SetupServerArgs(ArgsManager& argsman) |
| 445 | +void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc) |
445 | 446 | {
|
446 | 447 | SetupHelpOptions(argsman);
|
447 | 448 | argsman.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
|
@@ -676,6 +677,9 @@ void SetupServerArgs(ArgsManager& argsman)
|
676 | 677 | argsman.AddArg("-rpcwhitelistdefault", "Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault is set to 0, if any -rpcwhitelist is set, the rpc server acts as if all rpc users are subject to empty-unless-otherwise-specified whitelists. If rpcwhitelistdefault is set to 1 and no -rpcwhitelist is set, rpc server acts as if all rpc users are subject to empty whitelists.", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
|
677 | 678 | argsman.AddArg("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC);
|
678 | 679 | argsman.AddArg("-server", "Accept command line and JSON-RPC commands", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
|
| 680 | + if (can_listen_ipc) { |
| 681 | + argsman.AddArg("-ipcbind=<address>", "Bind to Unix socket address and listen for incoming connections. Valid address values are \"unix\" to listen on the default path, <datadir>/node.sock, or \"unix:/custom/path\" to specify a custom path. Can be specified multiple times to listen on multiple paths. Default behavior is not to listen on any path. If relative paths are specified, they are interpreted relative to the network data directory. If paths include any parent directory components and the parent directories do not exist, they will be created.", ArgsManager::ALLOW_ANY, OptionsCategory::IPC); |
| 682 | + } |
679 | 683 |
|
680 | 684 | #if HAVE_DECL_FORK
|
681 | 685 | argsman.AddArg("-daemon", strprintf("Run in the background as a daemon and accept commands (default: %d)", DEFAULT_DAEMON), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
@@ -1200,6 +1204,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
1200 | 1204 | g_wallet_init_interface.Construct(node);
|
1201 | 1205 | uiInterface.InitWallet();
|
1202 | 1206 |
|
| 1207 | + if (interfaces::Ipc* ipc = node.init->ipc()) { |
| 1208 | + for (std::string address : gArgs.GetArgs("-ipcbind")) { |
| 1209 | + try { |
| 1210 | + ipc->listenAddress(address); |
| 1211 | + } catch (const std::exception& e) { |
| 1212 | + return InitError(strprintf(Untranslated("Unable to bind to IPC address '%s'. %s"), address, e.what())); |
| 1213 | + } |
| 1214 | + LogPrintf("Listening for IPC requests on address %s\n", address); |
| 1215 | + } |
| 1216 | + } |
| 1217 | + |
1203 | 1218 | /* Register RPC commands regardless of -server setting so they will be
|
1204 | 1219 | * available in the GUI RPC console even if external calls are disabled.
|
1205 | 1220 | */
|
|
0 commit comments