Config: Add initial implementation

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-18 20:11:17 +03:00
parent c163558976
commit e432987032
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
2 changed files with 38 additions and 0 deletions

36
src/logic/config.vala Normal file
View file

@ -0,0 +1,36 @@
/* config.vala
*
* Copyright 2025 Vasiliy Doylov (NekoCWD) <nekocwd@mainlining.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
class Singularity.SingConfig : Object, Json.Serializable {
public List<Outbound.Outbound> outbounds { get; owned set; default = new List<Outbound.Outbound> (); }
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
if (property_name == "outbounds") {
var node = Utils.serialize_object_list<Outbound.Outbound> (outbounds);
var arr = node.get_array ();
arr.foreach_element ((_, __, node) => {
var _node = node;
Utils.fix_type (ref _node);
Utils.fix_dash (ref _node);
});
return node;
}
return default_serialize_property (property_name, value, pspec);;
}
}

View file

@ -1,4 +1,5 @@
utils_sources = 'logic/utils.vala'
config_sources = 'logic/config.vala'
singularity_deps += [
dependency('json-glib-1.0'),
@ -11,4 +12,5 @@ singularity_sources += [
utils_sources,
outbounds_sources,
transports_sources,
config_sources,
]