Compare commits
	
		
			2 Commits
		
	
	
		
			e5c9cb6024
			...
			787f74e3ec
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 787f74e3ec | |||
| 9b68b32354 | 
| @@ -3,40 +3,14 @@ | ||||
| use anyhow::{Context, Result}; | ||||
| use log::{error, info}; | ||||
| use reqwest::Client; | ||||
| use serde::{self, Deserialize, Serialize}; | ||||
| use std::{ | ||||
|     collections::HashMap, | ||||
|     fmt, | ||||
|     net::{IpAddr, Ipv4Addr}, | ||||
| }; | ||||
| 
 | ||||
| use super::cloudflare_responses::{CloudflareResponse, DnsRecord}; | ||||
| use crate::get_current_public_ipv4; | ||||
| 
 | ||||
| #[derive(Serialize, Deserialize, Clone, Debug)] | ||||
| struct DnsRecord { | ||||
|     id: String, | ||||
|     #[serde(rename = "type")] | ||||
|     record_type: Box<str>, | ||||
|     name: Box<str>, | ||||
|     content: Box<str>, | ||||
|     ttl: u32, | ||||
|     proxied: bool, | ||||
|     locked: bool, | ||||
|     zone_id: Box<str>, | ||||
|     zone_name: Box<str>, | ||||
|     modified_on: Box<str>, | ||||
|     created_on: Box<str>, | ||||
|     meta: HashMap<Box<str>, serde_json::Value>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Serialize, Deserialize, Debug)] | ||||
| struct CloudflareResponse { | ||||
|     success: bool, | ||||
|     errors: Vec<HashMap<String, serde_json::Value>>, | ||||
|     messages: Vec<HashMap<String, serde_json::Value>>, | ||||
|     result: Option<Vec<DnsRecord>>, | ||||
| } | ||||
| 
 | ||||
| pub struct CloudflareClient<A, Z> | ||||
| where | ||||
|     A: fmt::Display, | ||||
							
								
								
									
										27
									
								
								src/internet/cloudflare_responses.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/internet/cloudflare_responses.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| use std::collections::HashMap; | ||||
|  | ||||
| use serde; | ||||
| #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] | ||||
| pub struct DnsRecord { | ||||
|     pub id: Box<str>, | ||||
|     #[serde(rename = "type")] | ||||
|     pub record_type: Box<str>, | ||||
|     pub name: Box<str>, | ||||
|     pub content: Box<str>, | ||||
|     pub ttl: u32, | ||||
|     pub proxied: bool, | ||||
|     pub locked: bool, | ||||
|     pub zone_id: Box<str>, | ||||
|     pub zone_name: Box<str>, | ||||
|     pub modified_on: Box<str>, | ||||
|     pub created_on: Box<str>, | ||||
|     pub meta: HashMap<Box<str>, serde_json::Value>, | ||||
| } | ||||
|  | ||||
| #[derive(serde::Serialize, serde::Deserialize, Debug)] | ||||
| pub struct CloudflareResponse { | ||||
|     pub success: bool, | ||||
|     pub errors: Box<[HashMap<Box<str>, serde_json::Value>]>, | ||||
|     pub messages: Box<[HashMap<Box<str>, serde_json::Value>]>, | ||||
|     pub result: Option<Vec<DnsRecord>>, | ||||
| } | ||||
							
								
								
									
										3
									
								
								src/internet/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/internet/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| mod cloudflare; | ||||
| pub mod cloudflare_responses; | ||||
| pub use cloudflare::CloudflareClient; | ||||
| @@ -1,16 +1,17 @@ | ||||
| // SPDX: BSD-2-Clause | ||||
|  | ||||
| mod cloudflare; | ||||
| mod config; | ||||
| mod exit_listener; | ||||
| mod logging; | ||||
| mod message_handler; | ||||
| mod network_change_listener; | ||||
| mod public_ip; | ||||
| mod tests; | ||||
| pub mod utils; | ||||
|  | ||||
| pub use cloudflare::CloudflareClient; | ||||
| mod tests; | ||||
| mod internet; | ||||
|  | ||||
| pub use internet::CloudflareClient; | ||||
| pub use config::{get_config_path, read_config, Config}; | ||||
| pub use exit_listener::ExitListener; | ||||
| pub use logging::init_logger; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user