using Newtonsoft.Json.Linq; using Shared; using Shared.Engine; using Shared.Models.Module; using Shared.Models.Module.Interfaces; using Shared.Models.Online.Settings; using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis.Scripting; using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json; using Shared.Models; using Shared.Models.Events; using System; using System.Net.Http; using System.Net.Mime; using System.Net.Security; using System.Security.Authentication; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; namespace LME.StarLight { public class ModInit : IModuleLoaded { public static double Version => 4.1; public static OnlinesSettings StarLight; public static bool ApnHostProvided; public static OnlinesSettings Settings { get => StarLight; set => StarLight = value; } /// /// модуль загружен /// public void Loaded(InitspaceModel initspace) { StarLight = new OnlinesSettings("LME.StarLight", "https://tp-back.starlight.digital", streamproxy: false, useproxy: false) { displayname = "StarLight", displayindex = 0, proxy = new Shared.Models.Base.ProxySettings() { useAuth = true, username = "", password = "", list = new string[] { "socks5://ip:port" } } }; var defaults = JObject.FromObject(StarLight); defaults["enabled"] = true; var conf = ModuleInvoke.Init("LME.StarLight", defaults); bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost); conf.Remove("apn"); conf.Remove("apn_host"); StarLight = conf.ToObject(); if (hasApn) ApnHelper.ApplyInitConf(apnEnabled, apnHost, StarLight, useDefaultHostWhenEmpty: true); ApnHostProvided = hasApn && apnEnabled && !string.IsNullOrWhiteSpace(apnHost); if (hasApn && apnEnabled) { StarLight.streamproxy = false; } else if (StarLight.streamproxy) { StarLight.apnstream = false; StarLight.apn = null; } // Виводити "уточнити пошук" OnlineRegistry.RegisterWithSearch("lme_starlight"); } public void Dispose() { } } public static class UpdateService { private static readonly ModuleUpdateService _service = new( () => ModInit.Settings?.plugin, () => ModInit.Version); public static Task ConnectAsync(string host, CancellationToken cancellationToken = default) => _service.ConnectAsync(host, cancellationToken); public static bool IsDisconnected() => _service.IsDisconnected(); public static ActionResult Validate(ActionResult result) => _service.Validate(result); } }