-
-
Notifications
You must be signed in to change notification settings - Fork 8
Upstream and dnst keyset TSIG support. (resolves #65)
#564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 32 commits
ae87d0b
25fdfe9
8a11e9d
52c88cf
79b3308
4b07b11
4d56ffb
53f6205
9b50f3c
5845baf
7002eb3
0750e4e
7143a54
c0724ee
678d55e
0c0d38c
432e779
75b6ee3
b44b805
059cd0a
5c38ef9
80b6b3d
5c5ef7e
1908500
0426bc6
15d6da2
542d70e
e03487b
67becab
b8729fb
271bfac
e6a5192
11bf96a
3331ff9
ee907f2
855e6ce
3756c89
78b1db0
f683960
04cd247
16d2619
deb0a21
e790b75
b1c599c
ee50dd7
41f50cd
db29fd4
2b48138
49474f7
6426c9a
6fbf719
e69c452
bb462b3
3bf9f91
c338121
f6a7a5c
021545e
ad2b492
eba3152
abf9d92
787ad2a
e6d8a5f
80ac2e7
d77e034
7228b83
9bc4f47
773369a
0fa77c8
1cdf7b0
d466f35
b08bc84
e2c4681
a8ff50c
342cbfd
42f554d
5f44999
5ab8b6a
8354c5b
c5f7819
8cdaa29
5da60cb
555b728
f61ccb7
bc7db24
ef966b4
3056a48
838b675
ed68983
399b384
f7529db
4c6c181
a822c42
880cc3f
44282b9
ebfc0f3
5198800
122e737
36f4961
144363a
d4fc435
b625ff5
a2db6be
154d923
ee3cb3d
aab66bf
4a58452
b851e81
078436e
106094b
239a92a
982274e
27bdc14
49043f8
5acd00b
1453aa6
a82b8a0
df1cfa2
52a919c
79559a7
8be30fb
3130f62
6170704
97aea65
aecc257
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| use std::collections::HashMap; | ||
| use std::fmt::{self, Display}; | ||
| use std::net::{IpAddr, SocketAddr}; | ||
| use std::time::{Duration, SystemTime}; | ||
|
|
||
| use camino::{Utf8Path, Utf8PathBuf}; | ||
| use domain::tsig::KeyName; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| pub use domain::base::Serial; | ||
|
|
@@ -187,6 +189,68 @@ pub struct KmipKeyImport { | |
| pub flags: String, | ||
| } | ||
|
|
||
| //----------- TsigKeyName ----------------------------------------------------- | ||
|
|
||
| /// The name of a TSIG key. | ||
| pub type TsigKeyName = domain::tsig::KeyName; | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct TsigAdd { | ||
| pub name: TsigKeyName, | ||
| pub alg: TsigAlgorithm, | ||
| pub secret: String, | ||
| } | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct TsigAddResult; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling this
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but it uses the same naming pattern as already exists in surrounding code. |
||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub enum TsigAddError { | ||
| InvalidKeyName, | ||
| AlreadyExists, | ||
| InvalidAlgorithmName, | ||
| InvalidBase64Secret, | ||
| } | ||
|
|
||
| impl Display for TsigAddError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self { | ||
| TsigAddError::InvalidKeyName => write!(f, "invalid TSIG key name"), | ||
| TsigAddError::AlreadyExists => write!(f, "TSIG key already exists"), | ||
| TsigAddError::InvalidAlgorithmName => write!(f, "invalid TSIG algorithm name"), | ||
| TsigAddError::InvalidBase64Secret => write!(f, "invalid TSIG base64 encoded secret"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct TsigRemoveResult; | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub enum TsigRemoveError { | ||
| NotFound, | ||
| InUse, | ||
| } | ||
|
|
||
| impl fmt::Display for TsigRemoveError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| f.write_str(match self { | ||
| TsigRemoveError::NotFound => "no such TSIG key was found", | ||
| TsigRemoveError::InUse => "the TSIG key cannot be removed as it is in use", | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct TsigListResult { | ||
| pub tsig_keys: HashMap<TsigKeyName, TsigListResultItem>, | ||
| } | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct TsigListResultItem { | ||
|
ximon18 marked this conversation as resolved.
Outdated
|
||
| pub zones: Vec<ZoneName>, | ||
| } | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct ZoneAdd { | ||
| pub name: ZoneName, | ||
|
|
@@ -206,6 +270,8 @@ pub enum ZoneAddError { | |
| AlreadyExists, | ||
| NoSuchPolicy, | ||
| PolicyMidDeletion, | ||
| InvalidTsigKeyName(String), | ||
| NoSuchTsigKey, | ||
| Other(String), | ||
| } | ||
|
|
||
|
|
@@ -215,6 +281,8 @@ impl fmt::Display for ZoneAddError { | |
| Self::AlreadyExists => "a zone of this name already exists", | ||
| Self::NoSuchPolicy => "no policy with that name exists", | ||
| Self::PolicyMidDeletion => "the specified policy is being deleted", | ||
| Self::InvalidTsigKeyName(reason) => reason, | ||
| Self::NoSuchTsigKey => "no TSIG key with that name exists", | ||
| Self::Other(reason) => reason, | ||
| }) | ||
| } | ||
|
|
@@ -290,18 +358,30 @@ impl Display for ZoneSource { | |
| } | ||
| } | ||
|
|
||
| /// Support parsing of ``-source`` command line arguments. | ||
| /// | ||
| /// Supported forms: | ||
| /// - `<IP_ADDRESS>[:<PORT>][^<TSIG_KEY_NAME>]` | ||
| /// - `</PATH/TO/ZONE/FILE/TO/LOAD>` | ||
|
ximon18 marked this conversation as resolved.
Outdated
|
||
| impl From<&str> for ZoneSource { | ||
| fn from(s: &str) -> Self { | ||
| fn from(mut s: &str) -> Self { | ||
| // Split out any provided TSIG key from the rest of the | ||
| // source argument. | ||
| let tsig_key = s.split_once('^').map(|(new_s, k)| { | ||
| s = new_s; | ||
| k.to_string() | ||
| }); | ||
|
|
||
| if let Ok(addr) = s.parse::<SocketAddr>() { | ||
| ZoneSource::Server { | ||
| addr, | ||
| tsig_key: None, | ||
| tsig_key, | ||
| xfr_status: Default::default(), | ||
| } | ||
| } else if let Ok(addr) = s.parse::<IpAddr>() { | ||
| ZoneSource::Server { | ||
| addr: SocketAddr::new(addr, DEFAULT_AXFR_PORT), | ||
| tsig_key: None, | ||
| tsig_key, | ||
| xfr_status: Default::default(), | ||
| } | ||
| } else { | ||
|
|
@@ -491,6 +571,26 @@ impl Display for KeyType { | |
| } | ||
| } | ||
|
|
||
| #[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
| pub enum TsigAlgorithm { | ||
| Sha1, | ||
| Sha256, | ||
| Sha384, | ||
| Sha512, | ||
|
ximon18 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| impl Display for TsigAlgorithm { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self { | ||
| TsigAlgorithm::Sha1 => "hmac-sha1", | ||
| TsigAlgorithm::Sha256 => "hmac-sha256", | ||
| TsigAlgorithm::Sha384 => "hmac-sha384", | ||
| TsigAlgorithm::Sha512 => "hmac-sha512", | ||
| } | ||
| .fmt(f) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct ZoneHistory { | ||
| pub history: Vec<HistoryItem>, | ||
|
|
@@ -650,12 +750,15 @@ pub struct KeyMsg { | |
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub enum PolicyReloadError { | ||
| Io(Utf8PathBuf, String), | ||
| Check(String), | ||
|
ximon18 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| impl Display for PolicyReloadError { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| let PolicyReloadError::Io(p, e) = self; | ||
| format!("{p}: {e}").fmt(f) | ||
| match self { | ||
| PolicyReloadError::Io(p, e) => format!("{p}: {e}").fmt(f), | ||
| PolicyReloadError::Check(e) => e.to_string().fmt(f), | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -739,12 +842,19 @@ pub struct OutboundPolicyInfo { | |
|
|
||
| #[derive(Deserialize, Serialize, Debug, Clone)] | ||
| pub struct NameserverCommsPolicyInfo { | ||
| pub addr: SocketAddr, | ||
| pub addr: Option<SocketAddr>, | ||
| pub tsig_key_name: Option<KeyName>, | ||
| } | ||
|
|
||
| impl std::fmt::Display for NameserverCommsPolicyInfo { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| write!(f, "{}", self.addr) | ||
| if let Some(addr) = self.addr { | ||
| write!(f, "{addr}")?; | ||
| } | ||
| if let Some(tsig_key_name) = &self.tsig_key_name { | ||
| write!(f, "^{tsig_key_name}")?; | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.