diff options
Diffstat (limited to 'src/ip_service.rs')
| -rw-r--r-- | src/ip_service.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ip_service.rs b/src/ip_service.rs index 3d869db..abe75f1 100644 --- a/src/ip_service.rs +++ b/src/ip_service.rs @@ -1,5 +1,5 @@ use crate::error::{AppError, AppResult}; -use crate::ip_service::IpServiceProvider::{IdentMe, Noop}; +use crate::ip_service::IpServiceProvider::{Http, IdentMe, Noop}; use http::StatusCode; use reqwest::{Client, Url}; use serde::{Deserialize, Serialize}; @@ -11,15 +11,21 @@ use std::str::FromStr; #[derive(Debug, Deserialize, PartialEq, Serialize)] #[serde(tag = "type")] pub enum IpServiceProvider { + #[serde(rename = "HTTP")] + Http(HttpConfig), #[serde(rename = "IDENTME")] IdentMe(IdentMeConfig), #[serde(rename = "NOOP")] Noop, } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct HttpConfig; + impl IpService for IpServiceProvider { async fn resolve(&self, client: &Client) -> AppResult<IpAddr> { match self { + Http(_http) => Ok(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), IdentMe(ident_me) => ident_me.resolve(client).await, Noop => Ok(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), } @@ -84,6 +90,9 @@ impl Default for IdentMeConfig { } } +// http service +// url - method - headers - response content-type (text, json) - response parser (text, json -> json path?) + impl IpService for IdentMeConfig { async fn resolve(&self, client: &Client) -> AppResult<IpAddr> { let response = client |
