summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
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;
+ }
+}