diff --git a/include/command_helpers.h b/include/command_helpers.h index 6dad9c0b..5c0c0d6b 100644 --- a/include/command_helpers.h +++ b/include/command_helpers.h @@ -74,12 +74,16 @@ cleanup_commands(); key, command_base_call_value, slot, "i:i", "") \ } while (0) \ -#define CMD2_ANY_VALUE_V(key, slot) \ - CMD2_A_FUNCTION(key, \ +#define CMD2_ANY_VALUE_V(key, slot, is_readonly) \ + do { \ + if (is_readonly) rpc::readonly_command.insert(key); \ + CMD2_A_FUNCTION(key, \ command_base_call_value, \ object_convert_void(slot), \ "i:i", \ - "") + "") \ + } while (0) \ + #define CMD2_ANY_VALUE_KB(key, slot) \ CMD2_A_FUNCTION(key, \ command_base_call_value_kb, \ diff --git a/src/command_local.cc b/src/command_local.cc index eada7f53..e6d1af00 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -257,7 +257,7 @@ initialize_command_local() { }, true); CMD2_ANY_VALUE_V("system.umask.set", - [](const auto&, const auto& mode) { return umask(mode); }); + [](const auto&, const auto& mode) { return umask(mode); }, false); CMD2_VAR_BOOL("system.daemon", false); @@ -281,7 +281,7 @@ initialize_command_local() { CMD2_ANY_VALUE_V("pieces.sync.always_safe.set", [chunkManager](const auto&, const auto& state) { return chunkManager->set_safe_sync(state); - }); + }, false); CMD2_ANY("pieces.sync.safe_free_diskspace", [chunkManager](const auto&, const auto&) { return chunkManager->safe_free_diskspace(); @@ -292,7 +292,7 @@ initialize_command_local() { CMD2_ANY_VALUE_V("pieces.sync.timeout.set", [chunkManager](const auto&, const auto& seconds) { return chunkManager->set_timeout_sync(seconds); - }); + }, false); CMD2_ANY("pieces.sync.timeout_safe", [chunkManager](const auto&, const auto&) { return chunkManager->timeout_safe_sync(); @@ -300,7 +300,7 @@ initialize_command_local() { CMD2_ANY_VALUE_V("pieces.sync.timeout_safe.set", [chunkManager](const auto&, const auto& seconds) { return chunkManager->set_timeout_safe_sync(seconds); - }); + }, false); CMD2_ANY("pieces.sync.queue_size", [chunkManager](const auto&, const auto&) { return chunkManager->sync_queue_size(); }, true); @@ -311,21 +311,21 @@ initialize_command_local() { CMD2_ANY_VALUE_V("pieces.preload.type.set", [chunkManager](const auto&, const auto& t) { return chunkManager->set_preload_type(t); - }); + }, false); CMD2_ANY("pieces.preload.min_size", [chunkManager](const auto&, const auto&) { return chunkManager->preload_min_size(); }, true); CMD2_ANY_VALUE_V("pieces.preload.min_size.set", [chunkManager](const auto&, const auto& bytes) { return chunkManager->set_preload_min_size(bytes); - }); + }, false); CMD2_ANY("pieces.preload.min_rate", [chunkManager](const auto&, const auto&) { return chunkManager->preload_required_rate(); }, true); CMD2_ANY_VALUE_V("pieces.preload.min_rate.set", [chunkManager](const auto&, const auto& bytes) { return chunkManager->set_preload_required_rate(bytes); - }); + }, false); CMD2_ANY("pieces.memory.current", [chunkManager](const auto&, const auto&) { return chunkManager->memory_usage(); @@ -344,7 +344,7 @@ initialize_command_local() { CMD2_ANY_VALUE_V("pieces.memory.max.set", [chunkManager](const auto&, const auto& bytes) { return chunkManager->set_max_memory_usage(bytes); - }); + }, false); CMD2_ANY("pieces.stats_preloaded", [chunkManager](const auto&, const auto&) { return chunkManager->stats_preloaded(); }, true); diff --git a/src/command_network.cc b/src/command_network.cc index 7b1bfc41..7b84e980 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -268,7 +268,7 @@ initialize_command_network() { [cm](const auto&, const auto&) { return cm->listen_backlog(); }, true); CMD2_ANY_VALUE_V( "network.listen.backlog.set", - [cm](const auto&, const auto& v) { return cm->set_listen_backlog(v); }); + [cm](const auto&, const auto& v) { return cm->set_listen_backlog(v); }, false); CMD2_VAR_BOOL("protocol.pex", true); CMD2_ANY_LIST("protocol.encryption.set", [](const auto&, const auto& args) { @@ -303,7 +303,7 @@ initialize_command_network() { CMD2_ANY_VALUE_V("network.http.dns_cache_timeout.set", [httpStack](const auto&, const auto& timeout) { return httpStack->set_dns_timeout(timeout); - }); + }, false); CMD2_ANY("network.http.current_open", [httpStack](const auto&, const auto&) { return httpStack->active(); }, true); @@ -313,7 +313,7 @@ initialize_command_network() { CMD2_ANY_VALUE_V("network.http.max_open.set", [httpStack](const auto&, const auto& a) { return httpStack->set_max_active(a); - }); + }, false); CMD2_ANY("network.http.proxy_address", [httpStack](const auto&, const auto&) { return httpStack->http_proxy(); }, true); @@ -328,7 +328,7 @@ initialize_command_network() { CMD2_ANY_VALUE_V("network.http.ssl_verify_host.set", [httpStack](const auto&, const auto& v) { return httpStack->set_ssl_verify_host(v); - }); + }, false); CMD2_ANY("network.http.ssl_verify_peer", [httpStack](const auto&, const auto&) { return httpStack->ssl_verify_peer(); @@ -336,20 +336,20 @@ initialize_command_network() { CMD2_ANY_VALUE_V("network.http.ssl_verify_peer.set", [httpStack](const auto&, const auto& v) { return httpStack->set_ssl_verify_peer(v); - }); + }, false); CMD2_ANY("network.send_buffer.size", [cm](const auto&, const auto&) { return cm->send_buffer_size(); }, true); CMD2_ANY_VALUE_V( "network.send_buffer.size.set", - [cm](const auto&, const auto& v) { return cm->set_send_buffer_size(v); }); + [cm](const auto&, const auto& v) { return cm->set_send_buffer_size(v); }, false); CMD2_ANY("network.receive_buffer.size", [cm](const auto&, const auto&) { return cm->receive_buffer_size(); }, true); CMD2_ANY_VALUE_V("network.receive_buffer.size.set", [cm](const auto&, const auto& v) { return cm->set_receive_buffer_size(v); - }); + }, false); CMD2_ANY_STRING("network.tos.set", [](const auto&, const auto& arg) { return apply_tos(arg); }, false); @@ -384,7 +384,7 @@ initialize_command_network() { CMD2_ANY_VALUE_V("network.max_open_files.set", [fileManager](const auto&, const auto& v) { return fileManager->set_max_open_files(v); - }); + }, false); CMD2_ANY("network.total_handshakes", [](const auto&, const auto&) { return torrent::total_handshakes(); }, true); @@ -394,7 +394,7 @@ initialize_command_network() { [cm](const auto&, const auto&) { return cm->max_size(); }, true); CMD2_ANY_VALUE_V( "network.max_open_sockets.set", - [cm](const auto&, const auto& v) { return cm->set_max_size(v); }); + [cm](const auto&, const auto& v) { return cm->set_max_size(v); }, false); CMD2_ANY_STRING("network.scgi.open_port", [](const auto&, const auto& arg) { return apply_scgi(arg, 1); diff --git a/src/command_throttle.cc b/src/command_throttle.cc index e4baee07..9881ee43 100644 --- a/src/command_throttle.cc +++ b/src/command_throttle.cc @@ -227,7 +227,7 @@ initialize_command_throttle() { CMD2_ANY_VALUE_V("throttle.global_up.max_rate.set", [](const auto&, const auto& throttle) { return control->ui()->set_up_throttle_i64(throttle); - }); + }, false); CMD2_ANY_VALUE_KB("throttle.global_up.max_rate.set_kb", [](const auto&, const auto& throttle) { return control->ui()->set_up_throttle_i64(throttle); @@ -246,7 +246,7 @@ initialize_command_throttle() { CMD2_ANY_VALUE_V("throttle.global_down.max_rate.set", [](const auto&, const auto& throttle) { return control->ui()->set_down_throttle_i64(throttle); - }); + }, false); CMD2_ANY_VALUE_KB("throttle.global_down.max_rate.set_kb", [](const auto&, const auto& throttle) { return control->ui()->set_down_throttle_i64(throttle); diff --git a/src/command_ui.cc b/src/command_ui.cc index 7ade04f6..4fd9419c 100644 --- a/src/command_ui.cc +++ b/src/command_ui.cc @@ -288,7 +288,7 @@ initialize_command_ui() { CMD2_ANY_VALUE_V("ui.input.history.size.set", [](const auto&, const auto& size) { return control->ui()->set_input_history_size(size); - }); + }, false); CMD2_ANY_V("ui.input.history.clear", [](const auto&, const auto&) { return control->ui()->clear_input_history(); }, false);