mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-16 22:40:30 +00:00
Code cleanups and improvements
- Make use of new UnixFileMode, always one native method we need to maintain less - Add madness support for it, because new feature of course - Add optional netstandard target and required compatibility for it, so I can test netf-oriented changes easier
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
||||||
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
||||||
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -11,11 +11,14 @@
|
|||||||
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
||||||
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" IncludeAssets="compile" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" IncludeAssets="compile" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
||||||
<Reference Include="System.Net.Http" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Net.Http.dll" />
|
<Reference Include="System.Net.Http" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Net.Http.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
<PackageReference Include="System.Linq.Async" IncludeAssets="compile" />
|
<PackageReference Include="System.Linq.Async" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
||||||
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
||||||
<Reference Include="System.Net.Http" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Net.Http.dll" />
|
<Reference Include="System.Net.Http" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Net.Http.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||||||
LastAnnouncement = DateTime.UtcNow.AddYears(1);
|
LastAnnouncement = DateTime.UtcNow.AddYears(1);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
case (HttpStatusCode) 429:
|
case (HttpStatusCode) 429:
|
||||||
#else
|
#else
|
||||||
case HttpStatusCode.TooManyRequests:
|
case HttpStatusCode.TooManyRequests:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
<!-- Madness is already included in netf build of ASF, so we don't need to emit it ourselves -->
|
||||||
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
<PackageReference Update="JustArchiNET.Madness" IncludeAssets="compile" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC
|
|||||||
GlobalCache.Reset(true);
|
GlobalCache.Reset(true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
case (HttpStatusCode) 429:
|
case (HttpStatusCode) 429:
|
||||||
#else
|
#else
|
||||||
case HttpStatusCode.TooManyRequests:
|
case HttpStatusCode.TooManyRequests:
|
||||||
|
|||||||
@@ -241,7 +241,6 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PassStringInterpolation/@EntryIndexedValue">SUGGESTION</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PassStringInterpolation/@EntryIndexedValue">SUGGESTION</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PatternAlwaysMatches/@EntryIndexedValue">WARNING</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PatternAlwaysMatches/@EntryIndexedValue">WARNING</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PatternAlwaysOfType/@EntryIndexedValue">WARNING</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PatternAlwaysOfType/@EntryIndexedValue">WARNING</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PlaceAssignmentExpressionIntoBlock/@EntryIndexedValue">WARNING</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyNotResolved/@EntryIndexedValue">WARNING</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyNotResolved/@EntryIndexedValue">WARNING</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArrayCreationExpression/@EntryIndexedValue">SUGGESTION</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArrayCreationExpression/@EntryIndexedValue">SUGGESTION</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeParentheses/@EntryIndexedValue">SUGGESTION</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeParentheses/@EntryIndexedValue">SUGGESTION</s:String>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<PackageReference Include="System.Security.Cryptography.ProtectedData" />
|
<PackageReference Include="System.Security.Cryptography.ProtectedData" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Cors" />
|
<PackageReference Include="Microsoft.AspNetCore.Cors" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" />
|
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" />
|
||||||
@@ -39,10 +39,17 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.WebSockets" />
|
<PackageReference Include="Microsoft.AspNetCore.WebSockets" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
||||||
<Reference Include="System.Net.Http" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Net.Http.dll" />
|
<Reference Include="System.Net.Http" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Net.Http.dll" />
|
||||||
<Reference Include="System.Security" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Security.dll" />
|
<Reference Include="System.Security" HintPath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8.1\System.Security.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
|
||||||
|
<PackageReference Include="System.IO.FileSystem.AccessControl" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<TrimmerRootDescriptor Include="TrimmerRoots.xml" />
|
<TrimmerRootDescriptor Include="TrimmerRoots.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1048,7 +1048,8 @@ public static class ASF {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(directory)) {
|
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
||||||
|
if (!Directory.Exists(directory!)) {
|
||||||
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
||||||
Directory.CreateDirectory(directory!);
|
Directory.CreateDirectory(directory!);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ internal static partial class GeneratedRegexes {
|
|||||||
private const string DigitsPattern = @"\d+";
|
private const string DigitsPattern = @"\d+";
|
||||||
private const string NonAsciiPattern = @"[^\u0000-\u007F]+";
|
private const string NonAsciiPattern = @"[^\u0000-\u007F]+";
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
internal static Regex CdKey() => new(CdKeyPattern, DefaultOptions);
|
internal static Regex CdKey() => new(CdKeyPattern, DefaultOptions);
|
||||||
internal static Regex Decimal() => new(DecimalPattern, DefaultOptions);
|
internal static Regex Decimal() => new(DecimalPattern, DefaultOptions);
|
||||||
internal static Regex Digits() => new(DigitsPattern, DefaultOptions);
|
internal static Regex Digits() => new(DigitsPattern, DefaultOptions);
|
||||||
|
|||||||
@@ -26,48 +26,22 @@ using System.Runtime.Versioning;
|
|||||||
namespace ArchiSteamFarm.Core;
|
namespace ArchiSteamFarm.Core;
|
||||||
|
|
||||||
internal static partial class NativeMethods {
|
internal static partial class NativeMethods {
|
||||||
[SupportedOSPlatform("Windows")]
|
|
||||||
internal const EExecutionState AwakeExecutionState = EExecutionState.SystemRequired | EExecutionState.AwayModeRequired | EExecutionState.Continuous;
|
|
||||||
|
|
||||||
[SupportedOSPlatform("Windows")]
|
|
||||||
internal const uint EnableQuickEditMode = 0x0040;
|
|
||||||
|
|
||||||
[SupportedOSPlatform("Windows")]
|
|
||||||
internal const byte ShowWindowMinimize = 6;
|
|
||||||
|
|
||||||
[SupportedOSPlatform("Windows")]
|
|
||||||
internal const sbyte StandardInputHandle = -10;
|
|
||||||
|
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
|
||||||
[SupportedOSPlatform("FreeBSD")]
|
|
||||||
[SupportedOSPlatform("Linux")]
|
|
||||||
[SupportedOSPlatform("MacOS")]
|
|
||||||
#if NETFRAMEWORK
|
|
||||||
#pragma warning disable CA2101 // False positive, we can't use unicode charset on Unix, and it uses UTF-8 by default anyway
|
|
||||||
[DllImport("libc", EntryPoint = "chmod", SetLastError = true)]
|
|
||||||
internal static extern int Chmod(string path, int mode);
|
|
||||||
#pragma warning restore CA2101 // False positive, we can't use unicode charset on Unix, and it uses UTF-8 by default anyway
|
|
||||||
#else
|
|
||||||
[LibraryImport("libc", EntryPoint = "chmod", SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
|
|
||||||
internal static partial int Chmod(string path, int mode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
[SupportedOSPlatform("Windows")]
|
[SupportedOSPlatform("Windows")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
internal static extern bool GetConsoleMode(nint hConsoleHandle, out uint lpMode);
|
internal static extern bool GetConsoleMode(nint hConsoleHandle, out EConsoleMode lpMode);
|
||||||
#else
|
#else
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
internal static partial bool GetConsoleMode(nint hConsoleHandle, out uint lpMode);
|
internal static partial bool GetConsoleMode(nint hConsoleHandle, out EConsoleMode lpMode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
[SupportedOSPlatform("FreeBSD")]
|
[SupportedOSPlatform("FreeBSD")]
|
||||||
[SupportedOSPlatform("Linux")]
|
[SupportedOSPlatform("Linux")]
|
||||||
[SupportedOSPlatform("MacOS")]
|
[SupportedOSPlatform("MacOS")]
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
[DllImport("libc", EntryPoint = "geteuid", SetLastError = true)]
|
[DllImport("libc", EntryPoint = "geteuid", SetLastError = true)]
|
||||||
internal static extern uint GetEuid();
|
internal static extern uint GetEuid();
|
||||||
#else
|
#else
|
||||||
@@ -77,28 +51,28 @@ internal static partial class NativeMethods {
|
|||||||
|
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
[SupportedOSPlatform("Windows")]
|
[SupportedOSPlatform("Windows")]
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
internal static extern nint GetStdHandle(int nStdHandle);
|
internal static extern nint GetStdHandle(EStandardHandle nStdHandle);
|
||||||
#else
|
#else
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
internal static partial nint GetStdHandle(int nStdHandle);
|
internal static partial nint GetStdHandle(EStandardHandle nStdHandle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
[SupportedOSPlatform("Windows")]
|
[SupportedOSPlatform("Windows")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
internal static extern bool SetConsoleMode(nint hConsoleHandle, uint dwMode);
|
internal static extern bool SetConsoleMode(nint hConsoleHandle, EConsoleMode dwMode);
|
||||||
#else
|
#else
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
internal static partial bool SetConsoleMode(nint hConsoleHandle, uint dwMode);
|
internal static partial bool SetConsoleMode(nint hConsoleHandle, EConsoleMode dwMode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
[SupportedOSPlatform("Windows")]
|
[SupportedOSPlatform("Windows")]
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
internal static extern EExecutionState SetThreadExecutionState(EExecutionState executionState);
|
internal static extern EExecutionState SetThreadExecutionState(EExecutionState executionState);
|
||||||
#else
|
#else
|
||||||
@@ -109,20 +83,37 @@ internal static partial class NativeMethods {
|
|||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
[SupportedOSPlatform("Windows")]
|
[SupportedOSPlatform("Windows")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
internal static extern void ShowWindow(nint hWnd, int nCmdShow);
|
internal static extern void ShowWindow(nint hWnd, EShowWindow nCmdShow);
|
||||||
#else
|
#else
|
||||||
[LibraryImport("user32.dll")]
|
[LibraryImport("user32.dll")]
|
||||||
internal static partial void ShowWindow(nint hWnd, int nCmdShow);
|
internal static partial void ShowWindow(nint hWnd, EShowWindow nCmdShow);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
[SupportedOSPlatform("Windows")]
|
||||||
|
internal enum EConsoleMode : uint {
|
||||||
|
EnableQuickEditMode = 0x0040
|
||||||
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
[SupportedOSPlatform("Windows")]
|
[SupportedOSPlatform("Windows")]
|
||||||
internal enum EExecutionState : uint {
|
internal enum EExecutionState : uint {
|
||||||
None = 0,
|
None = 0,
|
||||||
SystemRequired = 0x00000001,
|
SystemRequired = 0x00000001,
|
||||||
AwayModeRequired = 0x00000040,
|
AwayModeRequired = 0x00000040,
|
||||||
Continuous = 0x80000000
|
Continuous = 0x80000000,
|
||||||
|
Awake = SystemRequired | AwayModeRequired | Continuous
|
||||||
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("Windows")]
|
||||||
|
internal enum EShowWindow : uint {
|
||||||
|
Minimize = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("Windows")]
|
||||||
|
internal enum EStandardHandle {
|
||||||
|
Input = -10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ internal static class OS {
|
|||||||
internal static readonly string ProcessFileName = Environment.ProcessPath ?? throw new InvalidOperationException(nameof(ProcessFileName));
|
internal static readonly string ProcessFileName = Environment.ProcessPath ?? throw new InvalidOperationException(nameof(ProcessFileName));
|
||||||
|
|
||||||
internal static DateTime ProcessStartTime {
|
internal static DateTime ProcessStartTime {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
get => RuntimeMadness.ProcessStartTime.ToUniversalTime();
|
get => RuntimeMadness.ProcessStartTime.ToUniversalTime();
|
||||||
#else
|
#else
|
||||||
get {
|
get {
|
||||||
@@ -67,7 +67,7 @@ internal static class OS {
|
|||||||
framework = "Unknown Framework";
|
framework = "Unknown Framework";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
string runtime = RuntimeInformation.OSArchitecture.ToString();
|
string runtime = RuntimeInformation.OSArchitecture.ToString();
|
||||||
#else
|
#else
|
||||||
string runtime = RuntimeInformation.RuntimeIdentifier.Trim();
|
string runtime = RuntimeInformation.RuntimeIdentifier.Trim();
|
||||||
@@ -195,30 +195,6 @@ internal static class OS {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("FreeBSD")]
|
|
||||||
[SupportedOSPlatform("Linux")]
|
|
||||||
[SupportedOSPlatform("MacOS")]
|
|
||||||
internal static void UnixSetFileAccess(string path, EUnixPermission permission) {
|
|
||||||
if (string.IsNullOrEmpty(path)) {
|
|
||||||
throw new ArgumentNullException(nameof(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!OperatingSystem.IsFreeBSD() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) {
|
|
||||||
throw new PlatformNotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(path) && !Directory.Exists(path)) {
|
|
||||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"!{nameof(path)}"));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chmod() returns 0 on success, -1 on failure
|
|
||||||
if (NativeMethods.Chmod(path, (int) permission) != 0) {
|
|
||||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, Marshal.GetLastWin32Error()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void UnregisterProcess() {
|
internal static void UnregisterProcess() {
|
||||||
if (SingleInstance == null) {
|
if (SingleInstance == null) {
|
||||||
return;
|
return;
|
||||||
@@ -237,7 +213,7 @@ internal static class OS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SharedInfo.BuildInfo.Variant.EndsWith("-netf", StringComparison.Ordinal)) {
|
if (SharedInfo.BuildInfo.Variant.EndsWith("-netf", StringComparison.Ordinal)) {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
// All Windows variants (7+) have valid .NET Core build
|
// All Windows variants (7+) have valid .NET Core build
|
||||||
if (OperatingSystem.IsWindows()) {
|
if (OperatingSystem.IsWindows()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -300,15 +276,15 @@ internal static class OS {
|
|||||||
throw new PlatformNotSupportedException();
|
throw new PlatformNotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
nint consoleHandle = NativeMethods.GetStdHandle(NativeMethods.StandardInputHandle);
|
nint consoleHandle = NativeMethods.GetStdHandle(NativeMethods.EStandardHandle.Input);
|
||||||
|
|
||||||
if (!NativeMethods.GetConsoleMode(consoleHandle, out uint consoleMode)) {
|
if (!NativeMethods.GetConsoleMode(consoleHandle, out NativeMethods.EConsoleMode consoleMode)) {
|
||||||
ASF.ArchiLogger.LogGenericError(Strings.WarningFailed);
|
ASF.ArchiLogger.LogGenericError(Strings.WarningFailed);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleMode &= ~NativeMethods.EnableQuickEditMode;
|
consoleMode &= ~NativeMethods.EConsoleMode.EnableQuickEditMode;
|
||||||
|
|
||||||
if (!NativeMethods.SetConsoleMode(consoleHandle, consoleMode)) {
|
if (!NativeMethods.SetConsoleMode(consoleHandle, consoleMode)) {
|
||||||
ASF.ArchiLogger.LogGenericError(Strings.WarningFailed);
|
ASF.ArchiLogger.LogGenericError(Strings.WarningFailed);
|
||||||
@@ -324,7 +300,7 @@ internal static class OS {
|
|||||||
// This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
|
// This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
|
||||||
// If user wishes to enter sleep mode, then he should use ShutdownOnFarmingFinished or manage ASF process with third-party tool or script
|
// If user wishes to enter sleep mode, then he should use ShutdownOnFarmingFinished or manage ASF process with third-party tool or script
|
||||||
// See https://docs.microsoft.com/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate for more details
|
// See https://docs.microsoft.com/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate for more details
|
||||||
NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.AwakeExecutionState);
|
NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.EExecutionState.Awake);
|
||||||
|
|
||||||
// SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.None) in our case
|
// SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.None) in our case
|
||||||
if (result == NativeMethods.EExecutionState.None) {
|
if (result == NativeMethods.EExecutionState.None) {
|
||||||
@@ -340,23 +316,6 @@ internal static class OS {
|
|||||||
|
|
||||||
using Process process = Process.GetCurrentProcess();
|
using Process process = Process.GetCurrentProcess();
|
||||||
|
|
||||||
NativeMethods.ShowWindow(process.MainWindowHandle, NativeMethods.ShowWindowMinimize);
|
NativeMethods.ShowWindow(process.MainWindowHandle, NativeMethods.EShowWindow.Minimize);
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
[SupportedOSPlatform("FreeBSD")]
|
|
||||||
[SupportedOSPlatform("Linux")]
|
|
||||||
[SupportedOSPlatform("MacOS")]
|
|
||||||
internal enum EUnixPermission : ushort {
|
|
||||||
OtherExecute = 0x1,
|
|
||||||
OtherWrite = 0x2,
|
|
||||||
OtherRead = 0x4,
|
|
||||||
GroupExecute = 0x8,
|
|
||||||
GroupWrite = 0x10,
|
|
||||||
GroupRead = 0x20,
|
|
||||||
UserExecute = 0x40,
|
|
||||||
UserWrite = 0x80,
|
|
||||||
UserRead = 0x100,
|
|
||||||
Combined777 = UserRead | UserWrite | UserExecute | GroupRead | GroupWrite | GroupExecute | OtherRead | OtherWrite | OtherExecute
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public static class Utilities {
|
|||||||
|
|
||||||
CookieCollection cookies = cookieContainer.GetCookies(uri);
|
CookieCollection cookies = cookieContainer.GetCookies(uri);
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
return cookies.Count > 0 ? (from Cookie cookie in cookies where cookie.Name == name select cookie.Value).FirstOrDefault() : null;
|
return cookies.Count > 0 ? (from Cookie cookie in cookies where cookie.Name == name select cookie.Value).FirstOrDefault() : null;
|
||||||
#else
|
#else
|
||||||
return cookies.Count > 0 ? cookies.FirstOrDefault(cookie => cookie.Name == name)?.Value : null;
|
return cookies.Count > 0 ? cookies.FirstOrDefault(cookie => cookie.Name == name)?.Value : null;
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(directoryPath)) {
|
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
||||||
Directory.CreateDirectory(directoryPath);
|
if (!Directory.Exists(directoryPath!)) {
|
||||||
|
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
||||||
|
DirectoryInfo directoryInfo = Directory.CreateDirectory(directoryPath!);
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows()) {
|
if (OperatingSystem.IsWindows()) {
|
||||||
DirectoryInfo directoryInfo = new(directoryPath);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DirectorySecurity directorySecurity = new(directoryPath, AccessControlSections.All);
|
DirectorySecurity directorySecurity = new(directoryPath, AccessControlSections.All);
|
||||||
|
|
||||||
@@ -194,17 +194,16 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
|
|||||||
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
||||||
}
|
}
|
||||||
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||||
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
directoryInfo.UnixFileMode |= UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute | UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;
|
||||||
OS.UnixSetFileAccess(directoryPath!, OS.EUnixPermission.Combined777);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new FileStream(FilePath, FileMode.CreateNew).Dispose();
|
new FileStream(FilePath, FileMode.CreateNew).Dispose();
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows()) {
|
FileInfo fileInfo = new(FilePath);
|
||||||
FileInfo fileInfo = new(FilePath);
|
|
||||||
|
|
||||||
|
if (OperatingSystem.IsWindows()) {
|
||||||
try {
|
try {
|
||||||
FileSecurity fileSecurity = new(FilePath, AccessControlSections.All);
|
FileSecurity fileSecurity = new(FilePath, AccessControlSections.All);
|
||||||
|
|
||||||
@@ -214,7 +213,7 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
|
|||||||
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
||||||
}
|
}
|
||||||
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||||
OS.UnixSetFileAccess(FilePath, OS.EUnixPermission.Combined777);
|
fileInfo.UnixFileMode |= UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute | UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;
|
||||||
}
|
}
|
||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
// Ignored, if the file was already created in the meantime by another instance, this is fine
|
// Ignored, if the file was already created in the meantime by another instance, this is fine
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
using IHost = Microsoft.AspNetCore.Hosting.IWebHost;
|
using IHost = Microsoft.AspNetCore.Hosting.IWebHost;
|
||||||
using HostBuilder = Microsoft.AspNetCore.Hosting.WebHostBuilder;
|
using HostBuilder = Microsoft.AspNetCore.Hosting.WebHostBuilder;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
using MvcNewtonsoftJsonOptions = Microsoft.AspNetCore.Mvc.MvcJsonOptions;
|
using MvcNewtonsoftJsonOptions = Microsoft.AspNetCore.Mvc.MvcJsonOptions;
|
||||||
#endif
|
#endif
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||||
@@ -134,7 +134,7 @@ internal sealed class Startup {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Use routing for our API controllers, this should be called once we're done with all the static files mess
|
// Use routing for our API controllers, this should be called once we're done with all the static files mess
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ internal sealed class Startup {
|
|||||||
app.UseWebSockets();
|
app.UseWebSockets();
|
||||||
|
|
||||||
// Finally register proper API endpoints once we're done with routing
|
// Finally register proper API endpoints once we're done with routing
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
app.UseMvcWithDefaultRoute();
|
app.UseMvcWithDefaultRoute();
|
||||||
#else
|
#else
|
||||||
app.UseEndpoints(static endpoints => endpoints.MapControllers());
|
app.UseEndpoints(static endpoints => endpoints.MapControllers());
|
||||||
@@ -313,7 +313,7 @@ internal sealed class Startup {
|
|||||||
|
|
||||||
mvc.AddControllersAsServices();
|
mvc.AddControllersAsServices();
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
// Use latest compatibility version for MVC
|
// Use latest compatibility version for MVC
|
||||||
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
|
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ internal sealed class Startup {
|
|||||||
options.SerializerSettings.Formatting = Formatting.Indented;
|
options.SerializerSettings.Formatting = Formatting.Indented;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
|
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
|
||||||
options.SerializerSettings.Converters.Add(new VersionConverter());
|
options.SerializerSettings.Converters.Add(new VersionConverter());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
#endif
|
#endif
|
||||||
@@ -35,7 +35,7 @@ using Newtonsoft.Json;
|
|||||||
namespace ArchiSteamFarm.IPC;
|
namespace ArchiSteamFarm.IPC;
|
||||||
|
|
||||||
internal static class WebUtilities {
|
internal static class WebUtilities {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
internal static IMvcCoreBuilder AddControllers(this IServiceCollection services) {
|
internal static IMvcCoreBuilder AddControllers(this IServiceCollection services) {
|
||||||
ArgumentNullException.ThrowIfNull(services);
|
ArgumentNullException.ThrowIfNull(services);
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ using Newtonsoft.Json;
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
using SteamKit2;
|
using SteamKit2;
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
using System.Net.Quic;
|
using System.Net.Quic;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -59,13 +59,13 @@ internal static class Program {
|
|||||||
internal static bool ShutdownSequenceInitialized { get; private set; }
|
internal static bool ShutdownSequenceInitialized { get; private set; }
|
||||||
internal static bool SteamParentalGeneration { get; private set; } = true;
|
internal static bool SteamParentalGeneration { get; private set; } = true;
|
||||||
|
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
private static readonly Dictionary<PosixSignal, PosixSignalRegistration> RegisteredPosixSignals = new();
|
private static readonly Dictionary<PosixSignal, PosixSignalRegistration> RegisteredPosixSignals = new();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static readonly TaskCompletionSource<byte> ShutdownResetEvent = new();
|
private static readonly TaskCompletionSource<byte> ShutdownResetEvent = new();
|
||||||
|
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
private static readonly ImmutableHashSet<PosixSignal> SupportedPosixSignals = ImmutableHashSet.Create(PosixSignal.SIGINT, PosixSignal.SIGTERM);
|
private static readonly ImmutableHashSet<PosixSignal> SupportedPosixSignals = ImmutableHashSet.Create(PosixSignal.SIGINT, PosixSignal.SIGTERM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ internal static class Program {
|
|||||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||||
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
RuntimeMadness.Initialize();
|
RuntimeMadness.Initialize();
|
||||||
#else
|
#else
|
||||||
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||||
@@ -465,7 +465,7 @@ internal static class Program {
|
|||||||
|
|
||||||
ShutdownSequenceInitialized = true;
|
ShutdownSequenceInitialized = true;
|
||||||
|
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
|
||||||
// Unregister from registered signals
|
// Unregister from registered signals
|
||||||
foreach (PosixSignalRegistration registration in RegisteredPosixSignals.Values) {
|
foreach (PosixSignalRegistration registration in RegisteredPosixSignals.Values) {
|
||||||
@@ -510,7 +510,7 @@ internal static class Program {
|
|||||||
|
|
||||||
private static async void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) => await Exit(130).ConfigureAwait(false);
|
private static async void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) => await Exit(130).ConfigureAwait(false);
|
||||||
|
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
private static async void OnPosixSignal(PosixSignalContext signal) {
|
private static async void OnPosixSignal(PosixSignalContext signal) {
|
||||||
ArgumentNullException.ThrowIfNull(signal);
|
ArgumentNullException.ThrowIfNull(signal);
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
HttpClientHandler = new HttpClientHandler {
|
HttpClientHandler = new HttpClientHandler {
|
||||||
AllowAutoRedirect = false, // This must be false if we want to handle custom redirection schemes such as "steammobile://"
|
AllowAutoRedirect = false, // This must be false if we want to handle custom redirection schemes such as "steammobile://"
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
|
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
|
||||||
#else
|
#else
|
||||||
AutomaticDecompression = DecompressionMethods.All,
|
AutomaticDecompression = DecompressionMethods.All,
|
||||||
@@ -85,7 +85,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
if (!RuntimeMadness.IsRunningOnMono) {
|
if (!RuntimeMadness.IsRunningOnMono) {
|
||||||
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
|
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
byte connectionTimeout = ASF.GlobalConfig?.ConnectionTimeout ?? GlobalConfig.DefaultConnectionTimeout;
|
byte connectionTimeout = ASF.GlobalConfig?.ConnectionTimeout ?? GlobalConfig.DefaultConnectionTimeout;
|
||||||
|
|
||||||
HttpClient result = new(HttpClientHandler, false) {
|
HttpClient result = new(HttpClientHandler, false) {
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
DefaultRequestVersion = HttpVersion.Version30,
|
DefaultRequestVersion = HttpVersion.Version30,
|
||||||
#endif
|
#endif
|
||||||
Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeout : connectionTimeout)
|
Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeout : connectionTimeout)
|
||||||
@@ -662,7 +662,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
using StreamReader streamReader = new(response.Content);
|
using StreamReader streamReader = new(response.Content);
|
||||||
|
|
||||||
#pragma warning disable CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
|
#pragma warning disable CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
|
||||||
JsonReader jsonReader = new JsonTextReader(streamReader);
|
JsonTextReader jsonReader = new(streamReader);
|
||||||
#pragma warning restore CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
|
#pragma warning restore CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
|
||||||
|
|
||||||
await using (jsonReader.ConfigureAwait(false)) {
|
await using (jsonReader.ConfigureAwait(false)) {
|
||||||
@@ -766,7 +766,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
ServicePointManager.Expect100Continue = false;
|
ServicePointManager.Expect100Continue = false;
|
||||||
|
|
||||||
// Reuse ports if possible
|
// Reuse ports if possible
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
if (!RuntimeMadness.IsRunningOnMono) {
|
if (!RuntimeMadness.IsRunningOnMono) {
|
||||||
ServicePointManager.ReusePort = true;
|
ServicePointManager.ReusePort = true;
|
||||||
}
|
}
|
||||||
@@ -801,7 +801,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
using (HttpRequestMessage requestMessage = new(httpMethod, request)) {
|
using (HttpRequestMessage requestMessage = new(httpMethod, request)) {
|
||||||
#if !NETFRAMEWORK
|
#if !NETFRAMEWORK && !NETSTANDARD
|
||||||
requestMessage.Version = HttpClient.DefaultRequestVersion;
|
requestMessage.Version = HttpClient.DefaultRequestVersion;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ internal static class WebBrowserUtilities {
|
|||||||
private static (Stream CompressionInput, string ContentEncoding) GetBestSupportedCompressionMethod(Stream output) {
|
private static (Stream CompressionInput, string ContentEncoding) GetBestSupportedCompressionMethod(Stream output) {
|
||||||
ArgumentNullException.ThrowIfNull(output);
|
ArgumentNullException.ThrowIfNull(output);
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK || NETSTANDARD
|
||||||
return (new GZipStream(output, CompressionLevel.Optimal, true), "gzip");
|
return (new GZipStream(output, CompressionLevel.Optimal, true), "gzip");
|
||||||
#else
|
#else
|
||||||
return (new BrotliStream(output, CompressionLevel.SmallestSize, true), "br");
|
return (new BrotliStream(output, CompressionLevel.SmallestSize, true), "br");
|
||||||
|
|||||||
@@ -29,18 +29,19 @@
|
|||||||
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
|
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
|
||||||
<RollForward>LatestMajor</RollForward>
|
<RollForward>LatestMajor</RollForward>
|
||||||
<RuntimeIdentifiers>linux-arm;linux-arm64;linux-x64;osx-arm64;osx-x64;win-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>linux-arm;linux-arm64;linux-x64;osx-arm64;osx-x64;win-x64</RuntimeIdentifiers>
|
||||||
|
<TargetFrameworks>net7.0</TargetFrameworks>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(OS)' == 'Windows_NT' OR '$(ASFNetFramework)' != ''">
|
<PropertyGroup Condition="'$(OS)' == 'Windows_NT' OR '$(ASFNetFramework)' != ''">
|
||||||
<TargetFrameworks>net7.0;net481</TargetFrameworks>
|
<TargetFrameworks>$(TargetFrameworks);net481</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(OS)' != 'Windows_NT' AND '$(ASFNetFramework)' == ''">
|
<PropertyGroup Condition="'$(ASFNetStandard)' != ''">
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFrameworks>$(TargetFrameworks);netstandard2.1</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<PackageReference Include="JustArchiNET.Madness" />
|
<PackageReference Include="JustArchiNET.Madness" />
|
||||||
<PackageReference Include="TA.System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray" />
|
<PackageReference Include="TA.System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray" />
|
||||||
|
|
||||||
@@ -48,9 +49,13 @@
|
|||||||
<Using Include="JustArchiNET.Madness.ArgumentNullExceptionMadness.ArgumentNullException" Alias="ArgumentNullException" />
|
<Using Include="JustArchiNET.Madness.ArgumentNullExceptionMadness.ArgumentNullException" Alias="ArgumentNullException" />
|
||||||
<Using Include="JustArchiNET.Madness.ArrayMadness.Array" Alias="Array" />
|
<Using Include="JustArchiNET.Madness.ArrayMadness.Array" Alias="Array" />
|
||||||
<Using Include="JustArchiNET.Madness.ConvertMadness.Convert" Alias="Convert" />
|
<Using Include="JustArchiNET.Madness.ConvertMadness.Convert" Alias="Convert" />
|
||||||
|
<Using Include="JustArchiNET.Madness.DirectoryInfoMadness.DirectoryInfo" Alias="DirectoryInfo" />
|
||||||
|
<Using Include="JustArchiNET.Madness.DirectoryMadness.Directory" Alias="Directory" />
|
||||||
<Using Include="JustArchiNET.Madness.EnumMadness.Enum" Alias="Enum" />
|
<Using Include="JustArchiNET.Madness.EnumMadness.Enum" Alias="Enum" />
|
||||||
<Using Include="JustArchiNET.Madness.EnvironmentMadness.Environment" Alias="Environment" />
|
<Using Include="JustArchiNET.Madness.EnvironmentMadness.Environment" Alias="Environment" />
|
||||||
|
<Using Include="JustArchiNET.Madness.FileInfoMadness.FileInfo" Alias="FileInfo" />
|
||||||
<Using Include="JustArchiNET.Madness.FileMadness.File" Alias="File" />
|
<Using Include="JustArchiNET.Madness.FileMadness.File" Alias="File" />
|
||||||
|
<Using Include="JustArchiNET.Madness.FileMadness.UnixFileMode" Alias="UnixFileMode" />
|
||||||
<Using Include="JustArchiNET.Madness.HashCodeMadness.HashCode" Alias="HashCode" />
|
<Using Include="JustArchiNET.Madness.HashCodeMadness.HashCode" Alias="HashCode" />
|
||||||
<Using Include="JustArchiNET.Madness.HMACSHA1Madness.HMACSHA1" Alias="HMACSHA1" />
|
<Using Include="JustArchiNET.Madness.HMACSHA1Madness.HMACSHA1" Alias="HMACSHA1" />
|
||||||
<Using Include="JustArchiNET.Madness.HttpRequestExceptionMadness.HttpRequestException" Alias="HttpRequestException" />
|
<Using Include="JustArchiNET.Madness.HttpRequestExceptionMadness.HttpRequestException" Alias="HttpRequestException" />
|
||||||
@@ -63,6 +68,11 @@
|
|||||||
<Using Include="JustArchiNET.Madness.StringMadness.String" Alias="String" />
|
<Using Include="JustArchiNET.Madness.StringMadness.String" Alias="String" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
|
||||||
|
<Using Include="JustArchiNET.Madness.NewtonsoftJsonMadness.JsonTextReader" Alias="JsonTextReader" />
|
||||||
|
<Using Include="JustArchiNET.Madness.NewtonsoftJsonMadness.JsonTextWriter" Alias="JsonTextWriter" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(ASFVariant)' != ''">
|
<PropertyGroup Condition="'$(ASFVariant)' != ''">
|
||||||
<DefineConstants>$(DefineConstants);ASF_VARIANT_$(ASFVariant.Replace('-', '_').ToUpperInvariant())</DefineConstants>
|
<DefineConstants>$(DefineConstants);ASF_VARIANT_$(ASFVariant.Replace('-', '_').ToUpperInvariant())</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
<PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="7.0.0" />
|
<PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net481'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
<PackageVersion Include="JustArchiNET.Madness" Version="3.10.0" />
|
<PackageVersion Include="JustArchiNET.Madness" Version="3.11.0" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
<PackageVersion Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
|
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
|
<PackageVersion Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
|
||||||
@@ -40,4 +40,8 @@
|
|||||||
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="3.1.32" />
|
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="3.1.32" />
|
||||||
<PackageVersion Include="TA.System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray" Version="1.0.1" />
|
<PackageVersion Include="TA.System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray" Version="1.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
|
||||||
|
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user