From 7ce0c897ead39da3f852194f0f8bd490d1f6787f Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Fri, 4 Aug 2023 20:23:17 -0400 Subject: [PATCH] Create example config files --- Cargo.toml | 17 +++++++++++++++-- config/protomask-clat.json | 7 +++++++ config/protomask.json | 14 ++++++++++++++ debian/protomask-clat-service | 9 +++++++++ debian/{service => protomask-service} | 2 +- src/args/protomask.rs | 12 ++++++++++++ 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 config/protomask-clat.json create mode 100644 config/protomask.json create mode 100644 debian/protomask-clat-service rename debian/{service => protomask-service} (57%) diff --git a/Cargo.toml b/Cargo.toml index 0dced11..770445c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,13 +101,26 @@ assets = [ "/usr/local/bin/protomask-6over4", "755", ], + [ + "config/protomask.json", + "/etc/protomask/protomask.json", + "644", + ], + [ + "config/protomask-clat.json", + "/etc/protomask/protomask-clat.json", + "644", + ], [ "README.md", - "usr/share/doc/protomask/README.md", + "/usr/share/doc/protomask/README.md", "644", ], ] conf-files = [] depends = [] maintainer-scripts = "./debian/" -systemd-units = { enable = false } +systemd-units = [ + { unit-name = "protomask-service", enable = false }, + { unit-name = "protomask-clat-service", enable = false }, +] diff --git a/config/protomask-clat.json b/config/protomask-clat.json new file mode 100644 index 0000000..1c270a2 --- /dev/null +++ b/config/protomask-clat.json @@ -0,0 +1,7 @@ +{ + "via": "64:ff9b::/96", + "customer_pool": [ + "192.0.2.0/24" + ], + "prometheus_bind_addr": "[::1]:8999" +} \ No newline at end of file diff --git a/config/protomask.json b/config/protomask.json new file mode 100644 index 0000000..305d764 --- /dev/null +++ b/config/protomask.json @@ -0,0 +1,14 @@ +{ + "prefix": "64:ff9b::/96", + "pool": [ + "192.0.2.0/24" + ], + "static_map": [ + { + "ipv4": "192.0.2.1", + "ipv6": "2001:db8::1" + } + ], + "prometheus_bind_addr": "[::1]:8999", + "reservation_timeout": 7200 +} \ No newline at end of file diff --git a/debian/protomask-clat-service b/debian/protomask-clat-service new file mode 100644 index 0000000..8677cfc --- /dev/null +++ b/debian/protomask-clat-service @@ -0,0 +1,9 @@ +[Unit] +Description = Protomask CLAT +After = network.target + +[Service] +ExecStart = /usr/local/bin/protomask-clat --config /etc/protomask/protomask-clat.json + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/debian/service b/debian/protomask-service similarity index 57% rename from debian/service rename to debian/protomask-service index 2b5db60..8317c4c 100644 --- a/debian/service +++ b/debian/protomask-service @@ -3,7 +3,7 @@ Description = Protomask After = network.target [Service] -ExecStart = /usr/local/bin/protomask --pool-file /etc/protomask/pool.txt +ExecStart = /usr/local/bin/protomask --config /etc/protomask/protomask.json [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/src/args/protomask.rs b/src/args/protomask.rs index 92256a3..fe824a1 100644 --- a/src/args/protomask.rs +++ b/src/args/protomask.rs @@ -90,3 +90,15 @@ pub struct Config { #[clap(long, default_value = "7200")] pub reservation_timeout: u64, } + +#[derive(Debug, serde::Deserialize, Clone)] +pub struct StaticMap { + pub ipv4: Ipv4Addr, + pub ipv6: Ipv6Addr, +} + +impl Into<(Ipv4Addr, Ipv6Addr)> for StaticMap { + fn into(self) -> (Ipv4Addr, Ipv6Addr) { + (self.ipv4, self.ipv6) + } +} \ No newline at end of file