diff --git a/KlonFUN/Controller.cs b/KlonFUN/Controller.cs index d9b5470..e9f108b 100644 --- a/KlonFUN/Controller.cs +++ b/KlonFUN/Controller.cs @@ -31,6 +31,14 @@ namespace KlonFUN.Controllers if (!init.enable) return Forbid(); + if (init.apn is null + && !init.streamproxy + && init.magic_apn + && new RchClient(HttpContext, host, init, requestInfo).InfoConnected().player == "inner") + { + ApnHelper.ApplyInitConf(true, null, init); + } + var invoke = new KlonFUNInvoke(init, hybridCache, OnLog, proxyManager, httpHydra); if (checksearch) diff --git a/KlonFUN/ModInit.cs b/KlonFUN/ModInit.cs index c413a40..bf4a084 100644 --- a/KlonFUN/ModInit.cs +++ b/KlonFUN/ModInit.cs @@ -14,6 +14,7 @@ using System.Security.Authentication; using System.Text; using System.Threading; using System.Threading.Tasks; +using Shared.Models.Events; namespace KlonFUN { @@ -21,10 +22,10 @@ namespace KlonFUN { public static double Version => 2.0; - public static OnlinesSettings KlonFUN; + public static ModuleConfig KlonFUN; public static bool ApnHostProvided; - public static OnlinesSettings Settings + public static ModuleConfig Settings { get => KlonFUN; set => KlonFUN = value; @@ -35,7 +36,16 @@ namespace KlonFUN /// public void Loaded(InitspaceModel initspace) { - KlonFUN = new OnlinesSettings("KlonFUN", "https://klon.fun", streamproxy: false, useproxy: false) + UpdateConfig(); + EventListener.UpdateInitFile += UpdateConfig; + + // Додаємо підтримку "уточнити пошук". + RegisterWithSearch("klonfun"); + } + + private void UpdateConfig() + { + KlonFUN = new ModuleConfig("KlonFUN", "https://klon.fun", streamproxy: false, useproxy: false) { displayname = "KlonFUN", displayindex = 0, @@ -52,7 +62,7 @@ namespace KlonFUN bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost); conf.Remove("apn"); conf.Remove("apn_host"); - KlonFUN = conf.ToObject(); + KlonFUN = conf.ToObject(); if (hasApn) ApnHelper.ApplyInitConf(apnEnabled, apnHost, KlonFUN); ApnHostProvided = hasApn && apnEnabled && !string.IsNullOrWhiteSpace(apnHost); @@ -66,9 +76,6 @@ namespace KlonFUN KlonFUN.apnstream = false; KlonFUN.apn = null; } - - // Додаємо підтримку "уточнити пошук". - RegisterWithSearch("klonfun"); } private static void RegisterWithSearch(string plugin) @@ -107,6 +114,7 @@ namespace KlonFUN public void Dispose() { + EventListener.UpdateInitFile -= UpdateConfig; } } diff --git a/KlonFUN/ModuleConfig.cs b/KlonFUN/ModuleConfig.cs new file mode 100644 index 0000000..ee88cc6 --- /dev/null +++ b/KlonFUN/ModuleConfig.cs @@ -0,0 +1,13 @@ +using Shared.Models.Online.Settings; + +namespace KlonFUN +{ + public class ModuleConfig : OnlinesSettings + { + public ModuleConfig(string plugin, string host, string apihost = null, bool useproxy = false, string token = null, bool enable = true, bool streamproxy = false, bool rip = false, bool forceEncryptToken = false, string rch_access = null, string stream_access = null) : base(plugin, host, apihost, useproxy, token, enable, streamproxy, rip, forceEncryptToken, rch_access, stream_access) + { + } + + public bool magic_apn { get; set; } + } +}