Skip to content

Commit

Permalink
Merge pull request #52 from Titlehhhh/dev
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
Titlehhhh authored Feb 6, 2024
2 parents c558e51 + 4515f79 commit aa471a3
Show file tree
Hide file tree
Showing 32 changed files with 237 additions and 116 deletions.
4 changes: 2 additions & 2 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />

<PackageReference Include="Octokit" Version="9.1.0" />
<PackageReference Include="Octokit" Version="9.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.7" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.7" />
<PackageReference Include="MinVer" Version="5.0.0-beta.1" PrivateAssets="All" />
<PackageReference Include="System.Reactive" Version="6.0.1-preview.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Avalonia.Controls;
using ReactiveUI;
using Serilog;
using System.Reactive.Disposables;

namespace HolyClient.Abstractions.StressTest
{
public abstract class BaseStressTestBehavior : IStressTestBehavior
{
public ReactiveObject? DefaultViewModel { get; protected set; }

public ReactiveObject? ProcessViewModel { get; protected set; }

public ResourceDictionary? Resources { get; protected set; }

public abstract Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot> bots, ILogger logger, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
using System.Reactive.Disposables;
using Avalonia.Controls;
using ReactiveUI;
using System.ComponentModel;
using System.Reactive.Disposables;

namespace HolyClient.Abstractions.StressTest
{


public interface IStressTestBehavior
{

public Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot> bots, CancellationToken cancellationToken);

ReactiveObject? DefaultViewModel { get; }

ReactiveObject? ProcessViewModel { get; }


ResourceDictionary? Resources { get; }

public Task Activate(
CompositeDisposable disposables,
IEnumerable<IStressTestBot> bots,
Serilog.ILogger logger,
CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using McProtoNet;
using Avalonia.Controls;
using McProtoNet;

namespace HolyClient.Abstractions.StressTest
{

public interface IStressTestBot
{
public Task Restart(bool changeNickAndProxy);


public MinecraftClient Client { get; }
}
Expand Down
6 changes: 3 additions & 3 deletions src/CoreLibs/HolyClient.Common/HolyClient.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<ItemGroup>
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.2" />
<PackageReference Include="MessagePack" Version="2.6.100-alpha" />
<PackageReference Include="Polly" Version="8.2.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.39" />
<PackageReference Include="Polly" Version="8.3.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="Serilog" Version="3.1.2-dev-02097" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="QuickProxyNet" Version="0.1.4" />
<PackageReference Include="QuickProxyNet" Version="2.0.0-preview.1.1.4" />
</ItemGroup>


Expand Down
5 changes: 4 additions & 1 deletion src/CoreLibs/HolyClient.Core/Helpers/MapDataHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace HolyClient.Core.Helpers
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace HolyClient.Core.Helpers
{
public class MapDataHelper
{
Expand Down
10 changes: 5 additions & 5 deletions src/CoreLibs/HolyClient.Core/HolyClient.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<ItemGroup>
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.2" />
<PackageReference Include="MessagePack" Version="2.6.100-alpha" />
<PackageReference Include="Polly" Version="8.2.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.39" />
<PackageReference Include="Polly" Version="8.3.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="Serilog" Version="3.1.2-dev-02097" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="SixLabors.Fonts" Version="2.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.0.1" />
<PackageReference Include="SixLabors.Fonts" Version="2.0.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CoreLibs/HolyClient.SDK/HolyClient.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="MinVer" Version="5.0.0-beta.1" PrivateAssets="All" />
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
<PackageReference Include="System.Reactive" Version="6.0.1-preview.1" />
<PackageReference Include="bodong.PropertyModels" Version="11.0.4.1" />
<PackageReference Include="bodong.PropertyModels" Version="11.0.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions src/CoreLibs/HolyClient.StressTest/DefaultBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using HolyClient.Abstractions.StressTest;
using Serilog;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Text.RegularExpressions;

namespace HolyClient.StressTest
{
public class DefaultBehavior : IStressTestBehavior
public class DefaultBehavior : BaseStressTestBehavior
{
[System.ComponentModel.DisplayName("Spam text")]
public string SpamText { get; set; } = "!Hello from Minecraft Holy Client";
Expand All @@ -24,7 +25,7 @@ public class DefaultBehavior : IStressTestBehavior

private static Regex SayVerifyRegex = new(@"\.say \/verify (\d+)");

public Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot> bots, CancellationToken cancellationToken)
public override Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot> bots,ILogger logger, CancellationToken cancellationToken)
{
foreach (var bot in bots)
{
Expand All @@ -50,7 +51,7 @@ public Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot
{
cts = null;
}
if (Reconnects <= 0)
if (Reconnects <= 1)
{
await bot.Restart(true);
}
Expand Down Expand Up @@ -89,8 +90,9 @@ public Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot

await Task.Delay(500);

await bot.Client.SendChat("/register 21qwerty");
await bot.Client.SendChat("/register 21qwerty 21qwerty");

await bot.Client.SendChat("/login 21qwerty");
try
{
using CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
Expand All @@ -112,6 +114,7 @@ public Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot

}


var spamming = SpamMessage(cts, bot);
var nuker = SpamNocomAsync(cts, bot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.2" />
<PackageReference Include="MessagePack" Version="2.6.100-alpha" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.39" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="Serilog" Version="3.1.2-dev-02097" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
</ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions src/CoreLibs/HolyClient.StressTest/StressTestProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public IStressTestBehavior Behavior
[IgnoreMember]
public StressTestServiceState CurrentState { get; private set; }


[IgnoreMember]
public ConcurrentDictionary<Tuple<string, string>, ExceptionCounter> ExceptionCounter { get; private set; } = new();

Expand Down Expand Up @@ -371,7 +371,7 @@ public async Task Start(Serilog.ILogger logger)
logger.Information("Запуск поведения");
if (Behavior is not null)
{
await Behavior.Activate(disposables, stressTestBots, cancellationTokenSource.Token);
await Behavior.Activate(disposables, stressTestBots, logger, cancellationTokenSource.Token);
}
logger.Information("Поведение запущено");

Expand Down Expand Up @@ -408,22 +408,22 @@ public async Task Start(Serilog.ILogger logger)
sources.Add(new UrlProxySource(QuickProxyNet.ProxyType.SOCKS4, "https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt"));
sources.Add(new UrlProxySource(QuickProxyNet.ProxyType.SOCKS5, "https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks5.txt"));
}

List<Task<IEnumerable<ProxyInfo>>> tasks = new();

foreach (var s in sources)
{
tasks.Add(s.GetProxiesAsync());
}

var result = await Task.WhenAll(tasks);

var proxies = result.SelectMany(x => x).ToList();

var provider = new ProxyProvider(proxies);

var group = proxies.GroupBy(x => x.Type).Select(x => $"{x.Key} - {x.Count()}");

logger.Information($"Загружено {proxies.Count} прокси. {string.Join(", ", group)}");

return provider;
Expand Down
49 changes: 46 additions & 3 deletions src/CoreLibs/HolyClient.StressTest/TidePVPBehaviorAttack.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
using HolyClient.Abstractions.StressTest;
using Avalonia.Controls;
using HolyClient.Abstractions.StressTest;
using Serilog;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks.Dataflow;

namespace HolyClient.StressTest
{
public class TidePVPBehaviorAttack : IStressTestBehavior
public class TidePVPBehaviorAttack : BaseStressTestBehavior
{
public Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot> bots, CancellationToken cancellationToken)


public override Task Activate(CompositeDisposable disposables, IEnumerable<IStressTestBot> bots, ILogger logger, CancellationToken cancellationToken)
{
foreach (var bot in bots)
{





bot.Client.OnDisconnect.Subscribe(async x =>
{
bool need = true;
do
{
try
{
await Task.Delay(5000);

await bot.Restart(true);
need = false;
}
catch
{

}
} while (need);
});


var d2 = bot.Client.OnJoinGame.Subscribe(async x =>
{

});

disposables.Add(d2);

_ = bot.Restart(true);

}
return Task.CompletedTask;
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/HolyClient/HolyClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@

<ItemGroup>
<PackageReference Include="akavache" Version="9.1.20" />
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia" Version="11.0.7" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.7" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.7" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.7" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.5" />
<PackageReference Include="Avalonia.Xaml.Interactivity" Version="11.0.5" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.1" />
<PackageReference Include="bodong.Avalonia.PropertyGrid" Version="11.0.4.1" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.7" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.6" />
<PackageReference Include="Avalonia.Xaml.Interactivity" Version="11.0.6" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.6" />
<PackageReference Include="bodong.Avalonia.PropertyGrid" Version="11.0.6.3" />

<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.0" />
<PackageReference Include="DialogHost.Avalonia" Version="0.7.5" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.4" />
<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.5" />
<PackageReference Include="DialogHost.Avalonia" Version="0.7.7" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-rc2" />

<PackageReference Include="Markdown.Avalonia" Version="11.0.2" />
Expand All @@ -62,9 +62,9 @@
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="NuGet.Protocol" Version="6.8.0" />
<PackageReference Include="NuGet.Resolver" Version="6.8.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.39" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="SkiaSharp.Skottie" Version="2.88.6" />
<PackageReference Include="SkiaSharp.Skottie" Version="2.88.7" />
<PackageReference Include="SpacedGrid-Avalonia" Version="11.0.0" />
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;


namespace HolyClient.ViewModels;

public sealed class ExceptionInfoViewModel
{
public string Type { get; private set; }
public string Message { get; private set; }
public int Count { get; private set; }

public Tuple<string, string> Key { get; private set; }

public ExceptionInfoViewModel(string type, string message, int count)
{
Type = type;
Message = message;
Count = count;
Key = Tuple.Create<string, string>(Type, Message);
}
}
Loading

0 comments on commit aa471a3

Please sign in to comment.