Outbounds: add basic outbounds
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
cce81e41db
commit
ee6d575d5d
5 changed files with 112 additions and 3 deletions
|
@ -1,7 +1,4 @@
|
||||||
utils_sources = 'logic/utils.vala'
|
utils_sources = 'logic/utils.vala'
|
||||||
singularity_sources += [
|
|
||||||
utils_sources,
|
|
||||||
]
|
|
||||||
|
|
||||||
singularity_deps += [
|
singularity_deps += [
|
||||||
dependency('json-glib-1.0'),
|
dependency('json-glib-1.0'),
|
||||||
|
@ -9,3 +6,9 @@ singularity_deps += [
|
||||||
]
|
]
|
||||||
|
|
||||||
subdir('transports')
|
subdir('transports')
|
||||||
|
subdir('outbounds')
|
||||||
|
singularity_sources += [
|
||||||
|
utils_sources,
|
||||||
|
outbounds_sources,
|
||||||
|
transports_sources,
|
||||||
|
]
|
||||||
|
|
43
src/logic/outbounds/dial.vala
Normal file
43
src/logic/outbounds/dial.vala
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/* dial.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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Base for outbound with Dial fields.
|
||||||
|
* DASH and TYPE FIX REQUIRED
|
||||||
|
*/
|
||||||
|
class Singularity.Outbound.Dial : Outbound {
|
||||||
|
public string detour { get; set; default = null; }
|
||||||
|
public string bind_interface { get; set; default = null; }
|
||||||
|
public string inet4_bind_address { get; set; default = null; }
|
||||||
|
public string inet6_bind_address { get; set; default = null; }
|
||||||
|
public int64 routing_mark { get; set; default = 0; }
|
||||||
|
public bool reuse_addr { get; set; default = false; }
|
||||||
|
public string netns { get; set; default = null; }
|
||||||
|
public string connect_timeout { get; set; default = null; }
|
||||||
|
public bool tcp_fast_open { get; set; default = false; }
|
||||||
|
public bool tcp_multi_path { get; set; default = false; }
|
||||||
|
public bool udp_fragment { get; set; default = false; }
|
||||||
|
|
||||||
|
public string[] domain_resolver { get; set; default = new string[0]; }
|
||||||
|
public string network_strategy { get; set; default = null; }
|
||||||
|
public string[] network_type { get; set; default = new string[0]; }
|
||||||
|
public string[] fallback_network_type { get; set; default = new string[0]; }
|
||||||
|
public string fallback_delay { get; set; default = null; }
|
||||||
|
}
|
5
src/logic/outbounds/meson.build
Normal file
5
src/logic/outbounds/meson.build
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
outbounds_sources = [
|
||||||
|
'logic/outbounds/outbound.vala',
|
||||||
|
'logic/outbounds/dial.vala',
|
||||||
|
'logic/outbounds/trojan.vala',
|
||||||
|
]
|
5
src/logic/outbounds/outbound.vala
Normal file
5
src/logic/outbounds/outbound.vala
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class Singularity.Outbound.Outbound : Object, Json.Serializable {
|
||||||
|
// We can't use name `type` in vala
|
||||||
|
public string type_name { get; construct set; default = ""; }
|
||||||
|
public string tag { get; set; default = ""; }
|
||||||
|
}
|
53
src/logic/outbounds/trojan.vala
Normal file
53
src/logic/outbounds/trojan.vala
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* trojan.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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Trojan outbound.
|
||||||
|
* DASH and TYPE FIX REQUIRED
|
||||||
|
*/
|
||||||
|
class Singularity.Outbound.Trojan : Dial, Json.Serializable {
|
||||||
|
public string server { get; set; default = null; }
|
||||||
|
public int64 server_port { get; set; default = 1080; }
|
||||||
|
public string password { get; set; default = null; }
|
||||||
|
public string network { get; set; default = null; }
|
||||||
|
public Transport.Transport transport { get; set; default = null; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* public TLS tls { get; set; default = null; }
|
||||||
|
* TODO: Implement TLS
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* public Multiplex multiplex { get; set; default = null; }
|
||||||
|
* TODO: Implement Multiplex
|
||||||
|
*/
|
||||||
|
|
||||||
|
construct {
|
||||||
|
type_name = "trojan";
|
||||||
|
}
|
||||||
|
|
||||||
|
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") {
|
||||||
|
Utils.fix_type (ref node);
|
||||||
|
Utils.fix_dash (ref node);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue