aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrand Jacquin <bertrand@jacquin.bzh>2024-04-04 22:33:16 +0100
committerBertrand Jacquin <bertrand@jacquin.bzh>2024-04-06 14:50:40 +0100
commit4175d5b8d5c89a0617c0686c3e18d81286a43471 (patch)
tree0251fbbb773b4392497e580eb1a41b3a8df3ef57
parentnet: bring consistency between IPv4 port and IPv6 port (diff)
downloadmonero-4175d5b8d5c89a0617c0686c3e18d81286a43471.tar.xz
net: add retro compatibility with legacy IPv4 optionsdev/beber/ipv4
To ensure retro compatibility, legacy IPv4 daemon arguments and configuration settings changes are marked as deprecated, but can still be used falling back to new option name when new options are not used. Raise warning in case legacy option are used. * --p2p-bind-ip is an alias to --p2p-bind-ipv4-address * --p2p-bind-port is an alias to --p2p-bind-ipv4-port * --p2p-bind-port-ipv6 is an alias to --p2p-bind-ipv6-port * --rpc-bind-ip is an alias to --rpc-bind-ipv4-address * --rpc-restricted-bind-ip is an alias to --rpc-restricted-bind-ipv4-address
-rw-r--r--src/p2p/net_node.cpp3
-rw-r--r--src/p2p/net_node.h3
-rw-r--r--src/p2p/net_node.inl22
-rw-r--r--src/rpc/rpc_args.cpp17
-rw-r--r--src/rpc/rpc_args.h2
5 files changed, 47 insertions, 0 deletions
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp
index bb7965817..4d5ba6e38 100644
--- a/src/p2p/net_node.cpp
+++ b/src/p2p/net_node.cpp
@@ -113,6 +113,7 @@ namespace nodetool
{
const command_line::arg_descriptor<std::string> arg_p2p_bind_ipv4_address = {"p2p-bind-ipv4-address", "Interface for p2p network protocol (IPv4)", "0.0.0.0"};
const command_line::arg_descriptor<std::string> arg_p2p_bind_ipv6_address = {"p2p-bind-ipv6-address", "Interface for p2p network protocol (IPv6)", "::"};
+ const command_line::arg_descriptor<std::string> arg_p2p_bind_ip = {"p2p-bind-ip", "DEPRECATED: replaced with --p2p-bind-ipv4-address", ""};
const command_line::arg_descriptor<std::string, false, true, 2> arg_p2p_bind_ipv4_port = {
"p2p-bind-ipv4-port"
, "Port for p2p network protocol (IPv4)"
@@ -139,6 +140,8 @@ namespace nodetool
return val;
}
};
+ const command_line::arg_descriptor<std::string> arg_p2p_bind_port = {"p2p-bind-port", "DEPRECATED: replaced with --p2p-bind-ipv4-port", ""};
+ const command_line::arg_descriptor<std::string> arg_p2p_bind_port_ipv6 = {"p2p-bind-port-ipv6", "DEPRECATED: replaced with --p2p-bind-ipv6-port", ""};
const command_line::arg_descriptor<uint32_t> arg_p2p_external_port = {"p2p-external-port", "External port for p2p network protocol (if port forwarding used with NAT)", 0};
const command_line::arg_descriptor<bool> arg_p2p_allow_local_ip = {"allow-local-ip", "Allow local ip add to peer list, mostly in debug purposes"};
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index a373c80a3..4db6a107c 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -522,8 +522,11 @@ namespace nodetool
const int64_t default_limit_down = P2P_DEFAULT_LIMIT_RATE_DOWN; // kB/s
extern const command_line::arg_descriptor<std::string> arg_p2p_bind_ipv4_address;
extern const command_line::arg_descriptor<std::string> arg_p2p_bind_ipv6_address;
+ extern const command_line::arg_descriptor<std::string> arg_p2p_bind_ip; // DEPRECATED
extern const command_line::arg_descriptor<std::string, false, true, 2> arg_p2p_bind_ipv4_port;
extern const command_line::arg_descriptor<std::string, false, true, 2> arg_p2p_bind_ipv6_port;
+ extern const command_line::arg_descriptor<std::string> arg_p2p_bind_port; // DEPRECATED
+ extern const command_line::arg_descriptor<std::string> arg_p2p_bind_port_ipv6; // DEPRECATED
extern const command_line::arg_descriptor<bool> arg_p2p_use_ipv6;
extern const command_line::arg_descriptor<bool> arg_p2p_ignore_ipv4;
extern const command_line::arg_descriptor<uint32_t> arg_p2p_external_port;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f50ac8ea2..1a43c8ac2 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -101,8 +101,11 @@ namespace nodetool
{
command_line::add_arg(desc, arg_p2p_bind_ipv4_address);
command_line::add_arg(desc, arg_p2p_bind_ipv6_address);
+ command_line::add_arg(desc, arg_p2p_bind_ip); // DEPRECATED
command_line::add_arg(desc, arg_p2p_bind_ipv4_port, false);
command_line::add_arg(desc, arg_p2p_bind_ipv6_port, false);
+ command_line::add_arg(desc, arg_p2p_bind_port, false); // DEPRECATED
+ command_line::add_arg(desc, arg_p2p_bind_port_ipv6, false); // DEPRECATED
command_line::add_arg(desc, arg_p2p_use_ipv6);
command_line::add_arg(desc, arg_p2p_ignore_ipv4);
command_line::add_arg(desc, arg_p2p_external_port);
@@ -416,6 +419,25 @@ namespace nodetool
public_zone.m_bind_ipv6_address = command_line::get_arg(vm, arg_p2p_bind_ipv6_address);
public_zone.m_port_ipv4 = command_line::get_arg(vm, arg_p2p_bind_ipv4_port);
public_zone.m_port_ipv6 = command_line::get_arg(vm, arg_p2p_bind_ipv6_port);
+
+ // DEPRECATED --p2p-bind-ip
+ if (!command_line::get_arg(vm, arg_p2p_bind_ip).empty())
+ MWARNING("--p2p-bind-ip is now DEPRECATED, replace with --p2p-bind-ipv4-address");
+ if (public_zone.m_bind_ipv4_address.empty())
+ public_zone.m_bind_ipv4_address = command_line::get_arg(vm, arg_p2p_bind_ip);
+
+ // DEPRECATED --p2p-bind-port
+ if (!command_line::get_arg(vm, arg_p2p_bind_port).empty())
+ MWARNING("--p2p-bind-port is now DEPRECATED, replace with --p2p-bind-ipv4-port");
+ if (public_zone.m_port_ipv4.empty())
+ public_zone.m_port_ipv4 = command_line::get_arg(vm, arg_p2p_bind_port);
+
+ // DEPRECATED --p2p-bind-port-ipv6
+ if (!command_line::get_arg(vm, arg_p2p_bind_port_ipv6).empty())
+ MWARNING("--p2p-bind-port-ipv6 is now DEPRECATED, replace with --p2p-bind-ipv6-port");
+ if (public_zone.m_port_ipv6.empty())
+ public_zone.m_port_ipv6 = command_line::get_arg(vm, arg_p2p_bind_ipv6_port);
+
public_zone.m_can_pingback = true;
m_external_port = command_line::get_arg(vm, arg_p2p_external_port);
m_allow_local_ip = command_line::get_arg(vm, arg_p2p_allow_local_ip);
diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp
index 3e4503b20..4d0411b50 100644
--- a/src/rpc/rpc_args.cpp
+++ b/src/rpc/rpc_args.cpp
@@ -91,8 +91,10 @@ namespace cryptonote
rpc_args::descriptors::descriptors()
: rpc_bind_ipv4_address({"rpc-bind-ipv4-address", rpc_args::tr("Specify IPv4 address to bind RPC server"), "127.0.0.1"})
, rpc_bind_ipv6_address({"rpc-bind-ipv6-address", rpc_args::tr("Specify IPv6 address to bind RPC server"), "::1"})
+ , rpc_bind_ip({"rpc-bind-ip", rpc_args::tr("DEPRECATED: replaced with --rpc-bind-ipv4-address"), ""})
, rpc_restricted_bind_ipv4_address({"rpc-restricted-bind-ipv4-address", rpc_args::tr("Specify IPv4 address to bind restricted RPC server"), "127.0.0.1"})
, rpc_restricted_bind_ipv6_address({"rpc-restricted-bind-ipv6-address", rpc_args::tr("Specify IPv6 address to bind restricted RPC server"), "::1"})
+ , rpc_restricted_bind_ip({"rpc-restricted-bind-ip", rpc_args::tr("DEPRECATED: replaced with --rpc-restricted-bind-ipv4-address"), ""})
, rpc_use_ipv6({"rpc-use-ipv6", rpc_args::tr("Allow IPv6 for RPC"), false})
, rpc_ignore_ipv4({"rpc-ignore-ipv4", rpc_args::tr("Ignore unsuccessful IPv4 bind for RPC"), false})
, rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true})
@@ -115,8 +117,10 @@ namespace cryptonote
const descriptors arg{};
command_line::add_arg(desc, arg.rpc_bind_ipv4_address);
command_line::add_arg(desc, arg.rpc_bind_ipv6_address);
+ command_line::add_arg(desc, arg.rpc_bind_ip); // DEPRECATED
command_line::add_arg(desc, arg.rpc_restricted_bind_ipv4_address);
command_line::add_arg(desc, arg.rpc_restricted_bind_ipv6_address);
+ command_line::add_arg(desc, arg.rpc_restricted_bind_ip); // DEPRECATED
command_line::add_arg(desc, arg.rpc_use_ipv6);
command_line::add_arg(desc, arg.rpc_ignore_ipv4);
command_line::add_arg(desc, arg.rpc_login);
@@ -142,6 +146,19 @@ namespace cryptonote
config.bind_ipv6_address = command_line::get_arg(vm, arg.rpc_bind_ipv6_address);
config.restricted_bind_ipv4_address = command_line::get_arg(vm, arg.rpc_restricted_bind_ipv4_address);
config.restricted_bind_ipv6_address = command_line::get_arg(vm, arg.rpc_restricted_bind_ipv6_address);
+
+ // DEPRECATED --rpc-bind-ip
+ if (!command_line::get_arg(vm, arg.rpc_bind_ip).empty())
+ MWARNING("--rpc-bind-ip is now DEPRECATED, replace with --rpc-bind-ipv4-address");
+ if (config.bind_ipv4_address.empty())
+ config.bind_ipv4_address = command_line::get_arg(vm, arg.rpc_bind_ip);
+
+ // DEPRECATED --rpc-restricted-bind-ip
+ if (!command_line::get_arg(vm, arg.rpc_restricted_bind_ip).empty())
+ MWARNING("--rpc-restricted-bind-ip is now DEPRECATED, replace with --rpc-restricted-bind-ipv4-address");
+ if (config.restricted_bind_ipv4_address.empty())
+ config.restricted_bind_ipv4_address = command_line::get_arg(vm, arg.rpc_restricted_bind_ip);
+
config.use_ipv6 = command_line::get_arg(vm, arg.rpc_use_ipv6);
config.require_ipv4 = !command_line::get_arg(vm, arg.rpc_ignore_ipv4);
config.disable_rpc_ban = command_line::get_arg(vm, arg.disable_rpc_ban);
diff --git a/src/rpc/rpc_args.h b/src/rpc/rpc_args.h
index b4fa3ced0..392e78703 100644
--- a/src/rpc/rpc_args.h
+++ b/src/rpc/rpc_args.h
@@ -53,8 +53,10 @@ namespace cryptonote
const command_line::arg_descriptor<std::string> rpc_bind_ipv4_address;
const command_line::arg_descriptor<std::string> rpc_bind_ipv6_address;
+ const command_line::arg_descriptor<std::string> rpc_bind_ip; // DEPRECATED
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ipv4_address;
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ipv6_address;
+ const command_line::arg_descriptor<std::string> rpc_restricted_bind_ip; // DEPRECATED
const command_line::arg_descriptor<bool> rpc_use_ipv6;
const command_line::arg_descriptor<bool> rpc_ignore_ipv4;
const command_line::arg_descriptor<std::string> rpc_login;