1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use crate::control_api::protocol::common::HostnamePort;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
#[derive(Debug, Serialize, Deserialize, Default, ToSchema)]
#[serde(rename_all = "kebab-case")]
pub enum OutletKind {
/// Works as a regular TCP Outlet. It's compatible with UDP Puncture,
/// but it must be enabled at node level.
#[default]
Regular,
/// Use eBPF and RawSocket to access TCP packets instead of TCP data stream.
/// It's compatible with UDP Puncture, but it must be enabled at node level.
Privileged,
}
#[derive(Debug, Serialize, Deserialize, Default, ToSchema)]
#[serde(rename_all = "kebab-case")]
pub enum OutletTls {
#[default]
/// No TLS
None,
/// The destination uses TLS, the connection will be fully validated.
Validate,
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "kebab-case")]
pub struct CreateOutletRequest {
/// The kind of the outlet
pub kind: OutletKind,
/// The address of the outlet, also acts as an identifier for the resource
pub address: Option<String>,
/// The destination address of the TCP connection
pub to: HostnamePort,
/// The TLS configuration for the outlet
#[serde(default)]
#[schema(default = "None")]
pub tls: OutletTls,
/// Policy expression that will be used for access control to the TCP Outlet;
/// by default, the policy set for the "tcp-outlet" resource type will be used.
/// [Learn more about Policies expression on the Ockam documentation](https://docs.ockam.io/reference/protocols/access-controls).
pub allow: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "kebab-case")]
pub struct UpdateOutletRequest {
/// Policy expression that will be used for access control to the TCP Outlet;
/// by default, the policy set for the "tcp-outlet" resource type will be used.
/// [Learn more about Policies expression on the Ockam documentation](https://docs.ockam.io/reference/protocols/access-controls).
pub allow: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "kebab-case")]
pub struct OutletStatus {
/// The address of the outlet
pub to: HostnamePort,
/// The address of the worker, this also acts as an identifier of the TCP Outlet within the node
pub address: String,
/// Whether the outlet is of privileged kind
pub privileged: bool,
}
impl From<crate::nodes::models::portal::OutletStatus> for OutletStatus {
fn from(status: crate::nodes::models::portal::OutletStatus) -> Self {
OutletStatus {
to: HostnamePort {
hostname: status.to.hostname,
port: status.to.port,
},
address: status.worker_addr.address().to_string(),
privileged: status.privileged,
}
}
}