diff --git a/firmware/main/hal/hal_account.cpp b/firmware/main/hal/hal_account.cpp index f87d83e..b953d27 100644 --- a/firmware/main/hal/hal_account.cpp +++ b/firmware/main/hal/hal_account.cpp @@ -17,9 +17,20 @@ static const std::string_view _setting_ns = "account"; static const std::string_view _setting_username_key = "username"; static const std::string_view _setting_device_name_key = "device_name"; -static const std::string_view _get_user_account_info_url = "http://47.113.125.164:12800/stackChan/device/user"; -static const std::string_view _get_device_info_url = "http://47.113.125.164:12800/stackChan/device/info"; -static const std::string_view _unbind_user_account_info_url = "http://47.113.125.164:12800/stackChan/device/unbind"; +static std::string get_user_account_info_url() +{ + return secret_logic::get_server_url() + "/stackChan/device/user"; +} + +static std::string get_device_info_url() +{ + return secret_logic::get_server_url() + "/stackChan/device/info"; +} + +static std::string get_unbind_user_account_info_url() +{ + return secret_logic::get_server_url() + "/stackChan/device/unbind"; +} static bool request_authorized_get(std::string_view token, std::string_view url, std::string &response, std::function onLog) @@ -58,7 +69,8 @@ static bool fetch_username(std::string_view token, std::string &username, std::f onLog("Updating user account info..."); std::string response; - if (!request_authorized_get(token, _get_user_account_info_url, response, onLog)) { + const std::string url = get_user_account_info_url(); + if (!request_authorized_get(token, url, response, onLog)) { return false; } @@ -101,7 +113,8 @@ static bool fetch_device_name(std::string_view token, std::string &deviceName, onLog("Updating device info..."); std::string response; - if (!request_authorized_get(token, _get_device_info_url, response, onLog)) { + const std::string url = get_device_info_url(); + if (!request_authorized_get(token, url, response, onLog)) { return false; } @@ -193,7 +206,7 @@ bool Hal::unbindAccount(std::function onLog) mclog::tagInfo(_tag, "requesting to unbind account..."); onLog("Unbinding account..."); - if (!http->Open("POST", std::string(_unbind_user_account_info_url))) { + if (!http->Open("POST", get_unbind_user_account_info_url())) { mclog::tagError(_tag, "failed to open http request"); onLog("Failed to connect to server"); return false; diff --git a/firmware/main/hal/hal_app_center.cpp b/firmware/main/hal/hal_app_center.cpp index 5dedc04..2dd1e49 100644 --- a/firmware/main/hal/hal_app_center.cpp +++ b/firmware/main/hal/hal_app_center.cpp @@ -5,6 +5,7 @@ */ #include "hal.h" #include "utils/ota/ota.h" +#include "utils/secret_logic/secret_logic.h" #include #include #include @@ -12,7 +13,10 @@ static const std::string_view _tag = "HAL-AppCenter"; -static const std::string_view _app_info_list_url = "http://47.113.125.164:12800/stackChan/apps"; +static std::string get_app_info_list_url() +{ + return secret_logic::get_server_url() + "/stackChan/apps"; +} static const char *get_json_string(cJSON *item, std::initializer_list keys) { @@ -33,7 +37,7 @@ app_center::AppInfoList_t Hal::fetchAppList() auto network = board.GetNetwork(); auto http = network->CreateHttp(0); - if (!http->Open("GET", std::string(_app_info_list_url))) { + if (!http->Open("GET", get_app_info_list_url())) { mclog::tagError(_tag, "failed to open http connection"); return app_list; }