Skip to main content

ipscanner/types/
gate.rs

1use serde::{Deserialize, Serialize};
2
3/// Body of `POST /v1/gate/verify`.
4#[derive(Debug, Clone, Default, PartialEq, Serialize)]
5pub struct GateVerifyRequest {
6    /// The site secret (`gs_...`).
7    pub secret: String,
8    pub token: String,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub remote_ip: Option<String>,
11}
12
13impl GateVerifyRequest {
14    pub fn new(secret: impl Into<String>, token: impl Into<String>) -> Self {
15        GateVerifyRequest {
16            secret: secret.into(),
17            token: token.into(),
18            remote_ip: None,
19        }
20    }
21}
22
23/// Response of `POST /v1/gate/verify`. Wire names are snake_case.
24#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
25#[serde(default)]
26pub struct GateVerification {
27    pub success: bool,
28    /// Traffic class, as on an edge check.
29    pub class: String,
30    /// `allow`, `flag` or `block`.
31    pub action: String,
32    /// `monitor` or `enforce`.
33    pub mode: String,
34    pub confidence: f64,
35    pub network: GateNetwork,
36    pub signals: Vec<String>,
37    pub hostname: String,
38    pub issued_at: String,
39    pub ip_match: bool,
40    pub locked: Vec<String>,
41    #[serde(rename = "planRequired")]
42    pub plan_required: Option<String>,
43}
44
45/// The network part of a gate verification.
46#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
47#[serde(default)]
48pub struct GateNetwork {
49    pub classification: String,
50    pub anonymized: bool,
51    /// The network owner. Null when unknown or on the site owner's Free plan.
52    pub provider: Option<String>,
53    /// The VPN brand. Null when unknown or on the site owner's Free plan.
54    pub vpn_provider: Option<String>,
55}