summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2023-03-03 00:10:21 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2023-03-03 00:10:21 -0500
commit0f40ab89e3b523ac206077d932a0e2d40d75f7e0 (patch)
treec4914050d1bbca8af77347220c0785c8ebefa213 /src/config.rs
parentclippy my beloved (diff)
downloadwrapper-0f40ab89e3b523ac206077d932a0e2d40d75f7e0.tar.gz
wrapper-0f40ab89e3b523ac206077d932a0e2d40d75f7e0.tar.bz2
wrapper-0f40ab89e3b523ac206077d932a0e2d40d75f7e0.zip
finialize initial dns + caching
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..9350adf
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,35 @@
+use std::net::IpAddr;
+
+#[derive(Clone)]
+pub struct Config {
+ fallback: IpAddr,
+ port: u16,
+}
+
+impl Config {
+ pub fn new() -> Self {
+ let fallback = "9.9.9.9"
+ .parse::<IpAddr>()
+ .expect("Failed to create default ns fallback");
+ Self {
+ fallback,
+ port: 2000,
+ }
+ }
+
+ pub fn get_fallback_ns(&self) -> &IpAddr {
+ &self.fallback
+ }
+
+ pub fn get_port(&self) -> u16 {
+ self.port
+ }
+
+ pub fn set_fallback_ns(&mut self, addr: &IpAddr) {
+ self.fallback = *addr;
+ }
+
+ pub fn set_port(&mut self, port: u16) {
+ self.port = port;
+ }
+}