Skip to content

Commit

Permalink
chore: add support for setting port via flag
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Jan 19, 2023
1 parent 3b38ef6 commit 6ae9f74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions libraries/cli/include/cli/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Config {
static constexpr const char* CONFIG_COMMAND = "config";
static constexpr const char* BOOT_NODES = "boot-nodes";
static constexpr const char* PUBLIC_IP = "public-ip";
static constexpr const char* PORT = "port";
static constexpr const char* LOG_CHANNELS = "log-channels";
static constexpr const char* LOG_CONFIGURATIONS = "log-configurations";
static constexpr const char* BOOT_NODES_APPEND = "boot-nodes-append";
Expand Down
6 changes: 6 additions & 0 deletions libraries/cli/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Config::Config(int argc, const char* argv[]) {
std::vector<std::string> command;
std::vector<std::string> boot_nodes;
std::string public_ip;
uint16_t port = 0;
std::vector<std::string> log_channels;
std::vector<std::string> log_configurations;
std::vector<std::string> boot_nodes_append;
Expand Down Expand Up @@ -105,6 +106,8 @@ Config::Config(int argc, const char* argv[]) {
"Boot nodes to connect to in addition to boot nodes defined in config: [ip_address:port_number/node_id, ....]");
node_command_options.add_options()(PUBLIC_IP, bpo::value<std::string>(&public_ip),
"Force advertised public IP to the given IP (default: auto)");
node_command_options.add_options()(PORT, bpo::value<uint16_t>(&port),
"Listen on the given port for incoming connections");
node_command_options.add_options()(LOG_CHANNELS, bpo::value<std::vector<std::string>>(&log_channels)->multitoken(),
"Log channels to log: [channel:level, ....]");
node_command_options.add_options()(
Expand Down Expand Up @@ -258,6 +261,9 @@ Config::Config(int argc, const char* argv[]) {
if (!public_ip.empty()) {
node_config_.network.public_ip = public_ip;
}
if (port) {
node_config_.network.listen_port = port;
}
node_config_.db_config.db_revert_to_period = revert_to_period;
node_config_.db_config.rebuild_db = rebuild_db;
node_config_.db_config.rebuild_db_columns = rebuild_db_columns;
Expand Down
2 changes: 1 addition & 1 deletion programs/taraxa-bootnode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int main(int argc, char** argv) {
auto addNetworkingOption = client_networking.add_options();
addNetworkingOption("public-ip", po::value<std::string>()->value_name("<ip>"),
"Force advertised public IP to the given IP (default: auto)");
addNetworkingOption("listen-ip", po::value<std::string>()->value_name("<ip>(:<port>)"),
addNetworkingOption("listen-ip", po::value<std::string>()->value_name("<ip>"),
"Listen on the given IP for incoming connections (default: 0.0.0.0)");
addNetworkingOption("listen", po::value<unsigned short>()->value_name("<port>"),
"Listen on the given port for incoming connections (default: 10002)");
Expand Down

0 comments on commit 6ae9f74

Please sign in to comment.