Skip to content

Commit d3648f1

Browse files
authored
NS API socks5 support (#6361)
* Add conversion from gw_probe crate type * Move code around - split 1000+ LoC files into smaller ones * Add socks5 field - code improvements in gw_probe crate * Fix docker build - install go - required as build dependency of gw probe * Add logs to agent * NS API: configure DB via env * rebase fix * socks5 score calc * Cargo fmt * use existing div_ceil * Code improvements * Bump NS API version * Rename variables * Bump API & agent version * Try to fix CI * Build only on linux
1 parent 9a931b9 commit d3648f1

40 files changed

Lines changed: 1466 additions & 711 deletions

File tree

.github/workflows/ci-build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
uses: actions-rs/cargo@v1
9090
with:
9191
command: clippy
92-
args: --workspace --all-targets --exclude nym-gateway-probe -- -D warnings
92+
args: --workspace --all-targets --exclude nym-gateway-probe --exclude nym-node-status-api -- -D warnings
9393

9494
- name: Clippy (non-macos)
9595
if: contains(matrix.os, 'linux') || contains(matrix.os, 'windows')
@@ -104,6 +104,14 @@ jobs:
104104
with:
105105
command: build
106106

107+
# only build on linux because of wg FFI bindings of its dependency (network probe)
108+
- name: Build nym-node-status-api (linux only)
109+
if: runner.os == 'Linux'
110+
uses: actions-rs/cargo@v1
111+
with:
112+
command: build
113+
args: -p nym-node-status-api
114+
107115
- name: Build all examples
108116
if: contains(matrix.os, 'linux')
109117
uses: actions-rs/cargo@v1

Cargo.lock

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ default-members = [
185185
"nym-credential-proxy/nym-credential-proxy",
186186
"nym-node",
187187
"nym-node-status-api/nym-node-status-agent",
188-
"nym-node-status-api/nym-node-status-api",
189188
"nym-statistics-api",
190189
"nym-validator-rewarder",
191190
"nyx-chain-watcher",

nym-gateway-probe/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tokio = { workspace = true, features = [
3838
tokio-util.workspace = true
3939
tracing-subscriber.workspace = true
4040
url = { workspace = true }
41+
utoipa = { workspace = true, optional = true }
4142
x25519-dalek = { workspace = true, features = [
4243
"reusable_secrets",
4344
"static_secrets",
@@ -76,6 +77,9 @@ time = { workspace = true }
7677
# TEMP: REMOVE BEFORE PR
7778
nym-topology = { workspace = true }
7879

80+
[features]
81+
utoipa = ["dep:utoipa"]
82+
7983
[build-dependencies]
8084
anyhow = { workspace = true }
8185
vergen-gitcl = { workspace = true, default-features = false, features = [

nym-gateway-probe/src/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ pub(crate) mod netstack;
1313
pub(crate) mod nodes;
1414
pub(crate) mod probe_tests;
1515
pub(crate) mod socks5_test;
16-
pub(crate) mod types;
16+
pub mod types;
1717
pub(crate) mod wireguard;

nym-gateway-probe/src/common/socks5_test/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct SingleHttpsTestResult {
7373
error: Option<String>,
7474
}
7575

76+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7677
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7778
pub struct HttpsConnectivityResult {
7879
/// successfully completed HTTPS request
@@ -88,17 +89,17 @@ pub struct HttpsConnectivityResult {
8889
endpoint_used: Option<String>,
8990

9091
/// error message(s) (if any)
91-
error: Option<Vec<String>>,
92+
errors: Option<Vec<String>>,
9293
}
9394

9495
impl HttpsConnectivityResult {
95-
pub fn with_errors(error: Vec<String>) -> Self {
96+
pub fn with_errors(errors: Vec<String>) -> Self {
9697
Self {
9798
https_success: false,
9899
https_status_code: None,
99100
https_latency_ms: None,
100101
endpoint_used: None,
101-
error: Some(error),
102+
errors: Some(errors),
102103
}
103104
}
104105

@@ -135,7 +136,7 @@ impl HttpsConnectivityResult {
135136
https_latency_ms: Some(avg_latency),
136137
endpoint_used: last_success.endpoint_used.clone(),
137138
// even in case of success, some errors were possible
138-
error: if errors.is_empty() {
139+
errors: if errors.is_empty() {
139140
None
140141
} else {
141142
Some(errors)
@@ -158,4 +159,8 @@ impl HttpsConnectivityResult {
158159
pub fn endpoint_used(&self) -> Option<&String> {
159160
self.endpoint_used.as_ref()
160161
}
162+
163+
pub fn errors(&self) -> Option<&Vec<String>> {
164+
self.errors.as_ref()
165+
}
161166
}

nym-gateway-probe/src/common/types.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct ProbeResult {
1010
pub outcome: ProbeOutcome,
1111
}
1212

13+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1314
#[derive(Debug, Clone, Serialize, Deserialize)]
1415
pub struct ProbeOutcome {
1516
pub as_entry: Entry,
@@ -19,6 +20,7 @@ pub struct ProbeOutcome {
1920
pub lp: Option<LpProbeResults>,
2021
}
2122

23+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2224
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2325
#[serde(rename = "wg")]
2426
pub struct WgProbeResults {
@@ -48,6 +50,7 @@ pub struct WgProbeResults {
4850
pub download_error_v6: String,
4951
}
5052

53+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5154
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5255
#[serde(rename = "lp")]
5356
pub struct LpProbeResults {
@@ -57,6 +60,7 @@ pub struct LpProbeResults {
5760
pub error: Option<String>,
5861
}
5962

63+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6064
#[derive(Debug, Clone, Serialize, Deserialize)]
6165
#[serde(untagged)]
6266
#[allow(clippy::enum_variant_names)]
@@ -98,12 +102,14 @@ impl Entry {
98102
}
99103
}
100104

105+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
101106
#[derive(Debug, Clone, Serialize, Deserialize)]
102107
pub struct EntryTestResult {
103108
pub can_connect: bool,
104109
pub can_route: bool,
105110
}
106111

112+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
107113
#[derive(Debug, Clone, Serialize, Deserialize)]
108114
pub struct Exit {
109115
pub can_connect: bool,
@@ -135,7 +141,8 @@ impl Exit {
135141
}
136142
}
137143

138-
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
144+
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
145+
#[derive(Debug, Clone, Serialize, Deserialize)]
139146
pub struct Socks5ProbeResults {
140147
/// whether we could establish a SOCKS5 proxy connection
141148
can_connect_socks5: bool,
@@ -165,6 +172,14 @@ impl Socks5ProbeResults {
165172
https_connectivity: HttpsConnectivityResult::with_errors(vec![error.into()]),
166173
}
167174
}
175+
176+
pub fn can_connect_socks5(&self) -> bool {
177+
self.can_connect_socks5
178+
}
179+
180+
pub fn https_connectivity(&self) -> &HttpsConnectivityResult {
181+
&self.https_connectivity
182+
}
168183
}
169184

170185
#[derive(Debug, Clone, Default)]

nym-gateway-probe/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use tracing::*;
2727
use url::Url;
2828

2929
mod common;
30+
pub use common::types;
3031
pub mod config;
3132

3233
use crate::common::bandwidth_helpers::{

nym-node-status-api/nym-node-status-agent/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[package]
55
name = "nym-node-status-agent"
6-
version = "1.1.0"
6+
version = "1.1.1"
77
authors.workspace = true
88
repository.workspace = true
99
homepage.workspace = true
@@ -23,6 +23,8 @@ nym-crypto = { workspace = true, features = ["asymmetric", "rand"] }
2323

2424
nym-node-status-client = { path = "../nym-node-status-client" }
2525
rand = { workspace = true }
26+
regex = { workspace = true }
27+
serde_json = { workspace = true }
2628
tokio = { workspace = true, features = [
2729
"macros",
2830
"rt-multi-thread",

nym-node-status-api/nym-node-status-agent/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ An agent to run tests and report results back to the Node Status API.
44

55
Environment variables that can be set individually are:
66

7-
- `NYM_NODE_MNEMONICS` - mnemonic to get tickets for tests
87
- `NODE_STATUS_AGENT_SERVER_PORT` - Node Status API port
98
- `NODE_STATUS_AGENT_SERVER_ADDRESS` - Node Status API address
109

0 commit comments

Comments
 (0)