Transport: Add transports
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
fafb1854bc
commit
cce81e41db
8 changed files with 205 additions and 1 deletions
|
@ -1,8 +1,11 @@
|
|||
utils_sources = 'logic/utils.vala'
|
||||
singularity_sources += [
|
||||
'logic/utils.vala',
|
||||
utils_sources,
|
||||
]
|
||||
|
||||
singularity_deps += [
|
||||
dependency('json-glib-1.0'),
|
||||
dependency('gee-0.8'),
|
||||
]
|
||||
|
||||
subdir('transports')
|
||||
|
|
34
src/logic/transports/grpc.vala
Normal file
34
src/logic/transports/grpc.vala
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* grpc.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
|
||||
*/
|
||||
|
||||
/*
|
||||
* gRPC transport.
|
||||
* DASH and TYPE FIX REQUIRED
|
||||
*/
|
||||
class Singularity.Transport.GRPC : Transport, Json.Serializable {
|
||||
public string service_name { get; set; default = "TunService"; }
|
||||
public string idle_timeout { get; set; default = "15s"; }
|
||||
public string ping_timeout { get; set; default = "15s"; }
|
||||
public bool permit_without_stream { get; set; default = false; }
|
||||
|
||||
construct {
|
||||
type_name = "grpc";
|
||||
}
|
||||
}
|
42
src/logic/transports/http.vala
Normal file
42
src/logic/transports/http.vala
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* http.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
|
||||
*/
|
||||
|
||||
/*
|
||||
* HTTP transport.
|
||||
* DASH and TYPE FIX REQUIRED
|
||||
*/
|
||||
class Singularity.Transport.Http : Transport, Json.Serializable {
|
||||
public string[] host { get; set; default = new string[0]; }
|
||||
public string path { get; set; default = ""; }
|
||||
public string method { get; set; default = ""; }
|
||||
public Gee.HashMap<string, string> headers { get; set; default = new Gee.HashMap<string, string> (); }
|
||||
public string idle_timeout { get; set; default = "15s"; }
|
||||
public string ping_timeout { get; set; default = "15s"; }
|
||||
|
||||
construct {
|
||||
type_name = "http";
|
||||
}
|
||||
|
||||
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
|
||||
if (property_name == "headers")
|
||||
return Utils.serialize_string_map (headers);
|
||||
return default_serialize_property (property_name, value, pspec);
|
||||
}
|
||||
}
|
39
src/logic/transports/http_upgrade.vala
Normal file
39
src/logic/transports/http_upgrade.vala
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* http_upgrade.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
|
||||
*/
|
||||
|
||||
/*
|
||||
* HTTPUpgrade transport.
|
||||
* TYPE FIX REQUIRED
|
||||
*/
|
||||
class Singularity.Transport.HttpUpgrade : Transport, Json.Serializable {
|
||||
public string host { get; set; default = ""; }
|
||||
public string path { get; set; default = ""; }
|
||||
public Gee.HashMap<string, string> headers { get; set; default = new Gee.HashMap<string, string> (); }
|
||||
|
||||
construct {
|
||||
type_name = "httpupgrade";
|
||||
}
|
||||
|
||||
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
|
||||
if (property_name == "headers")
|
||||
return Utils.serialize_string_map (headers);
|
||||
return default_serialize_property (property_name, value, pspec);
|
||||
}
|
||||
}
|
9
src/logic/transports/meson.build
Normal file
9
src/logic/transports/meson.build
Normal file
|
@ -0,0 +1,9 @@
|
|||
transports_sources = [
|
||||
'logic/transports/transport.vala',
|
||||
'logic/transports/http.vala',
|
||||
'logic/transports/ws.vala',
|
||||
'logic/transports/quic.vala',
|
||||
'logic/transports/grpc.vala',
|
||||
'logic/transports/http_upgrade.vala',
|
||||
]
|
||||
singularity_sources += transports_sources
|
29
src/logic/transports/quic.vala
Normal file
29
src/logic/transports/quic.vala
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* quic.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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Quic transport.
|
||||
* TYPE FIX REQUIRED
|
||||
*/
|
||||
class Singularity.Transport.Quic : Transport, Json.Serializable {
|
||||
construct {
|
||||
type_name = "quic";
|
||||
}
|
||||
}
|
8
src/logic/transports/transport.vala
Normal file
8
src/logic/transports/transport.vala
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Base class for transport.
|
||||
* TYPE FIX REQUIRED
|
||||
*/
|
||||
class Singularity.Transport.Transport : Object, Json.Serializable {
|
||||
// We can't use name `type` in vala
|
||||
public string type_name { get; construct set; default = ""; }
|
||||
}
|
40
src/logic/transports/ws.vala
Normal file
40
src/logic/transports/ws.vala
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* ws.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
|
||||
*/
|
||||
|
||||
/*
|
||||
* WebSocket transport.
|
||||
* DASH and TYPE FIX REQUIRED
|
||||
*/
|
||||
class Singularity.Transport.WebSocket : Transport, Json.Serializable {
|
||||
public string path { get; set; default = ""; }
|
||||
public Gee.HashMap<string, string> headers { get; set; default = new Gee.HashMap<string, string> (); }
|
||||
public int64 max_early_data { get; set; default = 0; }
|
||||
public string early_data_header_name { get; set; default = ""; }
|
||||
|
||||
construct {
|
||||
type_name = "ws";
|
||||
}
|
||||
|
||||
public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
|
||||
if (property_name == "headers")
|
||||
return Utils.serialize_string_map (headers);
|
||||
return default_serialize_property (property_name, value, pspec);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue