diff --git a/src/logic/config.vala b/src/logic/config.vala new file mode 100644 index 0000000..d0d266e --- /dev/null +++ b/src/logic/config.vala @@ -0,0 +1,36 @@ +/* config.vala + * + * Copyright 2025 Vasiliy Doylov (NekoCWD) + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +class Singularity.SingConfig : Object, Json.Serializable { + public List outbounds { get; owned set; default = new List (); } + 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 (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);; + } +} diff --git a/src/logic/meson.build b/src/logic/meson.build index 0fffdbf..eb0909d 100644 --- a/src/logic/meson.build +++ b/src/logic/meson.build @@ -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, ]