Add magic apn

This commit is contained in:
Oleksandr Zhyzhchenko 2026-04-01 15:02:33 +03:00
parent 312be86e27
commit fc7ddf2668
3 changed files with 36 additions and 7 deletions

View File

@ -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)

View File

@ -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
/// </summary>
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<OnlinesSettings>();
KlonFUN = conf.ToObject<ModuleConfig>();
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;
}
}

13
KlonFUN/ModuleConfig.cs Normal file
View File

@ -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; }
}
}