1
0
mirror of https://github.com/vbrandl/bind9-api.git synced 2025-07-31 14:23:56 +02:00

1 Commits

Author SHA1 Message Date
dependabot-preview[bot]
c7e101b06f Bump proptest from 0.9.5 to 0.9.6
Bumps [proptest](https://github.com/altsysrq/proptest) from 0.9.5 to 0.9.6.
- [Release notes](https://github.com/altsysrq/proptest/releases)
- [Changelog](https://github.com/AltSysrq/proptest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/altsysrq/proptest/compare/0.9.5...0.9.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-13 04:15:13 +00:00
6 changed files with 1141 additions and 1684 deletions

2797
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,19 +7,6 @@
This is an attempt to implement an API to create, update or delete DNS records
on a BIND9 DNS server.
## Building
To compile the code, you first need to [install Rust](https://rustup.rs/). Then
you can run
```
cargo build --release
```
in the project root. The server and client binary will be located in
`./target/release/bind9-api` and `./target/release/bind9-api-client`
respectively.
## Server
The server will wait for incoming requests and uses the `nsupdate` command to

View File

@@ -106,7 +106,7 @@ fn call_api<D: serde::Serialize>(
let data_s = serde_json::to_string(&data)?;
info!("body: {}", data_s);
let signature = crypto::sign(config.secret.as_bytes(), data_s.as_bytes());
let signature = crypto::bytes_to_hex_str(&signature);
let signature = crypto::bytes_to_hex_str(&signature)?;
let client = reqwest::Client::new();
let url = format!("{}/record", config.host);
Ok(if method == Method::POST {

View File

@@ -10,4 +10,4 @@ hex = "0.4.0"
ring = "0.13.5"
[dev-dependencies]
proptest = "0.9.5"
proptest = "0.9.6"

View File

@@ -55,8 +55,10 @@ use ring::{digest, hmac};
type Result<T> = std::result::Result<T, Error>;
/// Converts a byte slice to a lowercase hex string.
pub fn bytes_to_hex_str(bytes: &[u8]) -> String {
bytes.encode_hex::<String>()
pub fn bytes_to_hex_str(bytes: &[u8]) -> Result<String> {
let mut output = String::new();
bytes.write_hex(&mut output)?;
Ok(output)
}
/// Converts a hey string to a vec of bytes.

View File

@@ -104,7 +104,7 @@ pub struct Validated<T>(T);
impl<T: 'static + ::serde::de::DeserializeOwned> FromRequest<Arc<Config>> for Validated<T> {
type Config = ();
type Result = Box<dyn Future<Item = Self, Error = Error>>;
type Result = Box<Future<Item = Self, Error = Error>>;
fn from_request(req: &HttpRequest<Arc<Config>>, _: &Self::Config) -> Self::Result {
let state = req.state().clone();
@@ -134,8 +134,7 @@ impl<T> Deref for Validated<T> {
}
fn extract_signature<S>(req: &HttpRequest<S>) -> Result<Vec<u8>> {
Ok(req
.headers()
Ok(req.headers()
.get(::data::TOKEN_HEADER)
.as_ref()
.ok_or_else(|| ErrorUnauthorized(ParseError::Header))?