Fix refs
All checks were successful
PostmarketOS Build / Prepare (push) Successful in 7s
PostmarketOS Build / Build for aarch64 (push) Successful in 40s
PostmarketOS Build / Build for x86_64 (push) Successful in 14s

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-22 01:58:13 +03:00
parent 7c634dbfd5
commit 0ca6e4080e
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
5 changed files with 12 additions and 12 deletions

View file

@ -24,11 +24,11 @@ class Singularity.SingConfig : Object, Json.Serializable {
if (property_name == "outbounds") {
var node = Utils.serialize_object_list<Outbound.Outbound> (outbounds);
var arr = node.get_array ();
var new_arr = new Json.Array ();
arr.foreach_element ((_, __, node) => {
var _node = node;
Utils.fix_type (ref _node);
Utils.fix_dash (ref _node);
new_arr.add_element (Utils.fix_dash (Utils.fix_type (node)));
});
node.set_array (new_arr);
return node;
}
return default_serialize_property (property_name, value, pspec);;

View file

@ -42,11 +42,10 @@ class Singularity.Outbound.Trojan : Dial, Json.Serializable {
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
var node = default_serialize_property (property_name, value, pspec);
if (property_name == "transport" && transport != null) {
Utils.fix_type (ref node);
Utils.fix_dash (ref node);
return Utils.fix_dash (Utils.fix_type (node));
}
if (property_name == "tls" && tls != null) {
Utils.fix_dash (ref node);
return Utils.fix_dash (node);
}
return node;
}

View file

@ -43,11 +43,10 @@ class Singularity.Outbound.Vless : Dial, Json.Serializable {
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
var node = default_serialize_property (property_name, value, pspec);
if (property_name == "transport" && transport != null) {
Utils.fix_type (ref node);
Utils.fix_dash (ref node);
return Utils.fix_dash (Utils.fix_type (node));
}
if (property_name == "tls" && tls != null) {
Utils.fix_dash (ref node);
return Utils.fix_dash (node);
}
return node;
}

View file

@ -37,7 +37,7 @@ class Singularity.TLS : Object, Json.Serializable {
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
var node = default_serialize_property (property_name, value, pspec);
if (property_name == "reality" && reality != null) {
Utils.fix_dash (ref node);
return Utils.fix_dash (node);
}
return node;
}

View file

@ -26,7 +26,7 @@ namespace Singularity.Utils {
* Vala use `meow-meow-meow` as in json serialization, but we need to use
* `meow_meow_meow` to make our saves compatible with SingBox configuration.
*/
public void fix_dash(ref Json.Node node, bool serialize = true) {
public Json.Node fix_dash(Json.Node node, bool serialize = true) {
var type = node.get_value_type();
if (type == typeof (Json.Object)) {
var obj = node.get_object();
@ -36,13 +36,14 @@ namespace Singularity.Utils {
obj.remove_member(name);
}
}
return node;
}
/*
* In vala we can't use `type` as field name, but we need to use it
* to make our saves compatible with SingBox configuration.
*/
public void fix_type(ref Json.Node node) {
public Json.Node fix_type(Json.Node node) {
const string TYPE_NAME_SRC = "type-name";
const string TYPE_NAME_DST = "type";
@ -58,6 +59,7 @@ namespace Singularity.Utils {
} else {
warning("Object has no type to fix it");
}
return node;
}
/*