Commit c4c6e718 authored by Gaël Berthaud-Müller's avatar Gaël Berthaud-Müller
Browse files

remove unused stuff

parent b7fa4677
......@@ -8,7 +8,7 @@ use rocket_contrib::json::Json;
use trust_dns_client::client::{Client, SyncClient};
use trust_dns_client::tcp::TcpClientConnection;
use trust_dns_client::op::{DnsResponse, ResponseCode};
use trust_dns_client::rr::{DNSClass, Name, Record, RecordType};
use trust_dns_client::rr::{DNSClass, Name, RecordType};
mod models;
mod config;
......@@ -17,7 +17,7 @@ use models::errors::ErrorResponse;
#[get("/zones/<zone>/records")]
fn zone_records(client: State<SyncClient<TcpClientConnection>>, zone: String) -> Result<Json<Vec<models::dns::Record>>, ErrorResponse<()>> {
fn get_zone_records(client: State<SyncClient<TcpClientConnection>>, zone: String) -> Result<Json<Vec<models::dns::Record>>, ErrorResponse<()>> {
// TODO: Implement FromParam for Name
let name = Name::from_utf8(&zone).unwrap();
......@@ -30,7 +30,7 @@ fn zone_records(client: State<SyncClient<TcpClientConnection>>, zone: String) ->
).err()
}
let answers: &[Record] = response.answers();
let answers = response.answers();
let mut records: Vec<_> = answers.to_vec().into_iter()
.map(|record| models::dns::Record::from(record))
.filter(|record| match record.rdata {
......@@ -52,5 +52,5 @@ fn main() {
rocket::ignite()
.manage(client)
.mount("/api/v1", routes![zone_records]).launch();
.mount("/api/v1", routes![get_zone_records]).launch();
}
......@@ -7,131 +7,6 @@ use base64;
use super::trust_dns_types;
#[derive(Deserialize, Serialize)]
pub enum RecordType {
A,
AAAA,
ANAME,
ANY,
AXFR,
CAA,
CNAME,
HINFO,
HTTPS,
IXFR,
MX,
NAPTR,
NS,
NULL,
OPENPGPKEY,
OPT,
PTR,
SOA,
SRV,
SSHFP,
SVCB,
TLSA,
TXT,
// dnssec
DNSKEY,
DS,
KEY,
NSEC,
NSEC3,
NSEC3PARAM,
RRSIG,
SIG,
Unknown(u16),
ZERO,
}
impl From<trust_dns_types::RecordType> for RecordType {
fn from(record_type: trust_dns_types::RecordType) -> RecordType {
match record_type {
trust_dns_types::RecordType::A => RecordType::A,
trust_dns_types::RecordType::AAAA => RecordType::AAAA,
trust_dns_types::RecordType::ANAME => RecordType::ANAME,
trust_dns_types::RecordType::ANY => RecordType::ANY,
trust_dns_types::RecordType::AXFR => RecordType::AXFR,
trust_dns_types::RecordType::CAA => RecordType::CAA,
trust_dns_types::RecordType::CNAME => RecordType::CNAME,
trust_dns_types::RecordType::HINFO => RecordType::HINFO,
trust_dns_types::RecordType::HTTPS => RecordType::HTTPS,
trust_dns_types::RecordType::IXFR => RecordType::IXFR,
trust_dns_types::RecordType::MX => RecordType::MX,
trust_dns_types::RecordType::NAPTR => RecordType::NAPTR,
trust_dns_types::RecordType::NS => RecordType::NS,
trust_dns_types::RecordType::NULL => RecordType::NULL,
trust_dns_types::RecordType::OPENPGPKEY => RecordType::OPENPGPKEY,
trust_dns_types::RecordType::OPT => RecordType::OPT,
trust_dns_types::RecordType::PTR => RecordType::PTR,
trust_dns_types::RecordType::SOA => RecordType::SOA,
trust_dns_types::RecordType::SRV => RecordType::SRV,
trust_dns_types::RecordType::SSHFP => RecordType::SSHFP,
trust_dns_types::RecordType::SVCB => RecordType::SVCB,
trust_dns_types::RecordType::TLSA => RecordType::TLSA,
trust_dns_types::RecordType::TXT => RecordType::TXT,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::DNSKEY) => RecordType::DNSKEY,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::DS) => RecordType::DS,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::KEY) => RecordType::KEY,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::NSEC) => RecordType::NSEC,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::NSEC3) => RecordType::NSEC3,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::NSEC3PARAM) => RecordType::NSEC3PARAM,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::RRSIG) => RecordType::RRSIG,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::SIG) => RecordType::SIG,
trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::Unknown(r#type)) => RecordType::Unknown(r#type),
trust_dns_types::RecordType::Unknown(r#type) => RecordType::Unknown(r#type),
trust_dns_types::RecordType::ZERO => RecordType::ZERO,
}
}
}
impl Into<trust_dns_types::RecordType> for RecordType {
fn into(self) -> trust_dns_types::RecordType {
match self {
RecordType::A => trust_dns_types::RecordType::A,
RecordType::AAAA => trust_dns_types::RecordType::AAAA,
RecordType::ANAME => trust_dns_types::RecordType::ANAME,
RecordType::ANY => trust_dns_types::RecordType::ANY,
RecordType::AXFR => trust_dns_types::RecordType::AXFR,
RecordType::CAA => trust_dns_types::RecordType::CAA,
RecordType::CNAME => trust_dns_types::RecordType::CNAME,
RecordType::HINFO => trust_dns_types::RecordType::HINFO,
RecordType::HTTPS => trust_dns_types::RecordType::HTTPS,
RecordType::IXFR => trust_dns_types::RecordType::IXFR,
RecordType::MX => trust_dns_types::RecordType::MX,
RecordType::NAPTR => trust_dns_types::RecordType::NAPTR,
RecordType::NS => trust_dns_types::RecordType::NS,
RecordType::NULL => trust_dns_types::RecordType::NULL,
RecordType::OPENPGPKEY => trust_dns_types::RecordType::OPENPGPKEY,
RecordType::OPT => trust_dns_types::RecordType::OPT,
RecordType::PTR => trust_dns_types::RecordType::PTR,
RecordType::SOA => trust_dns_types::RecordType::SOA,
RecordType::SRV => trust_dns_types::RecordType::SRV,
RecordType::SSHFP => trust_dns_types::RecordType::SSHFP,
RecordType::SVCB => trust_dns_types::RecordType::SVCB,
RecordType::TLSA => trust_dns_types::RecordType::TLSA,
RecordType::TXT => trust_dns_types::RecordType::TXT,
RecordType::DNSKEY => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::DNSKEY),
RecordType::DS => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::DS),
RecordType::KEY => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::KEY),
RecordType::NSEC => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::NSEC),
RecordType::NSEC3 => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::NSEC3),
RecordType::NSEC3PARAM => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::NSEC3PARAM),
RecordType::RRSIG => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::RRSIG),
RecordType::SIG => trust_dns_types::RecordType::DNSSEC(trust_dns_types::DNSSECRecordType::SIG),
RecordType::Unknown(r#type) => trust_dns_types::RecordType::Unknown(r#type),
RecordType::ZERO => trust_dns_types::RecordType::ZERO,
}
}
}
#[derive(Deserialize, Serialize)]
#[serde(tag = "Type")]
......@@ -318,8 +193,6 @@ impl From<trust_dns_types::DNSClass> for DNSClass {
pub struct Record {
#[serde(rename = "Name")]
pub name: String,
//#[serde(rename = "Type")]
//rr_type: RecordType,
#[serde(rename = "Class")]
pub dns_class: DNSClass,
#[serde(rename = "TTL")]
......
......@@ -3,10 +3,10 @@ pub mod errors;
pub mod trust_dns_types {
pub use trust_dns_client::rr::rdata::{
DNSSECRecordType, NULL, caa, DNSSECRData
NULL, caa, DNSSECRData
};
pub use trust_dns_client::rr::{
RecordType, RData, DNSClass, Record
RData, DNSClass, Record
};
pub use trust_dns_proto::rr::Name;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment