Skip to content

Commit

Permalink
Обновил заголовки, обнаружение нового рейтлимита
Browse files Browse the repository at this point in the history
  • Loading branch information
saber-nyan committed Oct 22, 2020
1 parent 20939f8 commit efd6c7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ImagePoster4DTF/DtfClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public DtfClient() {
.WithHeader("sec-fetch-dest", "empty")
.WithHeader("sec-fetch-mode", "cors")
.WithHeader("sec-fetch-site", "same-origin")
.WithHeader("x-js-version", "599ad322")
.WithHeader("x-js-version", "11c8b9ea")
.WithHeader("x-this-is-csrf", "THIS IS SPARTA!")
.WithCookie(new Cookie("pushVisitsCount", "1", "/", ".dtf.ru"))
.WithCookie(new Cookie("adblock-state", "1", "/", ".dtf.ru"))
Expand Down
13 changes: 13 additions & 0 deletions ImagePoster4DTF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,19 @@ private async void FireButton_OnClick(object sender, RoutedEventArgs ev) {
Log.Debug("...done.");
await Task.Delay(334); // 3 requests per second
}
catch (FlurlHttpException e) {
Log.Error(e, "...failed, checking for 429:");
if (e.Call?.Response?.Content == null) continue;
var body = await e.Call.Response.Content.ReadAsStringAsync();

if (body.Contains("Ошибка 429")) {
Log.Information("Ratelimited, sleeping 15 secs!");
await Task.Delay(15000);
i = 0; // Does not count as error

for (var j = 0; j < 10; j++) await DtfClient.HitRandomPost();
}
}
catch (Exception e) {
Log.Error(e, "...failed:");
}
Expand Down

0 comments on commit efd6c7a

Please sign in to comment.