Fix refs
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
7c634dbfd5
commit
0ca6e4080e
5 changed files with 12 additions and 12 deletions
|
@ -24,11 +24,11 @@ class Singularity.SingConfig : Object, Json.Serializable {
|
||||||
if (property_name == "outbounds") {
|
if (property_name == "outbounds") {
|
||||||
var node = Utils.serialize_object_list<Outbound.Outbound> (outbounds);
|
var node = Utils.serialize_object_list<Outbound.Outbound> (outbounds);
|
||||||
var arr = node.get_array ();
|
var arr = node.get_array ();
|
||||||
|
var new_arr = new Json.Array ();
|
||||||
arr.foreach_element ((_, __, node) => {
|
arr.foreach_element ((_, __, node) => {
|
||||||
var _node = node;
|
new_arr.add_element (Utils.fix_dash (Utils.fix_type (node)));
|
||||||
Utils.fix_type (ref _node);
|
|
||||||
Utils.fix_dash (ref _node);
|
|
||||||
});
|
});
|
||||||
|
node.set_array (new_arr);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
return default_serialize_property (property_name, value, pspec);;
|
return default_serialize_property (property_name, value, pspec);;
|
||||||
|
|
|
@ -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) {
|
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
|
||||||
var node = default_serialize_property (property_name, value, pspec);
|
var node = default_serialize_property (property_name, value, pspec);
|
||||||
if (property_name == "transport" && transport != null) {
|
if (property_name == "transport" && transport != null) {
|
||||||
Utils.fix_type (ref node);
|
return Utils.fix_dash (Utils.fix_type (node));
|
||||||
Utils.fix_dash (ref node);
|
|
||||||
}
|
}
|
||||||
if (property_name == "tls" && tls != null) {
|
if (property_name == "tls" && tls != null) {
|
||||||
Utils.fix_dash (ref node);
|
return Utils.fix_dash (node);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
|
||||||
var node = default_serialize_property (property_name, value, pspec);
|
var node = default_serialize_property (property_name, value, pspec);
|
||||||
if (property_name == "transport" && transport != null) {
|
if (property_name == "transport" && transport != null) {
|
||||||
Utils.fix_type (ref node);
|
return Utils.fix_dash (Utils.fix_type (node));
|
||||||
Utils.fix_dash (ref node);
|
|
||||||
}
|
}
|
||||||
if (property_name == "tls" && tls != null) {
|
if (property_name == "tls" && tls != null) {
|
||||||
Utils.fix_dash (ref node);
|
return Utils.fix_dash (node);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
|
||||||
var node = default_serialize_property (property_name, value, pspec);
|
var node = default_serialize_property (property_name, value, pspec);
|
||||||
if (property_name == "reality" && reality != null) {
|
if (property_name == "reality" && reality != null) {
|
||||||
Utils.fix_dash (ref node);
|
return Utils.fix_dash (node);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Singularity.Utils {
|
||||||
* Vala use `meow-meow-meow` as in json serialization, but we need to use
|
* 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.
|
* `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();
|
var type = node.get_value_type();
|
||||||
if (type == typeof (Json.Object)) {
|
if (type == typeof (Json.Object)) {
|
||||||
var obj = node.get_object();
|
var obj = node.get_object();
|
||||||
|
@ -36,13 +36,14 @@ namespace Singularity.Utils {
|
||||||
obj.remove_member(name);
|
obj.remove_member(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In vala we can't use `type` as field name, but we need to use it
|
* In vala we can't use `type` as field name, but we need to use it
|
||||||
* to make our saves compatible with SingBox configuration.
|
* 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_SRC = "type-name";
|
||||||
const string TYPE_NAME_DST = "type";
|
const string TYPE_NAME_DST = "type";
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ namespace Singularity.Utils {
|
||||||
} else {
|
} else {
|
||||||
warning("Object has no type to fix it");
|
warning("Object has no type to fix it");
|
||||||
}
|
}
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue