Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
update timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Betty committed Mar 1, 2022
1 parent 5253ce9 commit a4929b1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Binary file modified bin/github_action/daily_reporter
Binary file not shown.
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inline nlohmann::json &default_json()
{
{"user_agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.84"},
{"form_data", "{\"formData\":[{\"name\":\"select_1582538796361\",\"title\":\"\\u4ECA\\u65E5\\u4F53\\u6E29 Body temperature today \\uFF08\\u2103\\uFF09\",\"value\":{\"stringValue\":\"37.3\\u4EE5\\u4E0B Below 37.3 degree celsius\"},\"hide\":false},{\"name\":\"select_1582538846920\",\"title\":\"\\u662F\\u5426\\u51FA\\u73B0\\u53D1\\u70ED\\u6216\\u54B3\\u55FD\\u6216\\u80F8\\u95F7\\u6216\\u547C\\u5438\\u56F0\\u96BE\\u7B49\\u75C7\\u72B6\\uFF1FDo you have sypmtoms such as fever, coughing, chest tightness or breath difficulties?\",\"value\":{\"stringValue\":\"\\u5426 No\"},\"hide\":false},{\"name\":\"select_1584240106785\",\"title\":\"\\u5B66\\u751F\\u672C\\u4EBA\\u662F\\u5426\\u586B\\u5199\",\"value\":{\"stringValue\":\"\\u662F\"},\"hide\":false},{\"name\":\"select_1582538939790\",\"title\":\"Can you hereby declare that all the information provided is all true and accurate and there is no concealment, false information or omission. \\u672C\\u4EBA\\u662F\\u5426\\u627F\\u8BFA\\u6240\\u586B\\u62A5\\u7684\\u5168\\u90E8\\u5185\\u5BB9\\u5747\\u5C5E\\u5B9E\\u3001\\u51C6\\u786E\\uFF0C\\u4E0D\\u5B58\\u5728\\u4EFB\\u4F55\\u9690\\u7792\\u548C\\u4E0D\\u5B9E\\u7684\\u60C5\\u51B5\\uFF0C\\u66F4\\u65E0\\u9057\\u6F0F\\u4E4B\\u5904\\u3002\",\"value\":{\"stringValue\":\"\\u662F Yes\"},\"hide\":false},{\"name\":\"input_1582538924486\",\"title\":\"\\u5907\\u6CE8 Notes\",\"value\":{\"stringValue\":\"\"},\"hide\":false},{\"name\":\"datetime_1611146487222\",\"title\":\"\\u6253\\u5361\\u65F6\\u95F4\\uFF08\\u65E0\\u9700\\u586B\\u5199\\uFF0C\\u4FDD\\u5B58\\u540E\\u4F1A\\u81EA\\u52A8\\u66F4\\u65B0\\uFF09\",\"value\":{\"dateValue\":\"\"},\"hide\":false}],\"playerId\":\"owner\"}"},
{"report_retry", {{"duration", 10}, {"counts", 30}}},
{"report_retry", {{"duration", 10}, {"counts", 100}}},
{"mail", {{"address", ""}, {"smtp_password", ""}, {"reporter_name", "HAL-9000"}}},
{"xmu", {{"ID", ""}, {"password", ""}}}};
return default_json;
Expand Down
14 changes: 7 additions & 7 deletions src/login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ unique_ptr<httplib::Client> login(const string_view src_url, optional<string_vie
auto headers = httplib::Headers{{"User-Agent", get_user_agent()}};
httplib::Client cli(host.data());
cli.set_keep_alive(true);
cli.set_connection_timeout(100s);
cli.set_read_timeout(100s);
cli.set_write_timeout(100s);
cli.set_connection_timeout(200s);
cli.set_read_timeout(200s);
cli.set_write_timeout(200s);
cli.enable_server_certificate_verification(false);
auto res = cli.Get(path.data(), headers);
if (!res)
Expand Down Expand Up @@ -146,12 +146,13 @@ unique_ptr<httplib::Client> login(const string_view src_url, optional<string_vie
}
tie(host, path) = url_parse(res->get_header_value("Location"));
SPDLOG_DEBUG("redirect host:{} path:{}",host, path);
cli.stop();

auto cli2 = make_unique<httplib::Client>(host.data());
cli2->set_keep_alive(true);
cli2->set_connection_timeout(100s);
cli2->set_read_timeout(100s);
cli2->set_write_timeout(100s);
cli2->set_connection_timeout(200s);
cli2->set_read_timeout(200s);
cli2->set_write_timeout(200s);
cli2->enable_server_certificate_verification(false);
res = cli2->Get(path.data(), headers);

Expand All @@ -166,7 +167,6 @@ unique_ptr<httplib::Client> login(const string_view src_url, optional<string_vie
SPDLOG_DEBUG("Headers:{}",res.value().headers);
SPDLOG_DEBUG("Body:{}",res.value().body);
SPDLOG_DEBUG("Status:{}",res.value().status);
this_thread::sleep_for(2s);

auto [iter, iterend] = res->headers.equal_range("Set-Cookie");
for (; iter != iterend; ++iter)
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool is_in_report_time()
}
bool report(int count = get_report_retry_counts())
{
while (--count > 0 && report_now()==false)
while (count-- > 0 && report_now()==false)
{
SPDLOG_ERROR("We will try again after {}s", get_report_retry_duration());
SPDLOG_INFO("Least retry count: {}",count);
Expand Down
2 changes: 1 addition & 1 deletion src/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool report_now()
auto cli = login("https://xmuxg.xmu.edu.cn/login/cas/xmu", "/platform");
if (!cli)
{
SPDLOG_ERROR("login failed:{}! please check your username and password.");
SPDLOG_ERROR("login failed! please check your username and password.");
return false;
}
this_thread::sleep_for(2s);
Expand Down

0 comments on commit a4929b1

Please sign in to comment.