From 43808b819f9d08a11c9a1bd87fe8315c11a11590 Mon Sep 17 00:00:00 2001 From: baliasnyifeliks Date: Wed, 4 Feb 2026 14:06:39 +0200 Subject: [PATCH] feat(makhno): support string-based APN configuration Allow APN configuration to be specified as a single string value in addition to the existing boolean + host format. When 'apn' is a string, it is used as the host and enabled is set automatically. --- Makhno/ApnHelper.cs | 20 ++++++++++++++++---- Makhno/ModInit.cs | 7 +++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makhno/ApnHelper.cs b/Makhno/ApnHelper.cs index 394a5bc..13e9176 100644 --- a/Makhno/ApnHelper.cs +++ b/Makhno/ApnHelper.cs @@ -17,12 +17,24 @@ namespace Shared.Engine if (conf == null) return false; - if (!conf.TryGetValue("apn", out var apnToken) || apnToken?.Type != JTokenType.Boolean) + if (!conf.TryGetValue("apn", out var apnToken) || apnToken == null) return false; - enabled = apnToken.Value(); - host = conf.Value("apn_host"); - return true; + if (apnToken.Type == JTokenType.Boolean) + { + enabled = apnToken.Value(); + host = conf.Value("apn_host"); + return true; + } + + if (apnToken.Type == JTokenType.String) + { + host = apnToken.Value(); + enabled = !string.IsNullOrWhiteSpace(host); + return true; + } + + return false; } public static void ApplyInitConf(bool enabled, string host, BaseSettings init) diff --git a/Makhno/ModInit.cs b/Makhno/ModInit.cs index 23151a7..f6f95a5 100644 --- a/Makhno/ModInit.cs +++ b/Makhno/ModInit.cs @@ -54,8 +54,11 @@ namespace Makhno }; var conf = ModuleInvoke.Conf("Makhno", Makhno); bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost); - conf.Remove("apn"); - conf.Remove("apn_host"); + if (hasApn) + { + conf.Remove("apn"); + conf.Remove("apn_host"); + } Makhno = conf.ToObject(); if (hasApn) ApnHelper.ApplyInitConf(apnEnabled, apnHost, Makhno);