MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / validate

Function validate

gateway/src/config.rs:34–52  ·  view source on GitHub ↗
(ip: Ipv4Net, reserved_net: &[Ipv4Net], client_ip_range: Ipv4Net)

Source from the content-addressed store, hash-verified

32}
33
34fn validate(ip: Ipv4Net, reserved_net: &[Ipv4Net], client_ip_range: Ipv4Net) -> Result<()> {
35 // The reserved net must be in the network
36 for net in reserved_net {
37 if !ip.contains(net) {
38 bail!("Reserved net is not in the network");
39 }
40 }
41
42 // The ip must be in one of the reserved net
43 if !reserved_net.iter().any(|net| net.contains(&ip.addr())) {
44 bail!("Wg peer IP is not in the reserved net");
45 }
46
47 // The client ip range must be in the network
48 if !ip.trunc().contains(&client_ip_range) {
49 bail!("Client IP range is not in the network");
50 }
51 Ok(())
52}
53
54#[derive(Debug, Clone, Deserialize)]
55pub enum CryptoProvider {

Callers 2

validateMethod · 0.85
test_validateFunction · 0.85

Calls 1

containsMethod · 0.80

Tested by 1

test_validateFunction · 0.68