-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract resolved config in struct (#2220)
* Extract resolved config in struct * Function instead of iterator
- Loading branch information
Showing
3 changed files
with
51 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright 2023-2024 - Nym Technologies SA <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
use std::net::SocketAddr; | ||
use std::{fmt, net::IpAddr}; | ||
|
||
use nym_sdk::UserAgent; | ||
|
@@ -87,6 +88,24 @@ impl Config { | |
} | ||
} | ||
|
||
pub struct ResolvedConfig { | ||
pub nyxd_socket_addrs: Vec<SocketAddr>, | ||
pub api_socket_addrs: Vec<SocketAddr>, | ||
pub nym_vpn_api_socket_addres: Option<Vec<SocketAddr>>, | ||
} | ||
|
||
impl ResolvedConfig { | ||
pub fn all_socket_addrs(&self) -> Vec<SocketAddr> { | ||
let mut socket_addrs = vec![]; | ||
socket_addrs.extend(self.nyxd_socket_addrs.iter()); | ||
socket_addrs.extend(self.api_socket_addrs.iter()); | ||
if let Some(vpn_api_socket_addrs) = &self.nym_vpn_api_socket_addres { | ||
socket_addrs.extend(vpn_api_socket_addrs.iter()); | ||
} | ||
socket_addrs | ||
} | ||
} | ||
|
||
pub struct GatewayClient { | ||
api_client: NymApiClient, | ||
nym_vpn_api_client: Option<nym_vpn_api_client::VpnApiClient>, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters