mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Implement IPCPrefixes
This makes it possible to not only listen on multiple different host/port combinations, but also different protocols or base URLs (even though this will probably break things up, need to do more tests)
This commit is contained in:
@@ -90,9 +90,9 @@ namespace ArchiSteamFarm {
|
||||
HistoryTarget = historyTarget;
|
||||
}
|
||||
|
||||
internal static void Start(string host, ushort port) {
|
||||
if (string.IsNullOrEmpty(host) || (port == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(host) + " || " + nameof(port));
|
||||
internal static void Start(HashSet<string> prefixes) {
|
||||
if ((prefixes == null) || (prefixes.Count == 0)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(prefixes));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,21 +101,14 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (host) {
|
||||
case "0.0.0.0":
|
||||
case "::":
|
||||
// Silently map INADDR_ANY to match HttpListener expectations
|
||||
host = "*";
|
||||
break;
|
||||
}
|
||||
|
||||
string url = "http://" + host + ":" + port + "/";
|
||||
HttpListener = new HttpListener { IgnoreWriteExceptions = true };
|
||||
|
||||
try {
|
||||
ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.IPCStarting, url));
|
||||
foreach (string prefix in prefixes) {
|
||||
ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.IPCStarting, prefix));
|
||||
HttpListener.Prefixes.Add(prefix);
|
||||
}
|
||||
|
||||
HttpListener.Prefixes.Add(url);
|
||||
HttpListener.Start();
|
||||
} catch (Exception e) {
|
||||
// HttpListener can dispose itself on error, so don't keep it around
|
||||
|
||||
Reference in New Issue
Block a user