mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 17:32:20 +00:00
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.
This commit is contained in:
parent
e846ce65b3
commit
43808b819f
@ -17,12 +17,24 @@ namespace Shared.Engine
|
|||||||
if (conf == null)
|
if (conf == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!conf.TryGetValue("apn", out var apnToken) || apnToken?.Type != JTokenType.Boolean)
|
if (!conf.TryGetValue("apn", out var apnToken) || apnToken == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
enabled = apnToken.Value<bool>();
|
if (apnToken.Type == JTokenType.Boolean)
|
||||||
host = conf.Value<string>("apn_host");
|
{
|
||||||
return true;
|
enabled = apnToken.Value<bool>();
|
||||||
|
host = conf.Value<string>("apn_host");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apnToken.Type == JTokenType.String)
|
||||||
|
{
|
||||||
|
host = apnToken.Value<string>();
|
||||||
|
enabled = !string.IsNullOrWhiteSpace(host);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyInitConf(bool enabled, string host, BaseSettings init)
|
public static void ApplyInitConf(bool enabled, string host, BaseSettings init)
|
||||||
|
|||||||
@ -54,8 +54,11 @@ namespace Makhno
|
|||||||
};
|
};
|
||||||
var conf = ModuleInvoke.Conf("Makhno", Makhno);
|
var conf = ModuleInvoke.Conf("Makhno", Makhno);
|
||||||
bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost);
|
bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost);
|
||||||
conf.Remove("apn");
|
if (hasApn)
|
||||||
conf.Remove("apn_host");
|
{
|
||||||
|
conf.Remove("apn");
|
||||||
|
conf.Remove("apn_host");
|
||||||
|
}
|
||||||
Makhno = conf.ToObject<OnlinesSettings>();
|
Makhno = conf.ToObject<OnlinesSettings>();
|
||||||
if (hasApn)
|
if (hasApn)
|
||||||
ApnHelper.ApplyInitConf(apnEnabled, apnHost, Makhno);
|
ApnHelper.ApplyInitConf(apnEnabled, apnHost, Makhno);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user