Skip to content

Commit 1b3e45d

Browse files
committed
add serde features for ipnet
1 parent c33c12b commit 1b3e45d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

spi/spi-conf/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tardis = { workspace = true, features = [
2929
bios-basic = { path = "../../basic", features = ["default"] }
3030
lazy_static = { workspace = true }
3131
jsonwebtoken = "8"
32-
poem-grpc = "0.2.21"
32+
poem-grpc = "=0.2.22"
3333
prost = "0.11.9"
3434
poem = "1"
3535
prost-types = "0.11.9"
@@ -39,11 +39,11 @@ bios-sdk-invoke = { path = "../../sdk/invoke", features = [
3939
"iam",
4040
"macro",
4141
], default-features = false }
42-
42+
ipnet = { version = "2", features = ["serde"] }
4343
[dev-dependencies]
4444
tardis = { workspace = true, features = ["test", "conf-remote", "mq"] }
4545
bios-basic = { path = "../../basic", features = ["default", "test"] }
4646
reqwest = "*"
4747
testcontainers-modules = { workspace = true }
4848
[build-dependencies]
49-
poem-grpc-build = "0.2.21"
49+
poem-grpc-build = "0.2.22"

spi/spi-conf/src/conf_config.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::net::IpAddr;
2-
2+
use ipnet::IpNet;
33
use bios_basic::rbum::rbum_config::RbumConfig;
44
use serde::{Deserialize, Serialize};
55
use tardis::consts::{IP_LOCALHOST, IP_UNSPECIFIED};
@@ -19,15 +19,14 @@ pub struct ConfConfig {
1919
pub nacos_port: u16,
2020
pub nacos_grpc_port: u16,
2121
pub nacos_host: IpAddr,
22-
pub placeholder_white_list: Vec<IpAddr>,
22+
pub placeholder_white_list: Vec<IpNet>,
2323
pub iam_client: IamClientConfig,
2424
}
2525

2626
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
2727
#[serde(default)]
2828
pub struct IamClientConfig {
2929
pub base_url: String,
30-
pub cert_encode_key: String,
3130
}
3231

3332
impl ConfConfig {
@@ -54,7 +53,7 @@ impl Default for ConfConfig {
5453
nacos_port: 8848,
5554
nacos_grpc_port: 9848,
5655
nacos_host: IP_UNSPECIFIED,
57-
placeholder_white_list: vec![IP_LOCALHOST],
56+
placeholder_white_list: vec![IpNet::from(IP_LOCALHOST)],
5857
iam_client: Default::default(),
5958
}
6059
}

spi/spi-conf/src/serv/placehodler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async fn get_kvmap(codes: HashSet<&str>, config: &ConfConfig, funs: &tardis::Tar
7171

7272
pub fn has_placeholder_auth(source_addr: IpAddr, funs: &tardis::TardisFunsInst) -> bool {
7373
let cfg = funs.conf::<ConfConfig>();
74-
cfg.placeholder_white_list.contains(&source_addr)
74+
cfg.placeholder_white_list.iter().any(|net| net.contains(&source_addr))
7575
}
7676

7777
pub async fn render_content_for_ip(content: String, source_addr: IpAddr, funs: &tardis::TardisFunsInst, ctx: &tardis::basic::dto::TardisContext) -> TardisResult<String> {

0 commit comments

Comments
 (0)