mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-16 14:30:31 +00:00
@@ -324,6 +324,7 @@
|
|||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AES/@EntryIndexedValue">AES</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AES/@EntryIndexedValue">AES</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ASF/@EntryIndexedValue">ASF</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ASF/@EntryIndexedValue">ASF</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EWCF/@EntryIndexedValue">EWCF</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FA/@EntryIndexedValue">FA</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FA/@EntryIndexedValue">FA</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FS/@EntryIndexedValue">FS</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FS/@EntryIndexedValue">FS</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
|
||||||
@@ -337,6 +338,7 @@
|
|||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TTL/@EntryIndexedValue">TTL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TTL/@EntryIndexedValue">TTL</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WCF/@EntryIndexedValue">WCF</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WCF/@EntryIndexedValue">WCF</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WS/@EntryIndexedValue">WS</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WTF/@EntryIndexedValue">WTF</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WTF/@EntryIndexedValue">WTF</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XML/@EntryIndexedValue">XML</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XML/@EntryIndexedValue">XML</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="I" Suffix="" Style="AaBb" /></Policy></s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="I" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ namespace ArchiSteamFarm {
|
|||||||
internal const byte DefaultConnectionTimeout = 60;
|
internal const byte DefaultConnectionTimeout = 60;
|
||||||
internal const ushort DefaultWCFPort = 1242;
|
internal const ushort DefaultWCFPort = 1242;
|
||||||
|
|
||||||
private const byte DefaultFarmingDelay = 15;
|
|
||||||
private const byte DefaultMaxFarmingTime = 10;
|
|
||||||
private const ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
|
|
||||||
|
|
||||||
// This is hardcoded blacklist which should not be possible to change
|
// This is hardcoded blacklist which should not be possible to change
|
||||||
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280, 480730, 566020 };
|
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280, 480730, 566020 };
|
||||||
|
|
||||||
@@ -64,7 +60,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal readonly bool Debug = false;
|
internal readonly bool Debug = false;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly byte FarmingDelay = DefaultFarmingDelay;
|
internal readonly byte FarmingDelay = 15;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly byte GiftsLimiterDelay = 1;
|
internal readonly byte GiftsLimiterDelay = 1;
|
||||||
@@ -82,7 +78,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal readonly byte LoginLimiterDelay = 10;
|
internal readonly byte LoginLimiterDelay = 10;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly byte MaxFarmingTime = DefaultMaxFarmingTime;
|
internal readonly byte MaxFarmingTime = 10;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly byte MaxTradeHoldDuration = 15;
|
internal readonly byte MaxTradeHoldDuration = 15;
|
||||||
@@ -97,16 +93,19 @@ namespace ArchiSteamFarm {
|
|||||||
internal readonly ulong SteamOwnerID = 0;
|
internal readonly ulong SteamOwnerID = 0;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly ProtocolType SteamProtocol = DefaultSteamProtocol;
|
internal readonly ProtocolType SteamProtocol = ProtocolType.Tcp;
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly EUpdateChannel UpdateChannel = EUpdateChannel.Stable;
|
internal readonly EUpdateChannel UpdateChannel = EUpdateChannel.Stable;
|
||||||
|
|
||||||
|
[JsonProperty]
|
||||||
|
internal string WCFHost { get; set; } = "127.0.0.1";
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly ushort WCFPort = DefaultWCFPort;
|
internal readonly ushort WCFPort = DefaultWCFPort;
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal string WCFHost { get; set; } = "127.0.0.1";
|
internal readonly EWCFProtocol WCFProtocol = EWCFProtocol.NetTcp;
|
||||||
|
|
||||||
// This constructor is used only by deserializer
|
// This constructor is used only by deserializer
|
||||||
private GlobalConfig() { }
|
private GlobalConfig() { }
|
||||||
@@ -182,5 +181,12 @@ namespace ArchiSteamFarm {
|
|||||||
Stable,
|
Stable,
|
||||||
Experimental
|
Experimental
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||||
|
internal enum EWCFProtocol : byte {
|
||||||
|
NetTcp,
|
||||||
|
BasicHttp,
|
||||||
|
WSHttp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,8 +39,6 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class WCF : IWCF, IDisposable {
|
internal sealed class WCF : IWCF, IDisposable {
|
||||||
private static string URL = "net.tcp://127.0.0.1:1242/ASF";
|
|
||||||
|
|
||||||
internal bool IsServerRunning => ServiceHost != null;
|
internal bool IsServerRunning => ServiceHost != null;
|
||||||
|
|
||||||
private Client Client;
|
private Client Client;
|
||||||
@@ -81,12 +79,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal static void Init() {
|
internal static void Init() {
|
||||||
if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) {
|
if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) {
|
||||||
Program.GlobalConfig.WCFHost = Program.GetUserInput(ASF.EUserInputType.WCFHostname);
|
Program.GlobalConfig.WCFHost = Program.GetUserInput(ASF.EUserInputType.WCFHostname);
|
||||||
if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
URL = "net.tcp://" + Program.GlobalConfig.WCFHost + ":" + Program.GlobalConfig.WCFPort + "/ASF";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string SendCommand(string input) {
|
internal string SendCommand(string input) {
|
||||||
@@ -95,17 +88,24 @@ namespace ArchiSteamFarm {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFSendingCommand, input, URL));
|
Binding binding = GetTargetBinding();
|
||||||
|
if (binding == null) {
|
||||||
|
ASF.ArchiLogger.LogNullError(nameof(binding));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string url = GetUrlFromBinding(binding);
|
||||||
|
if (string.IsNullOrEmpty(url)) {
|
||||||
|
ASF.ArchiLogger.LogNullError(nameof(url));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFSendingCommand, input, url));
|
||||||
|
|
||||||
if (Client == null) {
|
if (Client == null) {
|
||||||
Client = new Client(
|
Client = new Client(
|
||||||
new NetTcpBinding {
|
binding,
|
||||||
// We use SecurityMode.None for Mono compatibility
|
new EndpointAddress(url)
|
||||||
// Yes, also on Windows, for Mono<->Windows communication
|
|
||||||
Security = { Mode = SecurityMode.None },
|
|
||||||
SendTimeout = new TimeSpan(0, 0, Program.GlobalConfig.ConnectionTimeout)
|
|
||||||
},
|
|
||||||
new EndpointAddress(URL)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,20 +117,28 @@ namespace ArchiSteamFarm {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFStarting, URL));
|
Binding binding = GetTargetBinding();
|
||||||
|
if (binding == null) {
|
||||||
|
ASF.ArchiLogger.LogNullError(nameof(binding));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string url = GetUrlFromBinding(binding);
|
||||||
|
if (string.IsNullOrEmpty(url)) {
|
||||||
|
ASF.ArchiLogger.LogNullError(nameof(url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFStarting, url));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL));
|
ServiceHost = new ServiceHost(typeof(WCF), new Uri(url));
|
||||||
ServiceHost.AddServiceEndpoint(
|
ServiceHost.AddServiceEndpoint(
|
||||||
typeof(IWCF),
|
typeof(IWCF),
|
||||||
new NetTcpBinding {
|
binding,
|
||||||
// We use SecurityMode.None for Mono compatibility
|
|
||||||
// Yes, also on Windows, for Mono<->Windows communication
|
|
||||||
Security = { Mode = SecurityMode.None },
|
|
||||||
SendTimeout = new TimeSpan(0, 0, Program.GlobalConfig.ConnectionTimeout)
|
|
||||||
},
|
|
||||||
string.Empty
|
string.Empty
|
||||||
);
|
);
|
||||||
|
|
||||||
ServiceHost.Open();
|
ServiceHost.Open();
|
||||||
|
|
||||||
ASF.ArchiLogger.LogGenericInfo(Strings.WCFReady);
|
ASF.ArchiLogger.LogGenericInfo(Strings.WCFReady);
|
||||||
@@ -157,6 +165,46 @@ namespace ArchiSteamFarm {
|
|||||||
ServiceHost = null;
|
ServiceHost = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetUrlFromBinding(Binding binding) {
|
||||||
|
if (binding != null) {
|
||||||
|
return binding.Scheme + "://" + Program.GlobalConfig.WCFHost + ":" + Program.GlobalConfig.WCFPort + "/ASF";
|
||||||
|
}
|
||||||
|
|
||||||
|
ASF.ArchiLogger.LogNullError(nameof(binding));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Binding GetTargetBinding() {
|
||||||
|
Binding result;
|
||||||
|
switch (Program.GlobalConfig.WCFProtocol) {
|
||||||
|
case GlobalConfig.EWCFProtocol.NetTcp:
|
||||||
|
result = new NetTcpBinding {
|
||||||
|
// We use SecurityMode.None for Mono compatibility
|
||||||
|
// Yes, also on Windows, for Mono<->Windows communication
|
||||||
|
Security = { Mode = SecurityMode.None }
|
||||||
|
};
|
||||||
|
|
||||||
|
break;
|
||||||
|
case GlobalConfig.EWCFProtocol.BasicHttp:
|
||||||
|
result = new BasicHttpBinding();
|
||||||
|
break;
|
||||||
|
case GlobalConfig.EWCFProtocol.WSHttp:
|
||||||
|
result = new WSHttpBinding {
|
||||||
|
// We use SecurityMode.None for Mono compatibility
|
||||||
|
// Yes, also on Windows, for Mono<->Windows communication
|
||||||
|
Security = { Mode = SecurityMode.None }
|
||||||
|
};
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(Program.GlobalConfig.WCFProtocol), Program.GlobalConfig.WCFProtocol));
|
||||||
|
goto case GlobalConfig.EWCFProtocol.NetTcp;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.SendTimeout = new TimeSpan(0, 0, Program.GlobalConfig.ConnectionTimeout);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void StopClient() {
|
private void StopClient() {
|
||||||
if (Client == null) {
|
if (Client == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,5 +27,6 @@
|
|||||||
"SteamProtocol": 6,
|
"SteamProtocol": 6,
|
||||||
"UpdateChannel": 1,
|
"UpdateChannel": 1,
|
||||||
"WCFHost": "127.0.0.1",
|
"WCFHost": "127.0.0.1",
|
||||||
"WCFPort": 1242
|
"WCFPort": 1242,
|
||||||
|
"WCFProtocol": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user