X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/b6f9db38b4be65b8893ae726a6d78e7ac657dc35..f8054f164b10a7b42a5250856ec83dca71ad3545:/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp index fceaa3ab..ce339573 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp @@ -136,15 +136,24 @@ std::map structVal( std::map::iterator it; -if ((it = structVal.find("password")) != structVal.end()) +bool check = false; +bool alwaysOnline = ptr->GetProperty().alwaysOnline; +if ((it = structVal.find("aonline")) != structVal.end()) { - std::string value(xmlrpc_c::value_string(it->second)); - if (ptr->GetProperty().password.Get() != value) - if (!ptr->GetProperty().password.Set(value, - admin, - login, - &store)) - return true; + check = true; + alwaysOnline = xmlrpc_c::value_boolean(it->second); + } +bool onlyOneIP = ptr->GetProperty().ips.ConstData().OnlyOneIP(); +if ((it = structVal.find("ips")) != structVal.end()) + { + check = true; + onlyOneIP = StrToIPS(xmlrpc_c::value_string(it->second)).OnlyOneIP(); + } + +if (check && alwaysOnline && !onlyOneIP) + { + printfd(__FILE__, "Requested change leads to a forbidden state: AlwaysOnline with multiple IP's\n"); + return true; } if ((it = structVal.find("ips")) != structVal.end()) @@ -158,6 +167,28 @@ if ((it = structVal.find("ips")) != structVal.end()) return true; } +if ((it = structVal.find("aonline")) != structVal.end()) + { + bool value(xmlrpc_c::value_boolean(it->second)); + if (ptr->GetProperty().alwaysOnline.Get() != value) + if (!ptr->GetProperty().alwaysOnline.Set(value, + admin, + login, + &store)) + return true; + } + +if ((it = structVal.find("password")) != structVal.end()) + { + std::string value(xmlrpc_c::value_string(it->second)); + if (ptr->GetProperty().password.Get() != value) + if (!ptr->GetProperty().password.Set(value, + admin, + login, + &store)) + return true; + } + if ((it = structVal.find("address")) != structVal.end()) { std::string value(IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "KOI8-RU")); @@ -257,17 +288,6 @@ if ((it = structVal.find("passive")) != structVal.end()) return true; } -if ((it = structVal.find("aonline")) != structVal.end()) - { - bool value(xmlrpc_c::value_boolean(it->second)); - if (ptr->GetProperty().alwaysOnline.Get() != value) - if (!ptr->GetProperty().alwaysOnline.Set(value, - admin, - login, - &store)) - return true; - } - if ((it = structVal.find("disableddetailstat")) != structVal.end()) { bool value(xmlrpc_c::value_boolean(it->second));