├── rustfmt.toml ├── src ├── lib.rs ├── util.rs ├── backend.rs ├── update_message.rs ├── tsig.rs ├── update.rs ├── record.rs ├── bin │ └── tdns.rs └── query.rs ├── .gitignore ├── Cargo.toml ├── Makefile ├── tdns.1.md ├── tdns-query.1.md ├── .github └── workflows │ └── CI.yml ├── tests ├── smoke.rs └── mock │ └── mod.rs ├── README.md ├── tdns-update.1.md ├── LICENSE └── Cargo.lock /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod query; 2 | pub mod record; 3 | pub mod tsig; 4 | pub mod update; 5 | pub mod update_message; 6 | pub mod util; 7 | 8 | pub mod backend; 9 | 10 | pub use backend::{Backend, Resolver, Runtime, TcpBackend, UdpBackend}; 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Standard Rust ignores 2 | /target 3 | **/*.rs.bk 4 | 5 | # Generated man page. These are built when using the included Makefile. 6 | /tdns.1 7 | /tdns.1.html 8 | /tdns-query.1 9 | /tdns-query.1.html 10 | /tdns-update.1 11 | /tdns-update.1.html 12 | 13 | # Produced by the `coverage` Makefile target. 14 | /cobertura.xml 15 | /cobertura.html 16 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tdns-cli" 3 | description = "DNS update client (RFC 2136)" 4 | categories = ["command-line-utilities", "network-programming"] 5 | keywords = ["dns", "update", "dynamic", "nsupdate"] 6 | repository = "https://github.com/rotty/tdns-cli" 7 | homepage = "https://github.com/rotty/tdns-cli" 8 | readme = "README.md" 9 | version = "0.0.5" 10 | authors = ["Andreas Rottmann "] 11 | license = "GPL-3.0-or-later" 12 | edition = "2021" 13 | 14 | [badges] 15 | maintenance = { status = "actively-developed" } 16 | 17 | [dependencies] 18 | async-trait = "0.1.57" 19 | trust-dns-client = "0.20.0" 20 | trust-dns-resolver = "0.20.0" 21 | structopt = "0.3.1" 22 | futures = "0.3.1" 23 | anyhow = "1.0" 24 | tokio = { version = "1.2.0", features = ["full"] } 25 | rand = "0.8.3" 26 | digest = "0.10.1" 27 | hmac = "0.12.0" 28 | sha2 = "0.10.1" 29 | once_cell = "1.2.0" 30 | data-encoding = "2.1.2" 31 | chrono = "0.4.9" 32 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | MAN_HEADER = "tdns Manual" 2 | MAN_SOURCES = tdns.1.md tdns-query.1.md tdns-update.1.md 3 | MAN_HTML_OUTPUT = $(patsubst %.1.md,%.1.html,$(MAN_SOURCES)) 4 | MAN_TROFF_OUTPUT = $(patsubst %.1.md,%.1,$(MAN_SOURCES)) 5 | 6 | MAN_SECTION = 1 7 | 8 | PANDOC_HTML_OPTIONS = 9 | 10 | all: man target/release/tdns 11 | 12 | man: $(MAN_TROFF_OUTPUT) $(MAN_HTML_OUTPUT) 13 | 14 | clean: man-clean 15 | cargo clean 16 | 17 | man-clean: 18 | rm -f $(MAN_TROFF_OUTPUT) $(MAN_HTML_OUTPUT) 19 | 20 | coverage: 21 | cargo tarpaulin --exclude-files 'src/bin/*' src/open.rs 'tests/*' --out Xml \ 22 | && pycobertura show -f html cobertura.xml > cobertura.html 23 | 24 | target/release/tdns: .FORCE 25 | cargo build --release 26 | 27 | %.1: %.1.md Makefile 28 | pandoc -s -M header='$(MAN_HEADER)' -M section=$(MAN_SECTION) -t man $< -o $@ 29 | 30 | %.1.html: %.1.md Makefile 31 | pandoc -s -M header='$(MAN_HEADER)' -M section=$(MAN_SECTION) -t html $(PANDOC_HTML_OPTIONS) $< -o $@ 32 | 33 | .PHONY: .FORCE clean coverage man man-clean 34 | -------------------------------------------------------------------------------- /tdns.1.md: -------------------------------------------------------------------------------- 1 | % TDNS(1) tnds Manual 2 | % Andreas Rottmann 3 | % October, 2019 4 | 5 | # NAME 6 | 7 | tnds - DNS client multitool 8 | 9 | # SYNOPSIS 10 | 11 | __tdns query__ [*options*] *dns-name* 12 | 13 | __tdns update__ [*options*] *dns-name* *rs-data* 14 | 15 | # DESCRIPTION 16 | 17 | __tdns__ is a DNS client, aiming to provide a select subset of the 18 | functionality provided by the `dig` and `nsupdate` commands from the 19 | ISC bind suite. 20 | 21 | # TDNS COMMANDS 22 | 23 | __tdns-query__(1) 24 | : Construct and submit DNS queries, and display the results. 25 | 26 | __tdns-update__(1) 27 | : Update DNS zones via the "DNS UPDATE" mechanism specified in 28 | RFC 2136. Authenticated updates are possible via TSIG (RFC 2845). 29 | 30 | # EXAMPLES 31 | 32 | Query for IPv4 and IPv6 addresses associated with a DNS name: 33 | 34 | tdns query -t A,AAAA example.org 35 | 36 | Create a fresh DNS entry, using a key file to sign the update request 37 | with a shared secret: 38 | 39 | tdns update --create foo.example.org A:10.1.2.3 --key-file secret.key 40 | -------------------------------------------------------------------------------- /tdns-query.1.md: -------------------------------------------------------------------------------- 1 | % TDNS-UPDATE(1) tnds-query Manual 2 | % Andreas Rottmann 3 | % October, 2019 4 | 5 | # NAME 6 | 7 | tnds-query - DNS query client 8 | 9 | # SYNOPSIS 10 | 11 | __tdns query__ [*options*] *dns-name* 12 | 13 | # DESCRIPTION 14 | 15 | __tdns query__ provides a subset of the functionality found in the 16 | `dig` utility which is distributed as part of the ISC BIND suite. Its 17 | functionality is currently quite limited compared to `dig`, but 18 | extending it to be a reasonable replacement for common usage is 19 | planned. 20 | 21 | # OPTIONS 22 | 23 | \--resolver=*address* 24 | : DNS server to send queries to. If not specified, the resolver name 25 | will be determined based on the contents of `/etc/resolv.conf`, 26 | using the first `nameserver` entry given therein. 27 | 28 | \--tcp 29 | : Use TCP for all DNS requests. 30 | 31 | # EXAMPLES 32 | 33 | Query for IPv4 and IPv6 addresses associated with a DNS name: 34 | 35 | tdns query -t A,AAAA example.org 36 | 37 | # BUGS 38 | 39 | - Only the record data is shown, similar to `dig +short`. 40 | - Only record data of for types `A`, `AAAA` and `TXT` are displayed 41 | properly. 42 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | on: [pull_request] 2 | name: CI 3 | 4 | jobs: 5 | check: 6 | name: Check 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout sources 10 | uses: actions/checkout@v2 11 | 12 | - name: Install stable toolchain 13 | uses: actions-rs/toolchain@v1 14 | with: 15 | profile: minimal 16 | toolchain: stable 17 | override: true 18 | 19 | - name: Run cargo check 20 | uses: actions-rs/cargo@v1 21 | with: 22 | command: check 23 | 24 | test: 25 | name: Test Suite 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Checkout sources 29 | uses: actions/checkout@v2 30 | 31 | - name: Install stable toolchain 32 | uses: actions-rs/toolchain@v1 33 | with: 34 | profile: minimal 35 | toolchain: stable 36 | override: true 37 | 38 | - name: Run cargo test 39 | uses: actions-rs/cargo@v1 40 | with: 41 | command: test 42 | 43 | lints: 44 | name: Lints 45 | runs-on: ubuntu-latest 46 | steps: 47 | - name: Checkout sources 48 | uses: actions/checkout@v2 49 | 50 | - name: Install stable toolchain 51 | uses: actions-rs/toolchain@v1 52 | with: 53 | profile: minimal 54 | toolchain: stable 55 | override: true 56 | components: rustfmt, clippy 57 | 58 | - name: Run cargo fmt 59 | uses: actions-rs/cargo@v1 60 | with: 61 | command: fmt 62 | args: --all -- --check 63 | 64 | - name: Run cargo clippy 65 | uses: actions-rs/cargo@v1 66 | with: 67 | command: clippy 68 | args: -- -D warnings 69 | -------------------------------------------------------------------------------- /src/util.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fmt, 3 | net::{IpAddr, SocketAddr}, 4 | num::ParseIntError, 5 | str::FromStr, 6 | }; 7 | 8 | use trust_dns_client::{op::ResponseCode, proto::error::ProtoError, rr}; 9 | use trust_dns_resolver::error::{ResolveError, ResolveErrorKind}; 10 | 11 | use crate::Resolver; 12 | 13 | pub fn parse_comma_separated(s: &str) -> Result, T::Err> 14 | where 15 | T: FromStr, 16 | { 17 | s.split(',') 18 | .map(|part| part.parse()) 19 | .collect::>() 20 | } 21 | 22 | /// A potential unresolved host name, with an optional port number. 23 | #[derive(Debug, Clone)] 24 | pub enum SocketName { 25 | HostName(rr::Name, Option), 26 | SocketAddr(SocketAddr), 27 | IpAddr(IpAddr), 28 | } 29 | 30 | impl SocketName { 31 | pub async fn resolve( 32 | &self, 33 | resolver: impl Resolver, 34 | default_port: u16, 35 | ) -> Result { 36 | match self { 37 | SocketName::HostName(name, port) => { 38 | let port = port.unwrap_or(default_port); 39 | let lookup = resolver.lookup_ip(name.clone()).await?; 40 | // TODO: how to choose from multiple addresses 41 | if let Some(ip) = lookup.iter().next() { 42 | Ok(SocketAddr::new(ip, port)) 43 | } else { 44 | Err(ResolveErrorKind::NoRecordsFound { 45 | query: lookup.query().clone(), 46 | soa: None, 47 | negative_ttl: None, 48 | response_code: ResponseCode::NXDomain, 49 | trusted: false, 50 | } 51 | .into()) 52 | } 53 | } 54 | SocketName::IpAddr(addr) => Ok(SocketAddr::new(*addr, default_port)), 55 | SocketName::SocketAddr(addr) => Ok(*addr), 56 | } 57 | } 58 | } 59 | 60 | impl FromStr for SocketName { 61 | type Err = ParseSocketNameError; 62 | 63 | fn from_str(s: &str) -> Result { 64 | s.parse() 65 | .map(SocketName::SocketAddr) 66 | .or_else(|_| s.parse().map(SocketName::IpAddr)) 67 | .or_else(|_| { 68 | let parts: Vec<_> = s.split(':').collect(); 69 | match parts.len() { 70 | 1 => Ok(SocketName::HostName( 71 | parts[0].parse().map_err(ParseSocketNameError::Name)?, 72 | None, 73 | )), 74 | 2 => Ok(SocketName::HostName( 75 | parts[0].parse().map_err(ParseSocketNameError::Name)?, 76 | Some(parts[1].parse().map_err(ParseSocketNameError::Port)?), 77 | )), 78 | _ => Err(ParseSocketNameError::Invalid), 79 | } 80 | }) 81 | } 82 | } 83 | 84 | impl fmt::Display for ParseSocketNameError { 85 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 86 | use ParseSocketNameError::*; 87 | match self { 88 | Invalid => write!( 89 | f, 90 | "invalid socket name, expected IP, IP:PORT, HOST, or HOST:PORT" 91 | ), 92 | Name(e) => write!(f, "invalid host name: {}", e), 93 | Port(e) => write!(f, "invalid port: {}", e), 94 | } 95 | } 96 | } 97 | 98 | impl std::error::Error for ParseSocketNameError {} 99 | 100 | #[derive(Debug)] 101 | pub enum ParseSocketNameError { 102 | Invalid, 103 | Name(ProtoError), 104 | Port(ParseIntError), 105 | } 106 | -------------------------------------------------------------------------------- /src/backend.rs: -------------------------------------------------------------------------------- 1 | /// An abstraction over different ways to do DNS queries. 2 | use std::net::SocketAddr; 3 | 4 | use async_trait::async_trait; 5 | use tokio::net::{TcpStream, UdpSocket}; 6 | use trust_dns_client::{ 7 | client::{AsyncClient, ClientFuture, ClientHandle}, 8 | rr, 9 | tcp::TcpClientStream, 10 | udp::UdpClientStream, 11 | }; 12 | use trust_dns_resolver::{ 13 | config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts}, 14 | error::ResolveError, 15 | lookup, lookup_ip, 16 | proto::{error::ProtoError, xfer::dns_request::DnsRequestOptions}, 17 | TokioAsyncResolver, 18 | }; 19 | 20 | pub use tokio::runtime::Runtime; 21 | 22 | pub type RuntimeHandle = tokio::runtime::Handle; 23 | 24 | #[async_trait] 25 | pub trait Resolver: Clone { 26 | async fn lookup( 27 | &self, 28 | name: rr::Name, 29 | rtype: rr::RecordType, 30 | ) -> Result; 31 | async fn lookup_ip(&self, host: rr::Name) -> Result; 32 | async fn lookup_soa(&self, name: rr::Name) -> Result; 33 | async fn lookup_ns(&self, name: rr::Name) -> Result; 34 | } 35 | 36 | #[async_trait] 37 | impl Resolver for TokioAsyncResolver { 38 | async fn lookup( 39 | &self, 40 | name: rr::Name, 41 | rtype: rr::RecordType, 42 | ) -> Result { 43 | TokioAsyncResolver::lookup(self, name, rtype, DnsRequestOptions::default()).await 44 | } 45 | 46 | async fn lookup_ip(&self, host: rr::Name) -> Result { 47 | TokioAsyncResolver::lookup_ip(self, host).await 48 | } 49 | 50 | async fn lookup_soa(&self, name: rr::Name) -> Result { 51 | TokioAsyncResolver::soa_lookup(self, name).await 52 | } 53 | 54 | async fn lookup_ns(&self, name: rr::Name) -> Result { 55 | TokioAsyncResolver::ns_lookup(self, name).await 56 | } 57 | } 58 | 59 | #[async_trait] 60 | pub trait Backend: Clone { 61 | type Client: ClientHandle; 62 | type Resolver: Resolver; 63 | async fn open( 64 | &mut self, 65 | runtime: &Runtime, 66 | addr: SocketAddr, 67 | ) -> Result; 68 | fn open_resolver(&mut self, addr: SocketAddr) -> Result; 69 | fn open_system_resolver(&mut self) -> Result; 70 | } 71 | 72 | #[derive(Debug, Clone)] 73 | pub struct TcpBackend; 74 | 75 | #[async_trait] 76 | impl Backend for TcpBackend { 77 | type Client = AsyncClient; 78 | type Resolver = TokioAsyncResolver; 79 | 80 | async fn open( 81 | &mut self, 82 | runtime: &Runtime, 83 | addr: SocketAddr, 84 | ) -> Result { 85 | use trust_dns_resolver::proto::iocompat::AsyncIoTokioAsStd; 86 | let (stream, sender) = TcpClientStream::>::new(addr); 87 | let (client, bg) = AsyncClient::new(Box::new(stream), sender, None).await?; 88 | runtime.spawn(bg); 89 | Ok(client) 90 | } 91 | 92 | fn open_resolver(&mut self, addr: SocketAddr) -> Result { 93 | make_resolver(addr, Protocol::Tcp) 94 | } 95 | 96 | fn open_system_resolver(&mut self) -> Result { 97 | TokioAsyncResolver::tokio_from_system_conf() 98 | } 99 | } 100 | 101 | #[derive(Debug, Clone)] 102 | pub struct UdpBackend; 103 | 104 | #[async_trait] 105 | impl Backend for UdpBackend { 106 | type Client = AsyncClient; 107 | type Resolver = TokioAsyncResolver; 108 | 109 | async fn open( 110 | &mut self, 111 | runtime: &Runtime, 112 | addr: SocketAddr, 113 | ) -> Result { 114 | let stream = UdpClientStream::::new(addr); 115 | let (client, bg) = ClientFuture::connect(stream).await?; 116 | runtime.spawn(bg); 117 | Ok(client) 118 | } 119 | 120 | fn open_resolver(&mut self, addr: SocketAddr) -> Result { 121 | make_resolver(addr, Protocol::Udp) 122 | } 123 | 124 | fn open_system_resolver(&mut self) -> Result { 125 | TokioAsyncResolver::tokio_from_system_conf() 126 | } 127 | } 128 | 129 | fn make_resolver(addr: SocketAddr, protocol: Protocol) -> Result { 130 | let mut config = ResolverConfig::new(); 131 | config.add_name_server(NameServerConfig { 132 | socket_addr: addr, 133 | protocol, 134 | tls_dns_name: None, 135 | trust_nx_responses: true, 136 | }); 137 | TokioAsyncResolver::tokio(config, ResolverOpts::default()) 138 | } 139 | -------------------------------------------------------------------------------- /src/update_message.rs: -------------------------------------------------------------------------------- 1 | use trust_dns_client::{ 2 | op::{Message, MessageType, OpCode, Query, UpdateMessage}, 3 | rr::{rdata::NULL, DNSClass, Name, RData, Record, RecordSet, RecordType}, 4 | }; 5 | 6 | // This code is taken from `update_message.rs` in the `trust_dns` crate, and 7 | // adapted to omit EDNS. 8 | pub fn create(rrset: RecordSet, zone_origin: Name) -> Message { 9 | // TODO: assert non-empty rrset? 10 | assert!(zone_origin.zone_of(rrset.name())); 11 | 12 | // for updates, the query section is used for the zone 13 | let mut zone = Query::new(); 14 | zone.set_name(zone_origin) 15 | .set_query_class(rrset.dns_class()) 16 | .set_query_type(RecordType::SOA); 17 | 18 | // build the message 19 | let mut message: Message = Message::new(); 20 | message 21 | .set_id(rand::random()) 22 | .set_message_type(MessageType::Query) 23 | .set_op_code(OpCode::Update) 24 | .set_recursion_desired(false); 25 | message.add_zone(zone); 26 | 27 | let mut prerequisite = Record::with(rrset.name().clone(), rrset.record_type(), 0); 28 | prerequisite.set_dns_class(DNSClass::NONE); 29 | message.add_pre_requisite(prerequisite); 30 | message.add_updates(rrset); 31 | message 32 | } 33 | 34 | pub fn append(rrset: RecordSet, zone_origin: Name, must_exist: bool) -> Message { 35 | assert!(zone_origin.zone_of(rrset.name())); 36 | 37 | // for updates, the query section is used for the zone 38 | let mut zone: Query = Query::new(); 39 | zone.set_name(zone_origin) 40 | .set_query_class(rrset.dns_class()) 41 | .set_query_type(RecordType::SOA); 42 | 43 | // build the message 44 | let mut message: Message = Message::new(); 45 | message 46 | .set_id(rand::random()) 47 | .set_message_type(MessageType::Query) 48 | .set_op_code(OpCode::Update) 49 | .set_recursion_desired(false); 50 | message.add_zone(zone); 51 | 52 | if must_exist { 53 | let mut prerequisite = Record::with(rrset.name().clone(), rrset.record_type(), 0); 54 | prerequisite.set_dns_class(DNSClass::ANY); 55 | message.add_pre_requisite(prerequisite); 56 | } 57 | 58 | message.add_updates(rrset); 59 | 60 | message 61 | } 62 | 63 | pub fn delete_by_rdata(mut rrset: RecordSet, zone_origin: Name) -> Message { 64 | assert!(zone_origin.zone_of(rrset.name())); 65 | 66 | // for updates, the query section is used for the zone 67 | let mut zone: Query = Query::new(); 68 | zone.set_name(zone_origin) 69 | .set_query_class(rrset.dns_class()) 70 | .set_query_type(RecordType::SOA); 71 | 72 | // build the message 73 | let mut message: Message = Message::new(); 74 | message 75 | .set_id(rand::random()) 76 | .set_message_type(MessageType::Query) 77 | .set_op_code(OpCode::Update) 78 | .set_recursion_desired(false); 79 | message.add_zone(zone); 80 | 81 | // the class must be none for delete 82 | rrset.set_dns_class(DNSClass::NONE); 83 | // the TTL should be 0 84 | rrset.set_ttl(0); 85 | message.add_updates(rrset); 86 | 87 | message 88 | } 89 | 90 | pub fn delete_rrset(mut record: Record, zone_origin: Name) -> Message { 91 | assert!(zone_origin.zone_of(record.name())); 92 | 93 | // for updates, the query section is used for the zone 94 | let mut zone: Query = Query::new(); 95 | zone.set_name(zone_origin) 96 | .set_query_class(record.dns_class()) 97 | .set_query_type(RecordType::SOA); 98 | 99 | // build the message 100 | let mut message: Message = Message::new(); 101 | message 102 | .set_id(rand::random()) 103 | .set_message_type(MessageType::Query) 104 | .set_op_code(OpCode::Update) 105 | .set_recursion_desired(false); 106 | message.add_zone(zone); 107 | 108 | // the class must be none for an rrset delete 109 | record.set_dns_class(DNSClass::ANY); 110 | // the TTL should be 0 111 | record.set_ttl(0); 112 | // the rdata must be null to delete all rrsets 113 | record.set_rdata(RData::NULL(NULL::new())); 114 | message.add_update(record); 115 | 116 | message 117 | } 118 | 119 | pub fn delete_all(name_of_records: Name, zone_origin: Name, dns_class: DNSClass) -> Message { 120 | assert!(zone_origin.zone_of(&name_of_records)); 121 | 122 | // for updates, the query section is used for the zone 123 | let mut zone: Query = Query::new(); 124 | zone.set_name(zone_origin) 125 | .set_query_class(dns_class) 126 | .set_query_type(RecordType::SOA); 127 | 128 | // build the message 129 | let mut message: Message = Message::new(); 130 | message 131 | .set_id(rand::random()) 132 | .set_message_type(MessageType::Query) 133 | .set_op_code(OpCode::Update) 134 | .set_recursion_desired(false); 135 | message.add_zone(zone); 136 | 137 | // the TTL should be 0 138 | // the rdata must be null to delete all rrsets 139 | // the record type must be any 140 | let mut record = Record::with(name_of_records, RecordType::ANY, 0); 141 | 142 | // the class must be none for an rrset delete 143 | record.set_dns_class(DNSClass::ANY); 144 | 145 | message.add_update(record); 146 | 147 | message 148 | } 149 | -------------------------------------------------------------------------------- /tests/smoke.rs: -------------------------------------------------------------------------------- 1 | use std::{pin::Pin, time::Duration}; 2 | 3 | use futures::{prelude::*, stream::FuturesUnordered}; 4 | use tdns_cli::{ 5 | record::RecordSet, 6 | update::{monitor_update, perform_update, Expectation, Monitor, Operation, Update}, 7 | Backend, 8 | }; 9 | use tokio::{runtime::Runtime, time::sleep}; 10 | use trust_dns_client::rr; 11 | 12 | mod mock; 13 | use mock::{parse_rdata, MockBackend, ZoneEntries}; 14 | 15 | const TIMEOUT: Duration = Duration::from_millis(10); 16 | 17 | fn monitor_settings(expected: &str) -> Monitor { 18 | let rset = RecordSet::new( 19 | "foo.example.org".parse().unwrap(), 20 | expected.parse().unwrap(), 21 | ); 22 | Monitor { 23 | zone: "example.org".parse().unwrap(), 24 | entry: "foo.example.org".parse().unwrap(), 25 | expectation: if rset.is_empty() { 26 | Expectation::Empty(rset.record_type()) 27 | } else { 28 | Expectation::Is(rset) 29 | }, 30 | exclude: Default::default(), 31 | interval: TIMEOUT / 100, 32 | timeout: TIMEOUT, 33 | verbose: true, 34 | } 35 | } 36 | 37 | fn update_settings(operation: Operation) -> Update { 38 | Update { 39 | zone: "example.org".parse().unwrap(), 40 | server: None, 41 | operation, 42 | tsig_key: None, 43 | ttl: 300, 44 | } 45 | } 46 | 47 | fn mock_dns(master_data: ZoneEntries) -> (MockBackend, mock::Handle) { 48 | let rec_data: &[_] = &[ 49 | ( 50 | "example.org", 51 | "SOA", 52 | "sns.dns.icann.org. noc.dns.icann.org. 2019090512 7200 3600 1209600 3600", 53 | ), 54 | ("example.org", "NS", "a.iana-servers.net."), 55 | ("example.org", "NS", "b.iana-servers.net."), 56 | ("a.iana-servers.net", "A", "199.43.135.53"), 57 | ("b.iana-servers.net", "A", "199.43.133.53"), 58 | ("sns.dns.icann.org", "A", "192.0.32.162"), 59 | ]; 60 | let rec_addr = "127.0.0.1:53".parse().unwrap(); 61 | let master_addr = "192.0.32.162:53".parse().unwrap(); 62 | let mut mock = MockBackend::default(); 63 | mock.add_server(rec_addr, rec_data).unwrap(); 64 | let master = mock.add_server(master_addr, master_data).unwrap(); 65 | (mock, master) 66 | } 67 | 68 | fn mock_dns_fixed( 69 | master_data: ZoneEntries, 70 | auth1_data: ZoneEntries, 71 | auth2_data: ZoneEntries, 72 | ) -> MockBackend { 73 | let (mut dns, _) = mock_dns(master_data); 74 | let auth1_addr = "199.43.135.53:53".parse().unwrap(); 75 | let auth2_addr = "199.43.133.53:53".parse().unwrap(); 76 | dns.add_server(auth1_addr, auth1_data).unwrap(); 77 | dns.add_server(auth2_addr, auth2_data).unwrap(); 78 | dns 79 | } 80 | 81 | fn mock_dns_shared(master_data: ZoneEntries) -> (MockBackend, mock::Handle) { 82 | let (mut dns, master) = mock_dns(master_data); 83 | let auth1_addr = "199.43.135.53:53".parse().unwrap(); 84 | let auth2_addr = "199.43.133.53:53".parse().unwrap(); 85 | let master = master.lock().unwrap(); 86 | dns.add_shared(auth1_addr, master.zone()); 87 | dns.add_shared(auth2_addr, master.zone()); 88 | (dns, master.zone()) 89 | } 90 | 91 | fn mock_dns_independent(master_data: ZoneEntries) -> (MockBackend, mock::Handle) { 92 | let (mut dns, _) = mock_dns(master_data); 93 | let auth1_addr = "199.43.135.53:53".parse().unwrap(); 94 | let auth2_addr = "199.43.133.53:53".parse().unwrap(); 95 | let slave = dns.add_server(auth1_addr, master_data).unwrap(); 96 | let slave = slave.lock().unwrap(); 97 | dns.add_shared(auth2_addr, slave.zone()); 98 | (dns, slave.zone()) 99 | } 100 | 101 | #[test] 102 | fn test_monitor_match() { 103 | let runtime = Runtime::new().unwrap(); 104 | let (mut dns, _) = mock_dns_shared(&[("foo.example.org", "A", "192.168.1.1")]); 105 | let resolver = runtime 106 | .block_on(dns.open(&runtime, "127.0.0.1:53".parse().unwrap())) 107 | .expect("failed to open resolver"); 108 | let monitor = monitor_update(&runtime, dns, resolver, monitor_settings("A:192.168.1.1")); 109 | runtime.block_on(monitor).unwrap(); 110 | } 111 | 112 | #[test] 113 | fn test_monitor_mismatch() { 114 | let runtime = Runtime::new().unwrap(); 115 | let mut dns = mock_dns_fixed( 116 | &[("foo.example.org", "A", "192.168.1.1")], 117 | &[("foo.example.org", "A", "192.168.1.1")], 118 | &[("foo.example.org", "A", "192.168.1.2")], 119 | ); 120 | let resolver = runtime 121 | .block_on(dns.open(&runtime, "127.0.0.1:53".parse().unwrap())) 122 | .expect("failed to open resolver"); 123 | let monitor = monitor_update(&runtime, dns, resolver, monitor_settings("A:192.168.1.1")); 124 | let result = runtime.block_on(monitor); 125 | assert!(result.is_err()); // TODO: check for timeout error, specifically 126 | } 127 | 128 | #[test] 129 | fn test_create_immediate() { 130 | let runtime = Runtime::new().unwrap(); 131 | let (mut dns, _) = mock_dns_shared(&[("foo.example.org", "A", "192.168.1.1")]); 132 | let resolver = runtime 133 | .block_on(dns.open(&runtime, "127.0.0.1:53".parse().unwrap())) 134 | .expect("failed to open resolver"); 135 | let update = perform_update( 136 | &runtime, 137 | dns.clone(), 138 | resolver.clone(), 139 | update_settings(Operation::Create(RecordSet::new( 140 | "foo.example.org".parse().unwrap(), 141 | "A:192.168.1.2".parse().unwrap(), 142 | ))), 143 | ); 144 | let monitor = monitor_update(&runtime, dns, resolver, monitor_settings("A:192.168.1.2")); 145 | runtime.block_on(update.and_then(|_| monitor)).unwrap(); 146 | } 147 | 148 | #[test] 149 | fn test_create_delayed() { 150 | let runtime = Runtime::new().unwrap(); 151 | let (mut dns, zone) = mock_dns_independent(&[("foo.example.org", "A", "192.168.1.1")]); 152 | let resolver = runtime 153 | .block_on(dns.open(&runtime, "127.0.0.1:53".parse().unwrap())) 154 | .expect("failed to open resolver"); 155 | let update = perform_update( 156 | &runtime, 157 | dns, 158 | resolver, 159 | update_settings(Operation::create( 160 | "foo.example.org".parse().unwrap(), 161 | "A:192.168.1.2".parse().unwrap(), 162 | )), 163 | ); 164 | async fn update_auth(zone: mock::Handle) -> anyhow::Result<()> { 165 | sleep(TIMEOUT / 2).await; 166 | let updated = rr::Record::from_rdata( 167 | "foo.example.org".parse().unwrap(), 168 | 0, 169 | parse_rdata("A", "192.168.1.2").unwrap(), 170 | ); 171 | let mut zone = zone.lock().unwrap(); 172 | zone.update(&updated); 173 | Ok(()) 174 | } 175 | let parallel = FuturesUnordered::new(); 176 | parallel.push(Box::pin(update) as Pin>>>); 177 | parallel.push(Box::pin(update_auth(zone))); 178 | runtime.block_on(parallel.try_collect::>()).unwrap(); 179 | } 180 | 181 | #[test] 182 | fn test_delete() { 183 | let runtime = Runtime::new().unwrap(); 184 | let (mut dns, _) = mock_dns_shared(&[("foo.example.org", "A", "192.168.1.1")]); 185 | let resolver = runtime 186 | .block_on(dns.open(&runtime, "127.0.0.1:53".parse().unwrap())) 187 | .expect("failed to open resolver"); 188 | let update = perform_update( 189 | &runtime, 190 | dns.clone(), 191 | resolver.clone(), 192 | update_settings(Operation::delete( 193 | "foo.example.org".parse().unwrap(), 194 | "A:192.168.1.1".parse().unwrap(), 195 | )), 196 | ); 197 | let monitor = monitor_update(&runtime, dns, resolver, monitor_settings("A")); 198 | runtime.block_on(update.and_then(|_| monitor)).unwrap(); 199 | } 200 | -------------------------------------------------------------------------------- /tests/mock/mod.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | collections::HashMap, 3 | convert::{TryFrom, TryInto}, 4 | net::SocketAddr, 5 | sync::{Arc, Mutex}, 6 | }; 7 | 8 | use anyhow::anyhow; 9 | use async_trait::async_trait; 10 | use futures::future; 11 | use trust_dns_client::{ 12 | op::update_message::UpdateMessage, 13 | proto::{ 14 | error::ProtoError, 15 | op::{Message, OpCode, Query}, 16 | rr, 17 | xfer::{DnsRequest, DnsResponse}, 18 | DnsHandle, 19 | }, 20 | }; 21 | use trust_dns_resolver::{ 22 | error::{ResolveError, ResolveErrorKind}, 23 | lookup, 24 | lookup::Lookup, 25 | lookup_ip, 26 | }; 27 | 28 | use tdns_cli::{Backend, Resolver, Runtime}; 29 | 30 | pub type Handle = Arc>; 31 | pub type FutureResult = future::Ready>; 32 | 33 | #[derive(Debug, Clone)] 34 | pub struct Zone(Vec); 35 | 36 | impl Zone { 37 | fn matches(&self, query: &Query) -> impl Iterator + '_ { 38 | let query = query.clone(); 39 | self.0 40 | .iter() 41 | .filter(move |r| r.name() == query.name()) 42 | .cloned() 43 | } 44 | pub fn update(&mut self, update: &rr::Record) { 45 | if update.dns_class() == rr::DNSClass::NONE { 46 | self.0 47 | .retain(|r| r.record_type() != update.record_type() && r.name() != update.name()); 48 | } else if let Some(record) = self 49 | .0 50 | .iter_mut() 51 | .find(|r| r.record_type() == update.record_type() && r.name() == update.name()) 52 | { 53 | record.set_rdata(update.rdata().clone()); 54 | } 55 | } 56 | } 57 | 58 | pub fn parse_rdata(rtype: &str, rdata: &str) -> anyhow::Result { 59 | use rr::{rdata::SOA, RData}; 60 | match rtype { 61 | "A" => Ok(RData::A(rdata.parse()?)), 62 | "AAAA" => Ok(RData::AAAA(rdata.parse()?)), 63 | "NS" => Ok(RData::NS(rdata.parse()?)), 64 | "SOA" => { 65 | let parts: Vec<_> = rdata.split(' ').collect(); 66 | // This quite ugly -- is there a better way? 67 | Ok(RData::SOA(SOA::new( 68 | parts[0].parse()?, 69 | parts[1].parse()?, 70 | parts[2].parse()?, 71 | parts[3].parse()?, 72 | parts[4].parse()?, 73 | parts[5].parse()?, 74 | parts[6].parse()?, 75 | ))) 76 | } 77 | _ => Err(anyhow!("unsupported record type: {}", rtype)), 78 | } 79 | } 80 | 81 | pub type ZoneEntries<'a> = &'a [(&'a str, &'a str, &'a str)]; 82 | 83 | impl<'a> TryFrom> for Zone { 84 | type Error = anyhow::Error; 85 | 86 | fn try_from(entries: ZoneEntries) -> Result { 87 | Ok(Zone( 88 | entries 89 | .iter() 90 | .map(|(name, rtype, rdata)| { 91 | Ok(rr::Record::from_rdata( 92 | name.parse()?, 93 | 0, 94 | parse_rdata(rtype, rdata)?, 95 | )) 96 | }) 97 | .collect::>()?, 98 | )) 99 | } 100 | } 101 | 102 | #[derive(Clone, Default)] 103 | pub struct MockBackend { 104 | resolv_conf: Option, 105 | servers: HashMap>, 106 | } 107 | 108 | impl MockBackend { 109 | pub fn add_server(&mut self, addr: SocketAddr, zone: T) -> Result, T::Error> 110 | where 111 | T: TryInto, 112 | { 113 | let server = Arc::new(Mutex::new(Server { 114 | zone: Arc::new(Mutex::new(zone.try_into()?)), 115 | query_log: Default::default(), 116 | })); 117 | self.servers.insert(addr, server.clone()); 118 | Ok(server) 119 | } 120 | 121 | pub fn add_shared(&mut self, addr: SocketAddr, zone: Handle) { 122 | let server = Arc::new(Mutex::new(Server { 123 | zone, 124 | query_log: Default::default(), 125 | })); 126 | self.servers.insert(addr, server); 127 | } 128 | 129 | fn open_client(&self, addr: SocketAddr) -> Client { 130 | let server = self 131 | .servers 132 | .get(&addr) 133 | .unwrap_or_else(|| panic!("no server for address {}", addr)); 134 | Client(server.clone()) 135 | } 136 | } 137 | 138 | #[async_trait] 139 | impl Backend for MockBackend { 140 | type Client = Client; 141 | type Resolver = Client; 142 | async fn open( 143 | &mut self, 144 | _runtime: &Runtime, 145 | addr: SocketAddr, 146 | ) -> Result { 147 | Ok(self.open_client(addr)) 148 | } 149 | fn open_resolver(&mut self, addr: SocketAddr) -> Result { 150 | Ok(self.open_client(addr)) 151 | } 152 | fn open_system_resolver(&mut self) -> Result { 153 | if let Some(addr) = self.resolv_conf { 154 | Ok(self.open_client(addr)) 155 | } else { 156 | Err(ResolveErrorKind::Message("no system resolver address configured").into()) 157 | } 158 | } 159 | } 160 | 161 | #[derive(Clone)] 162 | pub struct Client(Arc>); 163 | 164 | impl Client { 165 | fn query(&self, query: Query) -> Result { 166 | let mut server = self.0.lock().unwrap(); 167 | let mut message = Message::new(); 168 | message.add_query(query); 169 | server.request(message.into()) 170 | } 171 | fn lookup_base(&self, name: rr::Name, rtype: rr::RecordType) -> Result { 172 | let query = Query::query(name, rtype); 173 | self.query(query.clone()) 174 | .map(|response| { 175 | Lookup::new_with_max_ttl(query, response.answers().iter().cloned().collect()) 176 | }) 177 | .map_err(Into::into) 178 | } 179 | } 180 | 181 | pub struct Server { 182 | zone: Handle, 183 | query_log: Vec, 184 | } 185 | 186 | impl Server { 187 | pub fn zone(&self) -> Handle { 188 | Arc::clone(&self.zone) 189 | } 190 | fn request(&mut self, request: DnsRequest) -> Result { 191 | self.query_log.push(request.clone()); 192 | match request.op_code() { 193 | OpCode::Query => { 194 | let mut message = Message::new(); 195 | let zone = self.zone.lock().unwrap(); 196 | for query in request.queries() { 197 | for record in zone.matches(query) { 198 | message.add_answer(record); 199 | } 200 | } 201 | Ok(message.into()) 202 | } 203 | OpCode::Update => { 204 | let mut zone = self.zone.lock().unwrap(); 205 | for update in request.updates() { 206 | zone.update(update); 207 | } 208 | Ok(Message::new().into()) 209 | } 210 | _ => unimplemented!(), 211 | } 212 | } 213 | } 214 | 215 | impl DnsHandle for Client { 216 | type Error = ProtoError; 217 | type Response = FutureResult; 218 | 219 | fn send>(&mut self, request: R) -> Self::Response { 220 | let mut server = self.0.lock().unwrap(); 221 | future::ready(server.request(request.into())) 222 | } 223 | } 224 | 225 | #[async_trait] 226 | impl Resolver for Client { 227 | async fn lookup( 228 | &self, 229 | name: rr::Name, 230 | rtype: rr::RecordType, 231 | ) -> Result { 232 | self.lookup_base(name, rtype) 233 | } 234 | async fn lookup_ip(&self, host: rr::Name) -> Result { 235 | // TODO: IPv6 236 | self.lookup_base(host, rr::RecordType::A).map(Into::into) 237 | } 238 | async fn lookup_soa(&self, name: rr::Name) -> Result { 239 | self.lookup_base(name, rr::RecordType::SOA).map(Into::into) 240 | } 241 | async fn lookup_ns(&self, name: rr::Name) -> Result { 242 | self.lookup_base(name, rr::RecordType::NS).map(Into::into) 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tdns [![Build Status]][travis] 2 | 3 | [Build Status]: https://api.travis-ci.org/rotty/tdns-cli.svg?branch=master 4 | [travis]: https://travis-ci.org/rotty/tdns-cli 5 | 6 | A DNS client command-line tool, with aspirations to become a swiss 7 | army knife when it has grown up. 8 | 9 | `tdns` aims to grow into a replacement for the `nsupdate` and `dig` 10 | commands distributed as part of the ISC bind suite, adding features 11 | such as propagation checking for updates and a more convenient (and 12 | "standard") command-line interface. 13 | 14 | `tdns` is implemented in Rust, taking advantage of the terrific 15 | [`trust-dns`] DNS client library, and uses a single-threaded, 16 | non-blocking runtime. Translated from developer speak, this means that 17 | `tdns-udpate` should be very light on system resources, and cope well 18 | even with unreasonably large tasks, such as monitoring a record in a 19 | zone that is served by hundreds of authoritative nameservers. 20 | 21 | Note that `tdns` is currently in its initial development phase. The 22 | usual caveats apply. If you're still interested, read on for more 23 | information of what is currently working, and what is planned. 24 | 25 | ## Installation 26 | 27 | As `tdns` is written in Rust, you need a [Rust toolchain]. Rust 1.37 28 | or newer is required. To obtain the latest release from [crates.io], 29 | use: 30 | 31 | ```sh 32 | cargo install tdns-cli 33 | ``` 34 | 35 | Alternatively, you can run it directly from the source checkout, note 36 | that the master branch is using `async/await`, which requires Rust 37 | 1.39, currently in beta; so you need the beta toolchain. 38 | 39 | ```sh 40 | cargo +beta run -- --help 41 | ``` 42 | 43 | To install from locally checked-out source, use `cargo +beta install 44 | --path .`, which will end up installing the executable in 45 | `~/.cargo/bin/tdns`, which should already be in your `PATH` 46 | environment variable, if you followed the Rust toolchain installations 47 | instructions. 48 | 49 | ### Static build 50 | 51 | For deployment to a Linux target, an attractive option is to create a 52 | statically linked binary using Rust's MUSL target. This will result in 53 | a completely standalone binary, which depends only on the Linux 54 | kernel's system call ABI. 55 | 56 | ```sh 57 | # If you haven't installed the MUSL target already, let's do that now: 58 | rustup target add x86_64-unknown-linux-musl 59 | # Build against the MUSL libc target 60 | cargo build --target x86_64-unknown-linux-musl --release 61 | # Let's check it's really a static binary 62 | file target/x86_64-unknown-linux-musl/release/tdns \ 63 | | grep -q 'statically linked' || echo "nope" 64 | ``` 65 | 66 | ### Documentation 67 | 68 | The documentation for the `tdns` and its subcommands are provided in 69 | the form of Unix man pages, rendered from markdown source files, which 70 | can be turned in to troff format for viewing with the `man` command 71 | using [pandoc]. Note that to the markdown sources are tailored toward 72 | producing good output when fed through pandoc, and will not be 73 | rendered that nicely on github or alike, and is not ideal to read in 74 | plain, either. 75 | 76 | You can generate the manpages using the included `Makefile`, and view 77 | the man page using the Unix `man` command: 78 | 79 | ```sh 80 | make man 81 | man -l tdns.1 82 | man -l tnds-query.1 83 | man -l tnds-update.1 84 | ``` 85 | 86 | HTML renderings of the manpages are also created when running `make`, 87 | these are also available online: 88 | 89 | - [tdns.1](https://r0tty.org/software/tnds.1.html), providing an 90 | overview. 91 | - [tdns-query.1](https://r0tty.org/software/tnds-query.1.html), 92 | documenting the `tdns query` subcommand. 93 | - [tdns-update.1](https://r0tty.org/software/tnds-update.1.html), 94 | documenting the `tdns update` subcommand. 95 | 96 | ## Available subcommands 97 | 98 | ### tdns query 99 | 100 | This subcommand can be used as a partial substitute for `dig +short`; 101 | extending the functionality is planned. 102 | 103 | ### tdns update 104 | 105 | A dynamic DNS updater and update checker, using the mechanism 106 | described in RFC 2136. 107 | 108 | `tdns update` updates and/or monitors an entry in a DNS zone. The 109 | updating functionality is currently a limited subset of what the 110 | `nsupdate` utility from the ISC BIND provides, but providing both 111 | updates and monitoring in a single native executable is novel, at 112 | least to the author's knowledge. There are doubtlessly numerous shell 113 | scripts around that provide similar functionality, with varying 114 | degrees of sophistication. `tdns update` aims to its job correctly and 115 | efficiently, taking no shortcuts. 116 | 117 | With a single `tnds update` invocation, you can both perform a DNS 118 | update operation, and wait for all the authoritative nameservers in 119 | the zone to provide the updated records. 120 | 121 | #### Missing features 122 | 123 | Without those, `tdns update` cannot function reliably, or can be 124 | considered not doing the job properly: 125 | 126 | - [ ] If no `--resolver` option is provided, make use of all the 127 | resolvers specified in `/etc/resolv.conf`, not just the first 128 | one. 129 | - [ ] Probe all addresses an `NS` entry resolves to. 130 | - [ ] IPv6 support; the code is largely agnostic of IP address family, 131 | but IPv6 support has not yet been actively worked on. 132 | 133 | #### Planned features 134 | 135 | - [ ] To become a full replacement for `nsupdate`, a more elaborate 136 | way for describing the update, similar to the `nsupdate` 137 | "scripts" is needed; adapting the command-line interface is not 138 | suitable for more complex update operations. 139 | - [ ] Once a mechanism for describing an update in some kind of DSL is 140 | added, it should be quite easy to allow updating multiple zones 141 | concurrently in a single run. This functionality is probably not 142 | that useful in practice, but who knows... 143 | - [ ] Increase the test coverage of the test suite; the infrastructure 144 | and some basic tests are present, but coverage is quite limited 145 | currently. 146 | 147 | #### Example use case 148 | 149 | This is the scenario which prompted the development of `tdns update`. 150 | 151 | When obtaining TLS certificates from letsencrypt using the [DNS-01 152 | protocol], it is necessary to ensure that letsencrypt is only told to 153 | verify the challenge after it can be reliably retrieved. With 154 | secondary DNS servers, it can take a while until the update is 155 | completely rolled out to all of them. `tdns update` can be used as 156 | part of the hook script to deploy the letsencrypt challenge to DNS. 157 | 158 | ## License 159 | 160 | Copyright © 2019 Andreas Rottmann 161 | 162 | This program is free software; you can redistribute it and/or modify 163 | it under the terms of the GNU General Public License as published by 164 | the Free Software Foundation; either version 3 of the License, or (at 165 | your option) any later version. 166 | 167 | This program is distributed in the hope that it will be useful, but 168 | *WITHOUT ANY WARRANTY*; without even the implied warranty of 169 | *MERCHANTABILITY* or *FITNESS FOR A PARTICULAR PURPOSE*. See the GNU 170 | General Public License for more details. 171 | 172 | You should have received a copy of the GNU General Public License 173 | along with this program; if not, see . 174 | 175 | ### Additional permission under GNU GPL version 3 section 7 176 | 177 | If you modify this Program, or any covered work, by linking or 178 | combining it with OpenSSL (or a modified version of that library), 179 | containing parts covered by the terms of OpenSSL License, the 180 | licensors of this Program grant you additional permission to convey 181 | the resulting work. Corresponding Source for a non-source form of such 182 | a combination shall include the source code for the parts of OpenSSL 183 | used as well as that of the covered work. 184 | 185 | ## Contributions 186 | 187 | Unless explicitly indicated otherwise, any contribution intentionally 188 | submitted for inclusion in this crate: 189 | 190 | - Will be licensed under the GNU GPL version 3.0, or 191 | later, with the additional permissions listed above. 192 | - The contributor additionally grants the crate maintainer the right 193 | to re-license parts or all of the crate's code, including the 194 | contribution, to the dual MIT/Apache-2.0 license. This is provision 195 | is for the case that some part of the crate's code turns out to be 196 | of general utility, such that it would benefit from being split out 197 | and being given a more liberal, non-copyleft license. 198 | 199 | [Rust toolchain]: https://www.rust-lang.org/tools/install 200 | [`trust-dns`]: https://github.com/bluejekyll/trust-dns 201 | [DNS-01 protocol]: https://letsencrypt.org/docs/challenge-types/ 202 | [pandoc]: https://pandoc.org/ 203 | [crates.io]: https://crates.io 204 | -------------------------------------------------------------------------------- /tdns-update.1.md: -------------------------------------------------------------------------------- 1 | % TDNS-UPDATE(1) tnds-update Manual 2 | % Andreas Rottmann 3 | % October, 2019 4 | 5 | # NAME 6 | 7 | tnds-update - DNS update client (RFC 2136) 8 | 9 | # SYNOPSIS 10 | 11 | __tdns update__ [*options*] *dns-name* *rs-data* 12 | 13 | # DESCRIPTION 14 | 15 | __tdns update__ is an alternative to the `nsupdate` utility which is 16 | distributed as part of the ISC BIND suite. It is currently not as 17 | general as `nsupdate`, but provides the additional feature of 18 | (optionally) ensuring that the DNS update has propagated to all 19 | authoritative nameservers of a domain. This feature is helpful when 20 | implementing challenge-response protocols such as the DNS-01 variant 21 | of the letsencrypt ACME protocol, as it ensures that when 22 | __tdns update__ exits successfully, any subsequent query to any of the 23 | authoritative nameservers will see the updated records. 24 | 25 | Furthermore, __tnds update__ provides a command-line interface that 26 | intends to cover all basic use-cases, like creating, deleting and 27 | updating a DNS resource record set, while __nsupdate__ requires a 28 | simple "script". This should make using __tdns update__ a bit more 29 | straightforward for these basic use-cases, compared to constructing a 30 | script on the fly and piping it into __nsupdate__. 31 | 32 | # OPTIONS 33 | 34 | ## Mode of operation 35 | 36 | __tdns update__ allows combining a nameserver update (__\--create__, 37 | __\--delete__) with optional monitoring, i.e. waiting for the specified 38 | update to happen. If no update action is specified, monitoring will 39 | still happen, unless turned off with __\--no-wait__. 40 | 41 | \--no-op 42 | : Does not perform an update, but still monitors the zone's 43 | nameservers for the given data to appear. This is the default if no 44 | action is specified. If __\--no-op__ is combined with __\--no-wait__, 45 | __tdns update__ will behave like a heavyweight implementation of the 46 | classic `true`(1) command. 47 | 48 | \--create 49 | : Creates *dns-name*, with the contents given by 50 | *rs-data*. *Prerequisite*: No RRset for the name of the type 51 | specified by *rs-data* may already exist. 52 | 53 | \--append 54 | : Adds the records implied by *dns-name* and *rs-data* to the zone. 55 | 56 | \--delete 57 | : Deletes records matching the given *dns-name* and *rs-data* 58 | arguments. Note that without *rs-data* argument, all records 59 | matching *dns-name* will be deleted. To delete all records of a 60 | specific type, a bare type may be used as *rs-data* argument. 61 | 62 | \--no-wait 63 | : Per default, __tdns update__ will monitor the authoritative 64 | nameservers of the updated zone and wait until the update is visible 65 | on all of them. With this option, __tnds-update__ terminates 66 | immediately after the update operation, not performing any 67 | monitoring. 68 | 69 | ## Tunables 70 | 71 | \--zone=*zone* 72 | : Specify the DNS zone to update; the zone's SOA record will be used 73 | to determine the primary master, unless __\--server__ is used. If not 74 | given, the zone is derived from *dns-name* by stripping the initial 75 | label; e.g. for `foo.example.org`, the derived zone will be 76 | `example.org`. 77 | 78 | \--server=*server* 79 | : Primary master to send updates to; if not specified, it will be 80 | determined from the SOA record of the updated zone. The given 81 | *server* may either be an IP address or a hostname, optionally 82 | including a port. 83 | 84 | \--resolver=*address* 85 | : Resolver to use for recursive queries. If not specified, the 86 | resolver name will be determined based on the contents of 87 | `/etc/resolv.conf`, using the first `nameserver` entry given 88 | therein. 89 | 90 | \--ttl=*seconds* 91 | : Set the TTL, in seconds, for any records created due to an 92 | update. If not specified, a default of 3600 (i.e., one hour) is 93 | used. 94 | 95 | \--key=*name:algorithm:base64-secret*, \--key=*name* 96 | : Use the specified secret to sign the update request with TSIG 97 | signature. TSIG allows the server to validate the update request 98 | using a shared secret. The components of a full key specification 99 | are as follows: 100 | 101 | - *name* is the key name, which must match between server and 102 | client. It needs to conform to DNS name syntax. 103 | - *algorithm* is the name of the HMAC algorithm used for 104 | signatures. The following algorithms are supported: `hmac-sha224`, 105 | `hmac-sha256`, `hmac-sha384`, `hmac-sha512`. Older algorithms 106 | relying on SHA1 or MD5 hashes have been intentionally left out. 107 | - *base64-secret* is the shared secret in base64-encoded form. 108 | 109 | Note that using a full key specification is *not* recommended for 110 | production use, as the secret may leak via the process table and 111 | shell history. Use __\--key-file__ instead, and consider tightening 112 | the permissions on the key file as appropriate. The second __\--key__ 113 | form, where only *name* is given can be used to select a key from a 114 | key file containing multiple keys. 115 | 116 | \--key-file=*file* 117 | : Read the TSIG key from a file. The file must contain lines which 118 | each in the same format as the argument to the __\--key__ option, 119 | i.e. *name:algorithm:base64-secret*. If __\--key-file__ is used 120 | without __\--key__, the first key in the file will be used, but it 121 | may also be combined with the name-only form of __\--key__, in which 122 | case the *algorithm* and *base64-secret* will be taken from the 123 | file, and the key name will be used to to select the appropriate 124 | line from the file. 125 | 126 | \--exclude=*address* 127 | : Exclude *address*, which must be an IPv4 or IPv6 address from 128 | monitoring. If an `NS` record resolves to this IP address, it is not 129 | monitored. This is useful for excluding the primary master, i.e., 130 | the server the update requests are sent to from monitoring, for 131 | example if it is not reachable via its public IP address from the 132 | machine __tdns update__ is run on. 133 | 134 | \--tcp 135 | : Use TCP for all DNS requests. 136 | 137 | \--verbose 138 | : Increase verbosity. If enabled, __tdns update__ will print 139 | informational messages during execution. 140 | 141 | # RECORD SET SYNTAX 142 | 143 | A resource record set (RRset), as specified by RFC 2136, is a set of 144 | DNS resource records (RRs) that have the same name, class, and 145 | type. For instance, all `A` records for the DNS name `foo.example.org` 146 | form an RRset. In today's use of DNS, only class `IN` is in common 147 | use, so only that class is currently supported by __tdns update__. 148 | 149 | __tdns update__ is currently restricted to a single RRset, with a 150 | specific type and name. The RRset data, including the RRset type, is 151 | given via the *rs-data* arguments. The general syntax for *rs-data* is 152 | uniform, although the syntax of the data portion is type-dependent; 153 | for instance `AAAA` RRsets require all data items to be valid IPv6 154 | addresses. 155 | 156 | The *rs-data* argument is written as its type, a colon, and a data 157 | item for each record. The data items are separated by commas. For 158 | example, `A:192.168.1.1,10.0.0.1` denotes an RRset of type `A`, with 159 | the given two IPv4 addresses. 160 | 161 | The following types of RRsets are supported: 162 | 163 | `A` 164 | : Each data item must be an IPv4 address. 165 | 166 | `AAAA` 167 | : Each data item must be an IPv6 address. 168 | 169 | `TXT` 170 | : Each data item must be valid UTF-8 string. 171 | 172 | # EXAMPLES 173 | 174 | The following will update `foo.example.org` with an IPv4 and IPv6 175 | address, deleting the old entries first: 176 | 177 | tdns update --delete --no-wait foo.example.org A 178 | tdns update --create foo.example.org A:10.1.2.3 179 | tnds-update --append foo.example.org AAAA:dead:beef::1234 180 | 181 | # BUGS 182 | 183 | - The set of supported record types is quite small; other commonly 184 | used record types, such as `CNAME`, `PTR`, `MX` and `NS` are going 185 | to be added at the author's whim, or due to contributions. 186 | 187 | - The notation for `TXT` record data is excessively restrictive 188 | compared to what is allowed according to RFC 1464: 189 | 190 | - Only a single data item may be specified per record. 191 | - There is no support for quoting, so items containing commas (the 192 | item separator) cannot be represented. 193 | 194 | A future version of __tdns update__ should lift these restrictions. 195 | 196 | - __tdns update__ currently can only handle a small class of updates 197 | that are possible via __nsupdate__ scripts; it is planned to extend 198 | the command line interface to support more common operations, such 199 | as deleting the RRsets before creating them anew. 200 | 201 | Another possible future direction is to implement taking update 202 | instructions from a file, akin to nsupdate scripts, allowing for 203 | capabilities like: 204 | 205 | - Update multiple DNS entries for a zone in a single update query. 206 | - Update and monitor multiple zones in a single invocation, which is 207 | a feature beyond __nsupdate__'s current capabilities. 208 | -------------------------------------------------------------------------------- /src/tsig.rs: -------------------------------------------------------------------------------- 1 | /// An implementation of RFC 2845 for `trust-dns`. 2 | use std::{ 3 | convert::{TryFrom, TryInto}, 4 | fmt, 5 | time::{SystemTime, SystemTimeError}, 6 | }; 7 | 8 | use digest::KeyInit; 9 | use hmac::{Hmac, Mac}; 10 | use once_cell::sync::Lazy; 11 | use trust_dns_client::{ 12 | op, 13 | proto::error::{ProtoError, ProtoResult}, 14 | rr, 15 | serialize::binary::{BinEncodable, BinEncoder}, 16 | }; 17 | 18 | #[derive(Debug)] 19 | pub enum Error { 20 | Proto(ProtoError), 21 | InvalidKeyLength(digest::InvalidLength), 22 | SystemTime(SystemTimeError), 23 | } 24 | 25 | impl fmt::Display for Error { 26 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 27 | match self { 28 | Error::Proto(e) => write!(f, "{}", e), 29 | Error::InvalidKeyLength(e) => write!(f, "{}", e), 30 | Error::SystemTime(e) => write!(f, "{}", e), 31 | } 32 | } 33 | } 34 | 35 | impl std::error::Error for Error {} 36 | 37 | impl From for Error { 38 | fn from(e: ProtoError) -> Self { 39 | Error::Proto(e) 40 | } 41 | } 42 | 43 | impl From for Error { 44 | fn from(e: digest::InvalidLength) -> Self { 45 | Error::InvalidKeyLength(e) 46 | } 47 | } 48 | 49 | impl From for Error { 50 | fn from(e: SystemTimeError) -> Self { 51 | Error::SystemTime(e) 52 | } 53 | } 54 | 55 | #[derive(Debug, Copy, Clone)] 56 | pub enum Algorithm { 57 | HmacSha224, 58 | HmacSha256, 59 | HmacSha384, 60 | HmacSha512, 61 | } 62 | 63 | struct AlgoNames { 64 | sha224: rr::Name, 65 | sha256: rr::Name, 66 | sha384: rr::Name, 67 | sha512: rr::Name, 68 | } 69 | 70 | static ALGO_NAMES: Lazy = Lazy::new(|| AlgoNames { 71 | // All SHA2-based algorithms are defined in RFC 4635 72 | sha224: rr::Name::from_ascii("hmac-sha224").unwrap(), 73 | sha256: rr::Name::from_ascii("hmac-sha256").unwrap(), 74 | sha384: rr::Name::from_ascii("hmac-sha384").unwrap(), 75 | sha512: rr::Name::from_ascii("hmac-sha512").unwrap(), 76 | }); 77 | 78 | impl Algorithm { 79 | pub fn as_name(self) -> &'static rr::Name { 80 | let names = Lazy::force(&ALGO_NAMES); 81 | use Algorithm::*; 82 | match self { 83 | HmacSha224 => &names.sha224, 84 | HmacSha256 => &names.sha256, 85 | HmacSha384 => &names.sha384, 86 | HmacSha512 => &names.sha512, 87 | } 88 | } 89 | pub fn from_name(name: &rr::Name) -> Result { 90 | let names = Lazy::force(&ALGO_NAMES); 91 | use Algorithm::*; 92 | for (algo_name, algo) in &[ 93 | (&names.sha224, HmacSha224), 94 | (&names.sha256, HmacSha256), 95 | (&names.sha384, HmacSha384), 96 | (&names.sha512, HmacSha512), 97 | ] { 98 | if name == *algo_name { 99 | return Ok(*algo); 100 | } 101 | } 102 | Err(UnknownAlgorithm) 103 | } 104 | } 105 | 106 | #[derive(Debug)] 107 | pub struct UnknownAlgorithm; 108 | 109 | impl fmt::Display for UnknownAlgorithm { 110 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 111 | write!(f, "unknown algorithm") 112 | } 113 | } 114 | 115 | impl std::error::Error for UnknownAlgorithm {} 116 | 117 | #[derive(Debug, Clone)] 118 | pub struct Key { 119 | name: rr::Name, 120 | algorithm: Algorithm, 121 | secret: Vec, 122 | } 123 | 124 | impl Key { 125 | pub fn new(name: rr::Name, algorithm: Algorithm, secret: T) -> Self 126 | where 127 | T: Into>, 128 | { 129 | Key { 130 | name, 131 | algorithm, 132 | secret: secret.into(), 133 | } 134 | } 135 | } 136 | 137 | pub fn add_signature(msg: &mut op::Message, key: &Key) -> Result<(), Error> { 138 | let unix_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?; 139 | let record = create_signature(msg, unix_time.as_secs(), key)?; 140 | msg.add_additional(record); 141 | Ok(()) 142 | } 143 | 144 | fn create_signature(msg: &op::Message, time_signed: u64, key: &Key) -> Result { 145 | use Algorithm::*; 146 | let tsig = match key.algorithm { 147 | HmacSha224 => create_tsig::>(msg, time_signed, key)?, 148 | HmacSha256 => create_tsig::>(msg, time_signed, key)?, 149 | HmacSha384 => create_tsig::>(msg, time_signed, key)?, 150 | HmacSha512 => create_tsig::>(msg, time_signed, key)?, 151 | }; 152 | let mut record = rr::Record::from_rdata(key.name.clone(), 0, tsig.try_into()?); 153 | record.set_dns_class(rr::DNSClass::ANY); 154 | Ok(record) 155 | } 156 | 157 | #[allow(clippy::upper_case_acronyms)] 158 | #[derive(Debug)] 159 | struct TSIG { 160 | algorithm_name: rr::Name, 161 | time_signed: u64, // This is a actually a 48-bit value 162 | fudge: u16, 163 | mac: Vec, 164 | original_id: u16, 165 | error: op::ResponseCode, 166 | other_data: Vec, 167 | } 168 | 169 | impl TSIG { 170 | fn new( 171 | algorithm_name: rr::Name, 172 | time_signed: u64, // This is a actually a 48-bit value 173 | fudge: u16, 174 | mac: Vec, 175 | original_id: u16, 176 | error: op::ResponseCode, 177 | other_data: Vec, 178 | ) -> Self { 179 | assert!(other_data.len() <= usize::from(u16::MAX)); 180 | TSIG { 181 | algorithm_name, 182 | time_signed, 183 | fudge, 184 | mac, 185 | original_id, 186 | error, 187 | other_data, 188 | } 189 | } 190 | } 191 | 192 | impl TryFrom for rr::RData { 193 | type Error = Error; 194 | 195 | fn try_from(tsig: TSIG) -> Result { 196 | let mut encoded = Vec::new(); 197 | let mut encoder = BinEncoder::new(&mut encoded); 198 | encoder.set_canonical_names(true); 199 | tsig.emit(&mut encoder)?; 200 | Ok(rr::RData::Unknown { 201 | code: 250, 202 | rdata: rr::rdata::null::NULL::with(encoded), 203 | }) 204 | } 205 | } 206 | 207 | impl BinEncodable for TSIG { 208 | fn emit(&self, encoder: &mut BinEncoder) -> ProtoResult<()> { 209 | self.algorithm_name.emit(encoder)?; 210 | emit_u48(encoder, self.time_signed)?; 211 | encoder.emit_u16(self.fudge)?; 212 | encoder.emit_u16(self.mac.len() as u16)?; 213 | encoder.emit_vec(&self.mac)?; 214 | encoder.emit_u16(self.original_id)?; 215 | encoder.emit_u16(self.error.into())?; 216 | encoder.emit_u16( 217 | self.other_data 218 | .len() 219 | .try_into() 220 | .expect("other data too long"), 221 | )?; 222 | encoder.emit_vec(&self.other_data)?; 223 | Ok(()) 224 | } 225 | } 226 | 227 | fn emit_u48(encoder: &mut BinEncoder, n: u64) -> ProtoResult<()> { 228 | encoder.emit_u16((n >> 32) as u16)?; 229 | encoder.emit_u32(n as u32)?; 230 | Ok(()) 231 | } 232 | 233 | fn create_tsig( 234 | msg: &op::Message, 235 | time_signed: u64, 236 | key: &Key, 237 | ) -> Result { 238 | let mut encoded = Vec::new(); // TODO: initial capacity? 239 | let mut encoder = BinEncoder::new(&mut encoded); 240 | let fudge = 300; // FIXME: fudge hardcoded 241 | // See RFC 2845, section 3.4. The "whole and complete message" in wire 242 | // format, before adding the TSIG RR. 243 | msg.emit(&mut encoder)?; 244 | // 3.4.2. TSIG Variables 245 | // 246 | // Source Field Name Notes 247 | // ----------------------------------------------------------------------- 248 | // TSIG RR NAME Key name, in canonical wire format 249 | // TSIG RR CLASS (Always ANY in the current specification) 250 | // TSIG RR TTL (Always 0 in the current specification) 251 | // TSIG RDATA Algorithm Name in canonical wire format 252 | // TSIG RDATA Time Signed in network byte order 253 | // TSIG RDATA Fudge in network byte order 254 | // TSIG RDATA Error in network byte order 255 | // TSIG RDATA Other Len in network byte order 256 | // TSIG RDATA Other Data exactly as transmitted 257 | encoder.set_canonical_names(true); 258 | key.name.emit(&mut encoder)?; 259 | rr::DNSClass::ANY.emit(&mut encoder)?; 260 | encoder.emit_u32(0)?; // TTL 261 | key.algorithm.as_name().emit(&mut encoder)?; 262 | emit_u48(&mut encoder, time_signed)?; 263 | encoder.emit_u16(fudge)?; 264 | let rcode = op::ResponseCode::NoError; 265 | encoder.emit_u16(rcode.into())?; 266 | encoder.emit_u16(0)?; // Other data is of length 0 267 | let hmac = { 268 | let mut mac = ::new_from_slice(&key.secret)?; 269 | mac.update(&encoded); 270 | mac.finalize().into_bytes().to_vec() 271 | }; 272 | Ok(TSIG::new( 273 | key.algorithm.as_name().clone(), 274 | time_signed, 275 | fudge, 276 | hmac, 277 | msg.id(), 278 | rcode, 279 | Vec::new(), 280 | )) 281 | } 282 | -------------------------------------------------------------------------------- /src/update.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | convert::TryFrom, 3 | fmt, 4 | net::{IpAddr, SocketAddr}, 5 | rc::Rc, 6 | time::Duration, 7 | }; 8 | 9 | use anyhow::anyhow; 10 | use futures::stream::{FuturesUnordered, TryStreamExt}; 11 | use tokio::time::{sleep, timeout}; 12 | use trust_dns_client::{ 13 | op::{Message, Query}, 14 | proto::xfer::{DnsHandle, DnsRequestOptions}, 15 | rr, 16 | }; 17 | 18 | use crate::{ 19 | record::{RecordSet, RsData}, 20 | tsig, update_message, 21 | util::{self, SocketName}, 22 | Backend, Resolver, Runtime, 23 | }; 24 | 25 | #[derive(Debug, Clone)] 26 | pub struct Update { 27 | pub zone: rr::Name, 28 | pub server: Option, 29 | pub operation: Operation, 30 | pub tsig_key: Option, 31 | pub ttl: u32, 32 | } 33 | 34 | impl Update { 35 | pub fn get_update(&self) -> Result { 36 | let ttl = self.ttl; 37 | let mut message = match &self.operation { 38 | Operation::Create(rset) => { 39 | update_message::create(rset.to_rrset(ttl), self.zone.clone()) 40 | } 41 | Operation::Append(rset) => { 42 | update_message::append(rset.to_rrset(ttl), self.zone.clone(), false) 43 | } 44 | Operation::Delete(rset) => { 45 | if rset.is_empty() { 46 | let record = rr::Record::with(rset.name().clone(), rset.record_type(), ttl); 47 | update_message::delete_rrset(record, self.zone.clone()) 48 | } else { 49 | update_message::delete_by_rdata(rset.to_rrset(ttl), self.zone.clone()) 50 | } 51 | } 52 | Operation::DeleteAll(name) => { 53 | update_message::delete_all(name.clone(), self.zone.clone(), rr::DNSClass::IN) 54 | } 55 | }; 56 | if let Some(key) = &self.tsig_key { 57 | tsig::add_signature(&mut message, key)?; 58 | } 59 | Ok(message) 60 | } 61 | } 62 | 63 | #[derive(Debug, Clone)] 64 | pub struct Monitor { 65 | pub zone: rr::Name, 66 | pub entry: rr::Name, 67 | pub interval: Duration, 68 | pub timeout: Duration, 69 | pub verbose: bool, 70 | pub exclude: Vec, 71 | pub expectation: Expectation, 72 | } 73 | 74 | impl Monitor { 75 | fn get_query(&self) -> Query { 76 | Query::query(self.entry.clone(), self.expectation.record_type()) 77 | } 78 | } 79 | 80 | #[derive(Debug, Clone, Eq, PartialEq)] 81 | pub enum Operation { 82 | Create(RecordSet), 83 | Append(RecordSet), 84 | Delete(RecordSet), 85 | DeleteAll(rr::Name), 86 | } 87 | 88 | impl Operation { 89 | pub fn create(name: rr::Name, data: RsData) -> Self { 90 | Operation::Create(RecordSet::new(name, data)) 91 | } 92 | 93 | pub fn delete(name: rr::Name, data: RsData) -> Self { 94 | Operation::Delete(RecordSet::new(name, data)) 95 | } 96 | } 97 | 98 | #[derive(Debug, Clone)] 99 | pub enum Expectation { 100 | Is(RecordSet), 101 | Contains(RecordSet), 102 | Empty(rr::RecordType), 103 | NotAny(RecordSet), 104 | } 105 | 106 | impl Expectation { 107 | pub fn record_type(&self) -> rr::RecordType { 108 | match self { 109 | Expectation::Is(rset) => rset.record_type(), 110 | Expectation::Contains(rset) => rset.record_type(), 111 | Expectation::NotAny(rset) => rset.record_type(), 112 | Expectation::Empty(rtype) => *rtype, 113 | } 114 | } 115 | 116 | pub fn satisfied_by(&self, rrs: &[rr::Record]) -> bool { 117 | match self { 118 | Expectation::Is(other) => { 119 | let rset = match RecordSet::try_from(rrs) { 120 | Err(_) => return false, 121 | Ok(rs) => rs, 122 | }; 123 | rset == *other 124 | } 125 | Expectation::Contains(other) => { 126 | let rset = match RecordSet::try_from(rrs) { 127 | Err(_) => return false, 128 | Ok(rs) => rs, 129 | }; 130 | other.is_subset(&rset) 131 | } 132 | Expectation::Empty(_) => rrs.is_empty(), 133 | Expectation::NotAny(other) => { 134 | if rrs.is_empty() { 135 | return true; 136 | } 137 | let rset = match RecordSet::try_from(rrs) { 138 | Err(_) => return false, 139 | Ok(rs) => rs, 140 | }; 141 | !other.iter_data().any(|r| rset.contains(&r)) 142 | } 143 | } 144 | } 145 | } 146 | 147 | impl fmt::Display for Expectation { 148 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 149 | match self { 150 | Expectation::Is(rset) => write!(f, "expected {}", rset.data()), 151 | Expectation::Contains(rset) => write!(f, "expected at least {} records", rset.data()), 152 | Expectation::Empty(rtype) => write!(f, "expected no {} records", rtype), 153 | Expectation::NotAny(rset) => write!(f, "expected none of {}", rset), 154 | } 155 | } 156 | } 157 | 158 | pub async fn perform_update( 159 | runtime: &Runtime, 160 | mut dns: D, 161 | resolver: D::Resolver, 162 | options: Update, 163 | ) -> anyhow::Result<()> 164 | where 165 | D: Backend, 166 | D::Resolver: 'static, 167 | { 168 | let message = options.get_update()?; 169 | let master = if let Some(sockname) = options.server { 170 | sockname.resolve(resolver, 53).await? 171 | } else if let Some(soa) = resolver 172 | .lookup_soa(options.zone.clone()) 173 | .await? 174 | .iter() 175 | .next() 176 | { 177 | util::SocketName::HostName(soa.mname().clone(), None) 178 | .resolve(resolver, 53) 179 | .await? 180 | } else { 181 | return Err(anyhow!("SOA record for {} not found", options.zone)); 182 | }; 183 | let mut server = dns.open(runtime, master).await?; 184 | // TODO: probably should check response 185 | server.send(message).await?; 186 | Ok(()) 187 | } 188 | 189 | pub async fn monitor_update( 190 | runtime: &Runtime, 191 | dns: D, 192 | resolver: D::Resolver, 193 | options: Monitor, 194 | ) -> anyhow::Result<()> 195 | where 196 | D: Backend, 197 | { 198 | let options = Rc::new(options); 199 | let authorative = resolver.lookup_ns(options.zone.clone()).await?; 200 | match timeout( 201 | options.timeout, 202 | poll_for_update(runtime, dns, resolver, authorative, Rc::clone(&options)), 203 | ) 204 | .await? 205 | { 206 | Ok(_) => Ok(()), 207 | Err(_) => Err(anyhow!( 208 | "timeout; update not complete within {}ms", 209 | options.timeout.as_millis() 210 | )), 211 | } 212 | } 213 | 214 | async fn poll_for_update( 215 | runtime: &Runtime, 216 | dns: D, 217 | resolver: D::Resolver, 218 | authorative: I, 219 | options: Rc, 220 | ) -> anyhow::Result<()> 221 | where 222 | I: IntoIterator, 223 | D: Backend, 224 | { 225 | let results: FuturesUnordered<_> = authorative 226 | .into_iter() 227 | .map(move |server_name| { 228 | poll_server( 229 | runtime, 230 | dns.clone(), 231 | resolver.clone(), 232 | server_name, 233 | Rc::clone(&options), 234 | ) 235 | }) 236 | .collect(); 237 | results.try_collect().await?; 238 | Ok(()) 239 | } 240 | 241 | async fn poll_server( 242 | runtime: &Runtime, 243 | mut dns: D, 244 | resolver: D::Resolver, 245 | server_name: rr::Name, 246 | options: Rc, 247 | ) -> anyhow::Result<()> 248 | where 249 | D: Backend, 250 | { 251 | let ip = resolver 252 | .lookup_ip(server_name.clone()) 253 | .await? 254 | .iter() 255 | .next() 256 | .ok_or_else(|| anyhow!("could not resolve {}", &server_name))?; 257 | if options.exclude.contains(&ip) { 258 | return Ok(()); 259 | } 260 | let mut server = dns.open(runtime, SocketAddr::new(ip, 53)).await?; 261 | let server_name = server_name.clone(); 262 | let options = Rc::clone(&options); 263 | let query = options.get_query(); 264 | loop { 265 | if let Ok(response) = server 266 | .lookup(query.clone(), DnsRequestOptions::default()) 267 | .await 268 | { 269 | let answers = response.answers(); 270 | let hit = options.expectation.satisfied_by(answers); 271 | if options.verbose { 272 | if hit { 273 | println!("{}: match found", &server_name); 274 | } else { 275 | let rset = match RecordSet::try_from(answers) { 276 | Ok(rs) => format!("{}", rs.data()), 277 | Err(e) => format!("{}", e), 278 | }; 279 | println!( 280 | "{}: records not matching: {}, found {}", 281 | server_name, options.expectation, rset, 282 | ); 283 | } 284 | } 285 | if hit { 286 | return Ok(()); 287 | } else { 288 | sleep(options.interval).await; 289 | } 290 | } 291 | } 292 | } 293 | -------------------------------------------------------------------------------- /src/record.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | collections::{btree_set, BTreeSet}, 3 | convert::TryFrom, 4 | fmt, 5 | net::{self, Ipv4Addr, Ipv6Addr}, 6 | str::{self, FromStr}, 7 | string::FromUtf8Error, 8 | }; 9 | 10 | use trust_dns_client::rr::{self, rdata}; 11 | 12 | /// This is a representation of the record set as described in RFC 2136. 13 | /// 14 | /// A domain name identifies a node within the domain name space tree structure. 15 | /// Each node has a set (possibly empty) of Resource Records (RRs). All RRs 16 | /// having the same NAME, CLASS and TYPE are called a Resource Record Set (RRset 17 | #[derive(Debug, Clone, Eq, PartialEq)] 18 | pub struct RecordSet { 19 | name: rr::Name, 20 | dns_class: rr::DNSClass, 21 | data: RsData, 22 | } 23 | 24 | impl RecordSet { 25 | pub fn new(name: rr::Name, data: RsData) -> Self { 26 | RecordSet { 27 | name, 28 | dns_class: rr::DNSClass::IN, 29 | data, 30 | } 31 | } 32 | 33 | pub fn name(&self) -> &rr::Name { 34 | &self.name 35 | } 36 | 37 | pub fn dns_class(&self) -> rr::DNSClass { 38 | self.dns_class 39 | } 40 | 41 | pub fn record_type(&self) -> rr::RecordType { 42 | self.data.record_type() 43 | } 44 | 45 | pub fn to_rrset(&self, ttl: u32) -> rr::RecordSet { 46 | let mut rrset = rr::RecordSet::with_ttl(self.name.clone(), self.record_type(), ttl); 47 | for data in self.iter_data() { 48 | rrset.add_rdata(data); 49 | } 50 | rrset 51 | } 52 | 53 | pub fn data(&self) -> &RsData { 54 | &self.data 55 | } 56 | 57 | pub fn iter_data(&self) -> RsDataIter { 58 | let inner = match &self.data { 59 | RsData::TXT(txts) => RsDataIterInner::TXT(txts.iter()), 60 | RsData::A(addrs) => RsDataIterInner::A(addrs.iter()), 61 | RsData::AAAA(addrs) => RsDataIterInner::AAAA(addrs.iter()), 62 | }; 63 | RsDataIter(inner) 64 | } 65 | 66 | pub fn contains(&self, entry: &rr::RData) -> bool { 67 | match (&self.data, entry) { 68 | (RsData::TXT(txts), rr::RData::TXT(txt)) => { 69 | if let Ok(txt) = txt_string(txt) { 70 | txts.contains(&txt) 71 | } else { 72 | false 73 | } 74 | } 75 | (RsData::A(addrs), rr::RData::A(addr)) => addrs.contains(addr), 76 | (RsData::AAAA(addrs), rr::RData::AAAA(addr)) => addrs.contains(addr), 77 | _ => false, 78 | } 79 | } 80 | 81 | pub fn is_empty(&self) -> bool { 82 | match &self.data { 83 | RsData::TXT(txts) => txts.is_empty(), 84 | RsData::A(addrs) => addrs.is_empty(), 85 | RsData::AAAA(addrs) => addrs.is_empty(), 86 | } 87 | } 88 | 89 | pub fn is_subset(&self, other: &RecordSet) -> bool { 90 | use RsData::*; 91 | if self.name() != other.name() { 92 | return false; 93 | } 94 | match (&self.data, &other.data) { 95 | (TXT(txts), TXT(other_txts)) => txts.is_subset(other_txts), 96 | (A(addrs), A(other_addrs)) => addrs.is_subset(other_addrs), 97 | (AAAA(addrs), AAAA(other_addrs)) => addrs.is_subset(other_addrs), 98 | _ => false, 99 | } 100 | } 101 | } 102 | 103 | impl fmt::Display for RecordSet { 104 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 105 | write!(f, "{} ({})", self.name, self.data) 106 | } 107 | } 108 | 109 | #[derive(Debug)] 110 | pub struct RsDataIter<'a>(RsDataIterInner<'a>); 111 | 112 | impl<'a> Iterator for RsDataIter<'a> { 113 | type Item = rr::RData; 114 | 115 | fn next(&mut self) -> Option { 116 | use RsDataIterInner::*; 117 | match &mut self.0 { 118 | A(iter) => iter.next().map(|item| rr::RData::A(*item)), 119 | AAAA(iter) => iter.next().map(|item| rr::RData::AAAA(*item)), 120 | TXT(iter) => iter 121 | .next() 122 | .map(|item| rr::RData::TXT(rdata::TXT::new(vec![item.into()]))), 123 | } 124 | } 125 | } 126 | 127 | #[allow(clippy::upper_case_acronyms)] 128 | #[derive(Debug)] 129 | enum RsDataIterInner<'a> { 130 | TXT(btree_set::Iter<'a, String>), 131 | A(btree_set::Iter<'a, Ipv4Addr>), 132 | AAAA(btree_set::Iter<'a, Ipv6Addr>), 133 | } 134 | 135 | #[derive(Debug, Clone, Hash, Eq, PartialEq)] 136 | pub enum RsData { 137 | TXT(BTreeSet), // TODO: simplified, only single value for now. 138 | A(BTreeSet), 139 | AAAA(BTreeSet), 140 | } 141 | 142 | impl RsData { 143 | pub fn record_type(&self) -> rr::RecordType { 144 | match self { 145 | RsData::TXT(_) => rr::RecordType::TXT, 146 | RsData::A(_) => rr::RecordType::A, 147 | RsData::AAAA(_) => rr::RecordType::AAAA, 148 | } 149 | } 150 | } 151 | 152 | impl fmt::Display for RsData { 153 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 154 | // FIXME: DRY 155 | match self { 156 | RsData::A(addrs) => { 157 | write!(f, "A:")?; 158 | for (i, addr) in addrs.iter().enumerate() { 159 | if i > 0 { 160 | write!(f, ",")?; 161 | } 162 | write!(f, "{}", addr)?; 163 | } 164 | } 165 | RsData::AAAA(addrs) => { 166 | write!(f, "A:")?; 167 | for (i, addr) in addrs.iter().enumerate() { 168 | if i > 0 { 169 | write!(f, ",")?; 170 | } 171 | write!(f, "{}", addr)?; 172 | } 173 | } 174 | RsData::TXT(txts) => { 175 | write!(f, "TXT:")?; 176 | for (i, txt) in txts.iter().enumerate() { 177 | if i > 0 { 178 | write!(f, ",")?; 179 | } 180 | write!(f, "{}", txt)?; 181 | } 182 | } 183 | } 184 | Ok(()) 185 | } 186 | } 187 | 188 | impl FromStr for RsData { 189 | type Err = RsDataParseError; 190 | 191 | fn from_str(s: &str) -> Result { 192 | let parts: Vec<_> = s.splitn(2, ':').collect(); 193 | if parts.len() == 1 { 194 | return match parts[0].to_uppercase().as_str() { 195 | "TXT" => Ok(RsData::TXT(Default::default())), 196 | "A" => Ok(RsData::A(Default::default())), 197 | "AAAA" => Ok(RsData::AAAA(Default::default())), 198 | _ => Err(RsDataParseError::UnknownType), 199 | }; 200 | } 201 | if parts.len() != 2 { 202 | return Err(RsDataParseError::MissingType); 203 | } 204 | let (rtype, rdata) = (parts[0].to_uppercase(), parts[1]); 205 | let rdata_parts = rdata.split(','); 206 | match rtype.as_str() { 207 | "TXT" => Ok(RsData::TXT(rdata_parts.map(|s| s.to_owned()).collect())), 208 | "A" => { 209 | let addrs = rdata_parts 210 | .map(|part| part.parse().map_err(RsDataParseError::Addr)) 211 | .collect::>()?; 212 | Ok(RsData::A(addrs)) 213 | } 214 | "AAAA" => { 215 | let addrs = rdata_parts 216 | .map(|part| part.parse().map_err(RsDataParseError::Addr)) 217 | .collect::>()?; 218 | Ok(RsData::AAAA(addrs)) 219 | } 220 | _ => Err(RsDataParseError::UnknownType), 221 | } 222 | } 223 | } 224 | 225 | #[derive(Debug)] 226 | pub enum RsDataParseError { 227 | MissingType, 228 | UnknownType, 229 | Addr(net::AddrParseError), 230 | } 231 | 232 | impl fmt::Display for RsDataParseError { 233 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 234 | use RsDataParseError::*; 235 | match self { 236 | MissingType => write!(f, "missing type"), 237 | UnknownType => write!(f, "unknown type"), 238 | Addr(e) => write!(f, "invalid address: {}", e), 239 | } 240 | } 241 | } 242 | 243 | impl std::error::Error for RsDataParseError {} 244 | 245 | #[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] 246 | pub struct RsKey { 247 | name: rr::Name, 248 | dns_class: rr::DNSClass, 249 | record_type: rr::RecordType, 250 | } 251 | 252 | impl RsKey { 253 | pub fn name(&self) -> &rr::Name { 254 | &self.name 255 | } 256 | pub fn dns_class(&self) -> rr::DNSClass { 257 | self.dns_class 258 | } 259 | pub fn record_type(&self) -> rr::RecordType { 260 | self.record_type 261 | } 262 | } 263 | 264 | impl From<&rr::Record> for RsKey { 265 | fn from(rr: &rr::Record) -> Self { 266 | RsKey { 267 | name: rr.name().clone(), 268 | dns_class: rr.dns_class(), 269 | record_type: rr.record_type(), 270 | } 271 | } 272 | } 273 | 274 | fn txt_string(txt: &rdata::TXT) -> Result { 275 | let data = txt.txt_data(); 276 | if data.len() != 1 { 277 | return Err(TryFromRecordsError::UnsupportedTxtValue); 278 | } 279 | str::from_utf8(&data[0]) 280 | .map(Into::into) 281 | .map_err(TryFromRecordsError::Utf8) 282 | } 283 | 284 | impl TryFrom<&[rr::Record]> for RecordSet { 285 | type Error = TryFromRecordsError; 286 | 287 | fn try_from(rrs: &[rr::Record]) -> Result { 288 | let keys: BTreeSet = rrs.iter().map(Into::into).collect(); 289 | match keys.len() { 290 | 0 => Err(TryFromRecordsError::Empty), 291 | 1 => { 292 | let key = keys.iter().next().unwrap(); 293 | // TODO: I'm not sure if `trust-dns` actually guarantees that 294 | // these `unwrap` calls never panic, but I'd guess so. I should 295 | // study its code and submit a documentation patch to clarify 296 | // behavior in either case. 297 | let data = match key.record_type { 298 | rr::RecordType::A => { 299 | RsData::A(rrs.iter().map(|rr| *rr.rdata().as_a().unwrap()).collect()) 300 | } 301 | rr::RecordType::AAAA => RsData::AAAA( 302 | rrs.iter() 303 | .map(|rr| *rr.rdata().as_aaaa().unwrap()) 304 | .collect(), 305 | ), 306 | rr::RecordType::TXT => RsData::TXT( 307 | rrs.iter() 308 | .map(|rr| txt_string(rr.rdata().as_txt().unwrap())) 309 | .collect::>()?, 310 | ), 311 | rtype => return Err(TryFromRecordsError::UnsupportedType(rtype)), 312 | }; 313 | Ok(RecordSet { 314 | name: key.name.clone(), 315 | dns_class: key.dns_class, 316 | data, 317 | }) 318 | } 319 | _ => Err(TryFromRecordsError::MultipleKeys(keys)), 320 | } 321 | } 322 | } 323 | 324 | #[derive(Debug)] 325 | pub enum TryFromRecordsError { 326 | Empty, 327 | MultipleKeys(BTreeSet), 328 | UnsupportedType(rr::RecordType), 329 | UnsupportedTxtValue, 330 | FromUtf8(FromUtf8Error), 331 | Utf8(str::Utf8Error), 332 | } 333 | 334 | impl fmt::Display for TryFromRecordsError { 335 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 336 | use TryFromRecordsError::*; 337 | match self { 338 | Empty => write!(f, "no records"), 339 | MultipleKeys(_) => write!(f, "multiple keys"), 340 | UnsupportedType(rtype) => write!(f, "unsupported record type {}", rtype), 341 | UnsupportedTxtValue => write!(f, "unsupported TXT value"), 342 | Utf8(e) => write!(f, "non-UTF8 content: {}", e), 343 | FromUtf8(e) => write!(f, "non-UTF8 content: {}", e), 344 | } 345 | } 346 | } 347 | 348 | impl std::error::Error for TryFromRecordsError {} 349 | -------------------------------------------------------------------------------- /src/bin/tdns.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs, 3 | io::{BufRead, BufReader, Write}, 4 | net::{IpAddr, SocketAddr}, 5 | path::{Path, PathBuf}, 6 | time::Duration, 7 | }; 8 | 9 | use anyhow::anyhow; 10 | use data_encoding::BASE64; 11 | use futures::{future, StreamExt}; 12 | use structopt::StructOpt; 13 | use tokio::runtime::Runtime; 14 | use trust_dns_client::{proto::error::ProtoError, rr}; 15 | use trust_dns_resolver::error::{ResolveError, ResolveErrorKind}; 16 | 17 | use tdns_cli::{ 18 | query::{self, perform_query, Query}, 19 | record::{RecordSet, RsData}, 20 | tsig, 21 | update::{monitor_update, perform_update, Expectation, Monitor, Operation, Update}, 22 | util, Backend, TcpBackend, UdpBackend, 23 | }; 24 | 25 | /// DNS client utilities 26 | #[allow(clippy::large_enum_variant)] 27 | #[derive(StructOpt)] 28 | enum Tdns { 29 | /// Update a DNS entry 30 | Update(UpdateOpt), 31 | /// Issue DNS queries 32 | Query(QueryOpt), 33 | } 34 | 35 | #[derive(StructOpt)] 36 | struct CommonOpt { 37 | /// Specify the recusor to use, including the port number. 38 | /// 39 | /// If not specified, the first nameserver specified in `/etc/resolv.conf` 40 | /// is used. 41 | #[structopt(long)] 42 | resolver: Option, 43 | /// Use TCP for all DNS requests. 44 | #[structopt(long)] 45 | tcp: bool, 46 | } 47 | 48 | // This is just so that `structopt` does not treat options of this type as 49 | // taking multiple arguments. 50 | type RTypes = Vec; 51 | 52 | fn parse_rtypes(s: &str) -> Result { 53 | let s = s.to_uppercase(); 54 | util::parse_comma_separated(&s) 55 | } 56 | 57 | #[derive(StructOpt)] 58 | struct QueryOpt { 59 | #[structopt(flatten)] 60 | common: CommonOpt, 61 | entry: rr::Name, 62 | #[structopt(long = "type", short = "t", parse(try_from_str = parse_rtypes))] 63 | record_types: Option, 64 | #[structopt(long = "fmt", short = "f")] 65 | display_format: Option, 66 | } 67 | 68 | impl QueryOpt { 69 | fn get_display_format( 70 | display_format: Option, 71 | query_types: &[rr::RecordType], 72 | ) -> query::DisplayFormat { 73 | use query::DisplayFormat; 74 | use rr::RecordType::*; 75 | display_format.unwrap_or_else(move || { 76 | if (query_types.len() == 1 && query_types[0] != ANY) 77 | || query_types.iter().all(|&rtype| rtype == A || rtype == AAAA) 78 | { 79 | DisplayFormat::Short 80 | } else { 81 | DisplayFormat::Zone 82 | } 83 | }) 84 | } 85 | 86 | fn to_query(&self) -> Query { 87 | let record_types = self 88 | .record_types 89 | .as_ref() 90 | .map(|cs| cs.to_vec()) 91 | .unwrap_or_else(|| vec![rr::RecordType::A]); 92 | Query { 93 | entry: self.entry.clone(), 94 | display_format: Self::get_display_format(self.display_format, &record_types), 95 | record_types, 96 | } 97 | } 98 | } 99 | 100 | #[derive(StructOpt)] 101 | struct UpdateOpt { 102 | #[structopt(flatten)] 103 | common: CommonOpt, 104 | /// Timeout in seconds for how long to wait in total for a successful 105 | /// update. 106 | #[structopt(long)] 107 | timeout: Option, 108 | #[structopt(long)] 109 | server: Option, 110 | #[structopt(long)] 111 | zone: Option, 112 | /// Entry to update and/or monitor. 113 | entry: rr::Name, 114 | /// RRset for update and/or monitoring. 115 | rs_data: Option, 116 | /// TSIG key in NAME:ALGORITHM:BASE64-DATA notation, or just NAME when used 117 | /// in combination with --key-file. 118 | #[structopt(long)] 119 | key: Option, 120 | #[structopt(long)] 121 | key_file: Option, 122 | /// Excluded IP address. 123 | #[structopt(long)] 124 | exclude: Option, 125 | /// The TTL for added records. 126 | #[structopt(long)] 127 | ttl: Option, 128 | /// Do not perform the update. 129 | #[structopt(long)] 130 | no_op: bool, 131 | /// Delete matching records. 132 | #[structopt(long)] 133 | delete: bool, 134 | /// Append records to the zone. 135 | #[structopt(long)] 136 | append: bool, 137 | /// Create the specified records. 138 | /// 139 | /// Ensures that no records for the added types exist. 140 | #[structopt(long)] 141 | create: bool, 142 | /// Do not monitor nameservers for the update. 143 | #[structopt(long)] 144 | no_wait: bool, 145 | /// Show informational messages during execution. 146 | #[structopt(long, short)] 147 | verbose: bool, 148 | /// The number of seconds to wait between checking. 149 | #[structopt(long)] 150 | interval: Option, 151 | } 152 | 153 | impl UpdateOpt { 154 | fn get_rset(&self) -> anyhow::Result { 155 | let rs_data = self 156 | .rs_data 157 | .clone() 158 | .ok_or_else(|| anyhow!("Missing RS-DATA argument"))?; 159 | Ok(RecordSet::new(self.entry.clone(), rs_data)) 160 | } 161 | 162 | fn get_operation(&self) -> anyhow::Result> { 163 | let op_flags = &[self.create, self.delete, self.append]; 164 | let operation = match op_flags.iter().filter(|&&flag| flag).count() { 165 | 0 => return Ok(None), 166 | 1 => match op_flags.iter().position(|flag| *flag).unwrap() { 167 | 0 => Operation::Create(self.get_rset()?), 168 | 1 => match &self.rs_data { 169 | Some(rs_data) => { 170 | Operation::Delete(RecordSet::new(self.entry.clone(), rs_data.clone())) 171 | } 172 | None => Operation::DeleteAll(self.entry.clone()), 173 | }, 174 | 2 => Operation::Append(self.get_rset()?), 175 | _ => unreachable!(), 176 | }, 177 | _ => return Err(anyhow!("Conflicting operations specified")), 178 | }; 179 | Ok(Some(operation)) 180 | } 181 | 182 | fn get_tsig_key(&self) -> anyhow::Result> { 183 | if let Some(key) = &self.key { 184 | let parts: Vec<_> = key.split(':').collect(); 185 | match parts.len() { 186 | 1 => { 187 | let key_name = parts[0].parse()?; 188 | if let Some(file_name) = &self.key_file { 189 | Ok(Some(read_key(file_name, Some(&key_name))?)) 190 | } else { 191 | Err(anyhow!("--key-file option required with --key=NAME")) 192 | } 193 | } 194 | 3 => { 195 | let (name, algo, data) = (parts[0], parts[1], parts[2]); 196 | Ok(Some(tsig::Key::new( 197 | name.parse()?, 198 | tsig::Algorithm::from_name(&algo.parse()?)?, 199 | BASE64.decode(data.as_bytes())?, 200 | ))) 201 | } 202 | _ => Err(anyhow!( 203 | "expected NAME or NAME:ALGORITHM:KEY, found {}", 204 | key 205 | )), 206 | } 207 | } else if let Some(key_file) = &self.key_file { 208 | Ok(Some(read_key(key_file, None)?)) 209 | } else { 210 | Ok(None) 211 | } 212 | } 213 | 214 | fn to_update(&self) -> anyhow::Result> { 215 | let zone = self.zone.clone().unwrap_or_else(|| self.entry.base_name()); 216 | if self.no_op { 217 | return Ok(None); 218 | } 219 | Ok(Some(Update { 220 | operation: match self.get_operation()? { 221 | Some(operation) => operation, 222 | None => return Ok(None), 223 | }, 224 | server: self.server.clone(), 225 | zone, 226 | tsig_key: self.get_tsig_key()?, 227 | ttl: self.ttl.unwrap_or(3600), 228 | })) 229 | } 230 | 231 | fn to_monitor(&self) -> anyhow::Result> { 232 | let zone = self.zone.clone().unwrap_or_else(|| self.entry.base_name()); 233 | if self.no_wait { 234 | return Ok(None); 235 | } 236 | Ok(Some(Monitor { 237 | zone, 238 | entry: self.entry.clone(), 239 | expectation: match self.get_operation()? { 240 | None => Expectation::Is(self.get_rset()?), 241 | Some(Operation::Create(rset)) => Expectation::Is(rset), 242 | Some(Operation::Append(rset)) => Expectation::Contains(rset), 243 | Some(Operation::Delete(rset)) => { 244 | if rset.is_empty() { 245 | Expectation::Empty(rset.record_type()) 246 | } else { 247 | Expectation::NotAny(rset) 248 | } 249 | } 250 | Some(Operation::DeleteAll(_)) => Expectation::Empty(rr::RecordType::ANY), 251 | }, 252 | exclude: self.exclude.into_iter().collect(), 253 | interval: Duration::from_secs(self.interval.unwrap_or(1)), 254 | timeout: Duration::from_secs(self.timeout.unwrap_or(60)), 255 | verbose: self.verbose, 256 | })) 257 | } 258 | } 259 | 260 | /// Reads a TSIG key from a file. 261 | /// 262 | /// If `key_name` is `None`, the first key will be returned, otherwise the first 263 | /// key matching `key_name` will be returned. When no matching key was found, or 264 | /// the file could not be parsed, an error will be returned. 265 | fn read_key(path: &Path, key_name: Option<&rr::Name>) -> anyhow::Result { 266 | let file = fs::File::open(path)?; 267 | let input = BufReader::new(file); 268 | for line in input.lines() { 269 | let line = line?; 270 | let line = line.trim(); 271 | if line.is_empty() || line.starts_with('#') { 272 | continue; 273 | } 274 | let parts: Vec<_> = line.split(':').collect(); 275 | if parts.len() != 3 { 276 | return Err(anyhow!( 277 | "invalid line in key file; expected NAME:ALGORITHM:KEY, found {}", 278 | line 279 | )); 280 | } 281 | let name = parts[0].parse()?; 282 | if key_name.is_none() || Some(&name) == key_name { 283 | let (algo, data) = (parts[1], parts[2]); 284 | return Ok(tsig::Key::new( 285 | name, 286 | tsig::Algorithm::from_name(&algo.parse()?)?, 287 | BASE64.decode(data.as_bytes())?, 288 | )); 289 | } 290 | } 291 | if let Some(key_name) = key_name { 292 | Err(anyhow!("key {} not found in {}", key_name, path.display())) 293 | } else { 294 | Err(anyhow!("no key found in {}", path.display())) 295 | } 296 | } 297 | 298 | fn open_resolver( 299 | mut dns: D, 300 | addr: Option, 301 | ) -> Result { 302 | if let Some(addr) = addr { 303 | Ok(dns.open_resolver(addr)?) 304 | } else { 305 | Ok(dns.open_system_resolver()?) 306 | } 307 | } 308 | 309 | async fn run_update( 310 | runtime: &Runtime, 311 | dns: D, 312 | opt: UpdateOpt, 313 | ) -> anyhow::Result<()> { 314 | let resolver = open_resolver(dns.clone(), opt.common.resolver)?; 315 | if let Some(update) = opt.to_update()? { 316 | perform_update(runtime, dns.clone(), resolver.clone(), update).await?; 317 | } 318 | if let Some(monitor) = opt.to_monitor()? { 319 | monitor_update(runtime, dns, resolver, monitor).await?; 320 | } 321 | Ok(()) 322 | } 323 | 324 | async fn run_query(dns: D, opt: QueryOpt) -> anyhow::Result<()> { 325 | let resolver = open_resolver(dns.clone(), opt.common.resolver)?; 326 | let query = opt.to_query(); 327 | let (n_failed, total) = perform_query(resolver, query.clone()) 328 | .fold((0_usize, 0_usize), |(n_failed, total), item| { 329 | let mut stdout = std::io::stdout(); 330 | let success = match item { 331 | Ok(records) => { 332 | for record in records { 333 | query::write_record(&mut stdout, &record, query.display_format).unwrap(); 334 | stdout.write_all(b"\n").unwrap(); 335 | } 336 | true 337 | } 338 | Err(e) => match e.kind() { 339 | ResolveErrorKind::NoRecordsFound { .. } => true, 340 | _ => { 341 | eprintln!("error response for query: {}", e); 342 | false 343 | } 344 | }, 345 | }; 346 | future::ready((n_failed + if success { 0 } else { 1 }, total + 1)) 347 | }) 348 | .await; 349 | if n_failed > 0 { 350 | return Err(anyhow!("{}/{} queries failed", n_failed, total,)); 351 | } 352 | Ok(()) 353 | } 354 | 355 | async fn run(runtime: &Runtime, tdns: Tdns) -> anyhow::Result<()> { 356 | match tdns { 357 | Tdns::Query(opt) => { 358 | if opt.common.tcp { 359 | run_query(TcpBackend, opt).await? 360 | } else { 361 | run_query(UdpBackend, opt).await? 362 | } 363 | } 364 | Tdns::Update(opt) => { 365 | if opt.common.tcp { 366 | run_update(runtime, TcpBackend, opt).await? 367 | } else { 368 | run_update(runtime, UdpBackend, opt).await? 369 | } 370 | } 371 | } 372 | Ok(()) 373 | } 374 | 375 | fn main() { 376 | let runtime = Runtime::new().unwrap(); 377 | let tdns = Tdns::from_args(); 378 | let rc = match runtime.block_on(run(&runtime, tdns)) { 379 | Ok(_) => 0, 380 | Err(e) => { 381 | eprintln!("Error: {}", e); 382 | 1 383 | } 384 | }; 385 | std::process::exit(rc); 386 | } 387 | -------------------------------------------------------------------------------- /src/query.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fmt::{self, Write}, 3 | io, 4 | str::{self, FromStr}, 5 | }; 6 | 7 | use chrono::DateTime; 8 | use data_encoding::{Encoding, BASE32, BASE64, HEXLOWER}; 9 | use futures::stream::{FuturesUnordered, Stream}; 10 | 11 | use trust_dns_client::rr::{ 12 | self, 13 | dnssec::Nsec3HashAlgorithm, 14 | rdata::{self, caa, DNSSECRData}, 15 | }; 16 | use trust_dns_resolver::error::ResolveError; 17 | 18 | use crate::Resolver; 19 | 20 | #[derive(Debug, Clone)] 21 | pub enum ParseDisplayFormatError { 22 | UnknownFormat, 23 | } 24 | 25 | impl fmt::Display for ParseDisplayFormatError { 26 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 27 | use ParseDisplayFormatError::*; 28 | match self { 29 | UnknownFormat => write!(f, "unknown format"), 30 | } 31 | } 32 | } 33 | 34 | #[derive(Debug, Copy, Clone)] 35 | pub enum DisplayFormat { 36 | Short, 37 | Zone, 38 | } 39 | 40 | impl FromStr for DisplayFormat { 41 | type Err = ParseDisplayFormatError; 42 | 43 | fn from_str(s: &str) -> Result { 44 | match s { 45 | "short" => Ok(DisplayFormat::Short), 46 | "zone" => Ok(DisplayFormat::Zone), 47 | _ => Err(ParseDisplayFormatError::UnknownFormat), 48 | } 49 | } 50 | } 51 | 52 | #[derive(Debug, Clone)] 53 | pub struct Query { 54 | pub entry: rr::Name, 55 | pub record_types: Vec, 56 | pub display_format: DisplayFormat, 57 | } 58 | 59 | pub fn perform_query( 60 | resolver: impl Resolver + 'static, 61 | options: Query, 62 | ) -> impl Stream, ResolveError>> { 63 | let entry = options.entry; 64 | options 65 | .record_types 66 | .into_iter() 67 | .map(move |rtype| { 68 | let resolver = resolver.clone(); 69 | let entry = entry.clone(); 70 | async move { 71 | let lookup = resolver.lookup(entry.clone(), rtype).await?; 72 | Ok(lookup.record_iter().cloned().collect::>()) 73 | } 74 | }) 75 | .collect::>() 76 | } 77 | 78 | struct CharacterString<'a>(&'a [u8]); 79 | 80 | impl<'a> fmt::Display for CharacterString<'a> { 81 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 82 | write!(f, "\"{}\"", CharacterStringContents(self.0))?; 83 | Ok(()) 84 | } 85 | } 86 | 87 | struct DisplayStrContents<'a>(&'a str); 88 | 89 | struct CharacterStringContents<'a>(&'a [u8]); 90 | 91 | impl<'a> fmt::Display for DisplayStrContents<'a> { 92 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 93 | let s = self.0; 94 | let mut last_pos = 0; 95 | while let Some(pos) = 96 | s[last_pos..].find(|c: char| c == '"' || c.is_control() || c.is_whitespace()) 97 | { 98 | f.write_str(&s[last_pos..last_pos + pos])?; 99 | let c = s[last_pos + pos..].chars().next().unwrap(); 100 | match c { 101 | '"' => f.write_str("\\\"")?, 102 | ' ' => f.write_char(' ')?, 103 | c => { 104 | let mut buf = [0_u8; 4]; 105 | for &octet in c.encode_utf8(&mut buf).as_bytes() { 106 | write!(f, "\\{:03}", octet)?; 107 | } 108 | } 109 | } 110 | last_pos += pos + c.len_utf8(); 111 | } 112 | f.write_str(&s[last_pos..])?; 113 | Ok(()) 114 | } 115 | } 116 | 117 | impl<'a> fmt::Display for CharacterStringContents<'a> { 118 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 119 | match str::from_utf8(self.0) { 120 | Ok(s) => write!(f, "{}", DisplayStrContents(s))?, 121 | Err(_) => { 122 | // The data contains non-UTF8 byte sequences. Write ASCII 123 | // graphic or SPACE octets as-is, and escape all other 124 | // octets. As this path is expected to be cold, no effort was 125 | // spent towards making this efficient. 126 | for &octet in self.0 { 127 | if octet.is_ascii_graphic() || octet == b' ' { 128 | if octet == b'"' { 129 | f.write_str("\\\"")?; 130 | } else { 131 | f.write_char(char::from(octet))?; 132 | } 133 | } else { 134 | write!(f, "\\{:03}", octet)?; 135 | } 136 | } 137 | } 138 | } 139 | Ok(()) 140 | } 141 | } 142 | 143 | #[derive(Debug, Copy, Clone)] 144 | struct DisplayRData<'a>(&'a rr::RData); 145 | 146 | impl<'a> fmt::Display for DisplayRData<'a> { 147 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 148 | use rr::RData::*; 149 | match self.0 { 150 | A(addr) => write!(f, "{}", addr)?, 151 | AAAA(addr) => write!(f, "{}", addr)?, 152 | ANAME(name) => write!(f, "{}", name)?, 153 | CAA(caa) => { 154 | let tag = match caa.tag() { 155 | caa::Property::Issue => "issue", 156 | caa::Property::IssueWild => "issuewild", 157 | caa::Property::Iodef => "iodef", 158 | caa::Property::Unknown(name) => name, 159 | }; 160 | write!(f, "{} {} ", if caa.issuer_critical() { 1 } else { 0 }, tag,)?; 161 | match caa.value() { 162 | caa::Value::Issuer(name, kvs) => { 163 | f.write_str("\"")?; 164 | if let Some(name) = name { 165 | write!(f, "{}", name)?; 166 | if !kvs.is_empty() { 167 | f.write_str(";")?; 168 | } 169 | } else { 170 | f.write_str(";")?; 171 | } 172 | for kv in kvs { 173 | write!(f, "{}={}", kv.key(), kv.value())?; 174 | } 175 | f.write_str("\"")?; 176 | } 177 | caa::Value::Url(url) => write!(f, "\"{}\"", DisplayStrContents(url.as_str()))?, 178 | caa::Value::Unknown(bytes) => write!(f, "{}", CharacterString(bytes))?, 179 | } 180 | } 181 | CNAME(name) => write!(f, "{}", name)?, 182 | DNSSEC(sec) => write!(f, "{}", DisplayDNSSECRData(sec))?, 183 | MX(mx) => write!(f, "{} {}", mx.preference(), mx.exchange())?, 184 | NAPTR(naptr) => write!( 185 | f, 186 | "{} {} {} {} {} {}", 187 | naptr.order(), 188 | naptr.preference(), 189 | CharacterString(naptr.flags()), 190 | CharacterString(naptr.services()), 191 | CharacterString(naptr.regexp()), 192 | naptr.replacement() 193 | )?, 194 | NS(name) => write!(f, "{}", name)?, 195 | OPENPGPKEY(key) => write!(f, "{}", DisplayEncoded(&BASE64, key.public_key()))?, 196 | PTR(name) => write!(f, "{}", name)?, 197 | SOA(soa) => { 198 | write!( 199 | f, 200 | "{} {} {} {} {} {} {}", 201 | soa.mname(), 202 | soa.rname(), 203 | soa.serial(), 204 | soa.refresh(), 205 | soa.retry(), 206 | soa.expire(), 207 | soa.minimum() 208 | )?; 209 | } 210 | SRV(srv) => write!( 211 | f, 212 | "{} {} {} {}", 213 | srv.priority(), 214 | srv.weight(), 215 | srv.port(), 216 | srv.target() 217 | )?, 218 | SSHFP(sshfp) => write!( 219 | f, 220 | "{} {} {}", 221 | u8::from(sshfp.algorithm()), 222 | u8::from(sshfp.fingerprint_type()), 223 | DisplayEncoded(&HEXLOWER, sshfp.fingerprint()) 224 | )?, 225 | TLSA(tlsa) => write!( 226 | f, 227 | "{} {} {} {}", 228 | u8::from(tlsa.cert_usage()), 229 | u8::from(tlsa.selector()), 230 | u8::from(tlsa.matching()), 231 | DisplayEncoded(&HEXLOWER, tlsa.cert_data()) 232 | )?, 233 | TXT(txt) => { 234 | for (i, data) in txt.txt_data().iter().enumerate() { 235 | let chars = CharacterString(data); 236 | if i + 1 < txt.txt_data().len() { 237 | write!(f, "{} ", chars)?; 238 | } else { 239 | write!(f, "{}", chars)?; 240 | } 241 | } 242 | } 243 | // TODO: What to do with records that have no specified presentation? 244 | NULL(_) | OPT(_) | Unknown { .. } | ZERO | HINFO(_) | HTTPS(_) | SVCB(_) => { 245 | write!(f, "{:?}", self.0)? 246 | } 247 | } 248 | Ok(()) 249 | } 250 | } 251 | 252 | struct DisplayEncoded<'a>(&'a Encoding, &'a [u8]); 253 | 254 | impl<'a> fmt::Display for DisplayEncoded<'a> { 255 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 256 | // TODO: It's a bit unfortunate that this allocates; maybe use a buffer if 257 | // the input is smaller than some reasonable limit? 258 | f.write_str(self.0.encode(self.1).as_str()) 259 | } 260 | } 261 | 262 | struct ShowTimestamp(u32); 263 | 264 | impl fmt::Display for ShowTimestamp { 265 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 266 | let time = 267 | DateTime::from_timestamp(i64::from(self.0), 0).expect("u32 seconds is always valid"); 268 | write!(f, "{}", time.format("%Y%m%d%H%S")) 269 | } 270 | } 271 | 272 | #[derive(Debug, Copy, Clone)] 273 | struct DisplayDNSSECRData<'a>(&'a DNSSECRData); 274 | 275 | impl<'a> fmt::Display for DisplayDNSSECRData<'a> { 276 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 277 | use DNSSECRData::*; 278 | match self.0 { 279 | DNSKEY(key) => { 280 | // The MSB is bit 0, hence the subtraction from 15 281 | let flag_bit = |b, n| (b as u16) << (15 - n); 282 | let flags = flag_bit(key.zone_key(), 7) 283 | | flag_bit(key.revoke(), 8) 284 | | flag_bit(key.secure_entry_point(), 15); 285 | let algorithm = key.algorithm().as_str(); 286 | let protocol = 3; // Fixed value, see RFC 4043, section 2.1.2 287 | write!( 288 | f, 289 | "{} {} {} {}", 290 | flags, 291 | protocol, 292 | algorithm, 293 | DisplayEncoded(&BASE64, key.public_key()) 294 | )?; 295 | } 296 | DS(ds) => { 297 | let digest_type: u8 = ds.digest_type().into(); 298 | write!( 299 | f, 300 | "{} {} {} {}", 301 | ds.key_tag(), 302 | ds.algorithm().as_str(), 303 | digest_type, 304 | DisplayEncoded(&HEXLOWER, ds.digest()), 305 | )?; 306 | } 307 | KEY(key) => { 308 | // RFC 2535, section 7.1 309 | use rdata::key::KeyTrust::*; 310 | match key.key_trust() { 311 | NotAuth => write!(f, "NOAUTH|")?, 312 | NotPrivate => write!(f, "NOCONF|")?, 313 | DoNotTrust => write!(f, "NOKEY|")?, 314 | AuthOrPrivate => {} 315 | } 316 | use rdata::key::KeyUsage::*; 317 | match key.key_usage() { 318 | Host => write!(f, "USER|")?, 319 | #[allow(deprecated)] 320 | Zone => write!(f, "ZONE|")?, 321 | Entity => write!(f, "HOST|")?, 322 | // TODO: Actually, this has no specified textual representation, 323 | // need use switch to numeric representation. 324 | Reserved => write!(f, "RESERVED|")?, 325 | } 326 | let scope = key.signatory(); 327 | let signatory_bit = |b, n| (b as u8) << (3 - n); 328 | #[allow(deprecated)] 329 | let signatory_bits = signatory_bit(scope.zone, 0) 330 | | signatory_bit(scope.strong, 1) 331 | | signatory_bit(scope.unique, 2) 332 | | signatory_bit(scope.general, 3); 333 | write!(f, "SIG{}", signatory_bits)?; 334 | } 335 | NSEC(nsec) => { 336 | write!(f, "{}", nsec.next_domain_name())?; 337 | if !nsec.type_bit_maps().is_empty() { 338 | write!(f, " {}", DisplayNSECTypeBitMaps(nsec.type_bit_maps()))?; 339 | } 340 | } 341 | NSEC3(nsec3) => { 342 | // RFC 5155, Section 3.3 343 | write!( 344 | f, 345 | "{} {}", 346 | DisplayNSEC3Common::from(nsec3), 347 | DisplayEncoded(&BASE32, nsec3.next_hashed_owner_name()) 348 | )?; 349 | if !nsec3.type_bit_maps().is_empty() { 350 | write!(f, " {}", DisplayNSECTypeBitMaps(nsec3.type_bit_maps()))?; 351 | } 352 | } 353 | NSEC3PARAM(nsec3param) => write!(f, "{}", DisplayNSEC3Common::from(nsec3param))?, 354 | SIG(sig) => { 355 | // RFC 2535, section 7.2 356 | write!( 357 | f, 358 | "{} {} {} {} {} {} {} {} {}", 359 | sig.type_covered(), 360 | sig.algorithm().as_str(), 361 | sig.num_labels(), 362 | sig.original_ttl(), 363 | ShowTimestamp(sig.sig_expiration()), 364 | ShowTimestamp(sig.sig_inception()), 365 | sig.key_tag(), 366 | sig.signer_name(), 367 | DisplayEncoded(&BASE64, sig.sig()), 368 | )?; 369 | } 370 | Unknown { rdata, .. } => { 371 | // This is dubiuos, and I'm not sure how we can even end up here. 372 | if let Some(data) = rdata.anything() { 373 | write!(f, "{}", DisplayEncoded(&BASE64, data))?; 374 | } 375 | } 376 | } 377 | Ok(()) 378 | } 379 | } 380 | 381 | struct DisplayNSEC3Common<'a> { 382 | hash_algorithm: Nsec3HashAlgorithm, 383 | opt_out: bool, 384 | iterations: u16, 385 | salt: &'a [u8], 386 | } 387 | 388 | impl<'a> From<&'a rdata::NSEC3> for DisplayNSEC3Common<'a> { 389 | fn from(nsec3: &'a rdata::NSEC3) -> Self { 390 | DisplayNSEC3Common { 391 | hash_algorithm: nsec3.hash_algorithm(), 392 | opt_out: nsec3.opt_out(), 393 | iterations: nsec3.iterations(), 394 | salt: nsec3.salt(), 395 | } 396 | } 397 | } 398 | 399 | impl<'a> From<&'a rdata::NSEC3PARAM> for DisplayNSEC3Common<'a> { 400 | fn from(nsec3: &'a rdata::NSEC3PARAM) -> Self { 401 | DisplayNSEC3Common { 402 | hash_algorithm: nsec3.hash_algorithm(), 403 | opt_out: nsec3.opt_out(), 404 | iterations: nsec3.iterations(), 405 | salt: nsec3.salt(), 406 | } 407 | } 408 | } 409 | 410 | impl<'a> fmt::Display for DisplayNSEC3Common<'a> { 411 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 412 | // RFC 5155, Section 4.3 413 | let algo_num: u8 = match self.hash_algorithm { 414 | Nsec3HashAlgorithm::SHA1 => 1, 415 | }; 416 | let flags: u8 = self.opt_out as u8; 417 | write!(f, "{} {} {} ", algo_num, flags, self.iterations)?; 418 | if self.salt.is_empty() { 419 | write!(f, "-")?; 420 | } else { 421 | write!(f, "{}", DisplayEncoded(&HEXLOWER, self.salt))?; 422 | } 423 | Ok(()) 424 | } 425 | } 426 | 427 | struct DisplayNSECTypeBitMaps<'a>(&'a [rr::RecordType]); 428 | 429 | impl<'a> fmt::Display for DisplayNSECTypeBitMaps<'a> { 430 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 431 | for (i, record_type) in self.0.iter().enumerate() { 432 | let sep = if i + 1 == self.0.len() { "" } else { " " }; 433 | write!(f, "{}{}", record_type, sep)?; 434 | } 435 | Ok(()) 436 | } 437 | } 438 | 439 | pub fn write_record( 440 | writer: &mut W, 441 | record: &rr::Record, 442 | format: DisplayFormat, 443 | ) -> io::Result<()> { 444 | match format { 445 | DisplayFormat::Short => { 446 | write!(writer, "{}", DisplayRData(record.rdata()))?; 447 | } 448 | DisplayFormat::Zone => { 449 | write!( 450 | writer, 451 | "{} {} {} {} {}", 452 | record.name(), 453 | record.ttl(), 454 | record.dns_class(), 455 | record.record_type(), 456 | DisplayRData(record.rdata()), 457 | )?; 458 | } 459 | } 460 | Ok(()) 461 | } 462 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.22.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "android-tzdata" 22 | version = "0.1.1" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" 25 | 26 | [[package]] 27 | name = "android_system_properties" 28 | version = "0.1.5" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 31 | dependencies = [ 32 | "libc", 33 | ] 34 | 35 | [[package]] 36 | name = "ansi_term" 37 | version = "0.12.1" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 40 | dependencies = [ 41 | "winapi", 42 | ] 43 | 44 | [[package]] 45 | name = "anyhow" 46 | version = "1.0.86" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" 49 | 50 | [[package]] 51 | name = "async-trait" 52 | version = "0.1.81" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" 55 | dependencies = [ 56 | "proc-macro2", 57 | "quote", 58 | "syn 2.0.75", 59 | ] 60 | 61 | [[package]] 62 | name = "atty" 63 | version = "0.2.14" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 66 | dependencies = [ 67 | "hermit-abi 0.1.19", 68 | "libc", 69 | "winapi", 70 | ] 71 | 72 | [[package]] 73 | name = "autocfg" 74 | version = "1.3.0" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" 77 | 78 | [[package]] 79 | name = "backtrace" 80 | version = "0.3.73" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" 83 | dependencies = [ 84 | "addr2line", 85 | "cc", 86 | "cfg-if", 87 | "libc", 88 | "miniz_oxide", 89 | "object", 90 | "rustc-demangle", 91 | ] 92 | 93 | [[package]] 94 | name = "bitflags" 95 | version = "1.3.2" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 98 | 99 | [[package]] 100 | name = "bitflags" 101 | version = "2.6.0" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 104 | 105 | [[package]] 106 | name = "block-buffer" 107 | version = "0.10.4" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 110 | dependencies = [ 111 | "generic-array", 112 | ] 113 | 114 | [[package]] 115 | name = "bumpalo" 116 | version = "3.16.0" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" 119 | 120 | [[package]] 121 | name = "byteorder" 122 | version = "1.5.0" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 125 | 126 | [[package]] 127 | name = "bytes" 128 | version = "1.7.1" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" 131 | 132 | [[package]] 133 | name = "cc" 134 | version = "1.1.13" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" 137 | dependencies = [ 138 | "shlex", 139 | ] 140 | 141 | [[package]] 142 | name = "cfg-if" 143 | version = "1.0.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 146 | 147 | [[package]] 148 | name = "chrono" 149 | version = "0.4.38" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" 152 | dependencies = [ 153 | "android-tzdata", 154 | "iana-time-zone", 155 | "js-sys", 156 | "num-traits", 157 | "wasm-bindgen", 158 | "windows-targets", 159 | ] 160 | 161 | [[package]] 162 | name = "clap" 163 | version = "2.34.0" 164 | source = "registry+https://github.com/rust-lang/crates.io-index" 165 | checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" 166 | dependencies = [ 167 | "ansi_term", 168 | "atty", 169 | "bitflags 1.3.2", 170 | "strsim", 171 | "textwrap", 172 | "unicode-width", 173 | "vec_map", 174 | ] 175 | 176 | [[package]] 177 | name = "core-foundation-sys" 178 | version = "0.8.7" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" 181 | 182 | [[package]] 183 | name = "cpufeatures" 184 | version = "0.2.13" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" 187 | dependencies = [ 188 | "libc", 189 | ] 190 | 191 | [[package]] 192 | name = "crypto-common" 193 | version = "0.1.6" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 196 | dependencies = [ 197 | "generic-array", 198 | "typenum", 199 | ] 200 | 201 | [[package]] 202 | name = "data-encoding" 203 | version = "2.6.0" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" 206 | 207 | [[package]] 208 | name = "deranged" 209 | version = "0.3.11" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" 212 | dependencies = [ 213 | "powerfmt", 214 | ] 215 | 216 | [[package]] 217 | name = "digest" 218 | version = "0.10.7" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 221 | dependencies = [ 222 | "block-buffer", 223 | "crypto-common", 224 | "subtle", 225 | ] 226 | 227 | [[package]] 228 | name = "endian-type" 229 | version = "0.1.2" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" 232 | 233 | [[package]] 234 | name = "enum-as-inner" 235 | version = "0.3.4" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" 238 | dependencies = [ 239 | "heck 0.4.1", 240 | "proc-macro2", 241 | "quote", 242 | "syn 1.0.109", 243 | ] 244 | 245 | [[package]] 246 | name = "form_urlencoded" 247 | version = "1.2.1" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 250 | dependencies = [ 251 | "percent-encoding", 252 | ] 253 | 254 | [[package]] 255 | name = "futures" 256 | version = "0.3.30" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" 259 | dependencies = [ 260 | "futures-channel", 261 | "futures-core", 262 | "futures-executor", 263 | "futures-io", 264 | "futures-sink", 265 | "futures-task", 266 | "futures-util", 267 | ] 268 | 269 | [[package]] 270 | name = "futures-channel" 271 | version = "0.3.30" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 274 | dependencies = [ 275 | "futures-core", 276 | "futures-sink", 277 | ] 278 | 279 | [[package]] 280 | name = "futures-core" 281 | version = "0.3.30" 282 | source = "registry+https://github.com/rust-lang/crates.io-index" 283 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 284 | 285 | [[package]] 286 | name = "futures-executor" 287 | version = "0.3.30" 288 | source = "registry+https://github.com/rust-lang/crates.io-index" 289 | checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" 290 | dependencies = [ 291 | "futures-core", 292 | "futures-task", 293 | "futures-util", 294 | ] 295 | 296 | [[package]] 297 | name = "futures-io" 298 | version = "0.3.30" 299 | source = "registry+https://github.com/rust-lang/crates.io-index" 300 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 301 | 302 | [[package]] 303 | name = "futures-macro" 304 | version = "0.3.30" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" 307 | dependencies = [ 308 | "proc-macro2", 309 | "quote", 310 | "syn 2.0.75", 311 | ] 312 | 313 | [[package]] 314 | name = "futures-sink" 315 | version = "0.3.30" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" 318 | 319 | [[package]] 320 | name = "futures-task" 321 | version = "0.3.30" 322 | source = "registry+https://github.com/rust-lang/crates.io-index" 323 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 324 | 325 | [[package]] 326 | name = "futures-util" 327 | version = "0.3.30" 328 | source = "registry+https://github.com/rust-lang/crates.io-index" 329 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 330 | dependencies = [ 331 | "futures-channel", 332 | "futures-core", 333 | "futures-io", 334 | "futures-macro", 335 | "futures-sink", 336 | "futures-task", 337 | "memchr", 338 | "pin-project-lite", 339 | "pin-utils", 340 | "slab", 341 | ] 342 | 343 | [[package]] 344 | name = "generic-array" 345 | version = "0.14.7" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 348 | dependencies = [ 349 | "typenum", 350 | "version_check", 351 | ] 352 | 353 | [[package]] 354 | name = "getrandom" 355 | version = "0.2.15" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 358 | dependencies = [ 359 | "cfg-if", 360 | "libc", 361 | "wasi", 362 | ] 363 | 364 | [[package]] 365 | name = "gimli" 366 | version = "0.29.0" 367 | source = "registry+https://github.com/rust-lang/crates.io-index" 368 | checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" 369 | 370 | [[package]] 371 | name = "heck" 372 | version = "0.3.3" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 375 | dependencies = [ 376 | "unicode-segmentation", 377 | ] 378 | 379 | [[package]] 380 | name = "heck" 381 | version = "0.4.1" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 384 | 385 | [[package]] 386 | name = "hermit-abi" 387 | version = "0.1.19" 388 | source = "registry+https://github.com/rust-lang/crates.io-index" 389 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 390 | dependencies = [ 391 | "libc", 392 | ] 393 | 394 | [[package]] 395 | name = "hermit-abi" 396 | version = "0.3.9" 397 | source = "registry+https://github.com/rust-lang/crates.io-index" 398 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 399 | 400 | [[package]] 401 | name = "hmac" 402 | version = "0.12.1" 403 | source = "registry+https://github.com/rust-lang/crates.io-index" 404 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 405 | dependencies = [ 406 | "digest", 407 | ] 408 | 409 | [[package]] 410 | name = "hostname" 411 | version = "0.3.1" 412 | source = "registry+https://github.com/rust-lang/crates.io-index" 413 | checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" 414 | dependencies = [ 415 | "libc", 416 | "match_cfg", 417 | "winapi", 418 | ] 419 | 420 | [[package]] 421 | name = "iana-time-zone" 422 | version = "0.1.60" 423 | source = "registry+https://github.com/rust-lang/crates.io-index" 424 | checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" 425 | dependencies = [ 426 | "android_system_properties", 427 | "core-foundation-sys", 428 | "iana-time-zone-haiku", 429 | "js-sys", 430 | "wasm-bindgen", 431 | "windows-core", 432 | ] 433 | 434 | [[package]] 435 | name = "iana-time-zone-haiku" 436 | version = "0.1.2" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" 439 | dependencies = [ 440 | "cc", 441 | ] 442 | 443 | [[package]] 444 | name = "idna" 445 | version = "0.2.3" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 448 | dependencies = [ 449 | "matches", 450 | "unicode-bidi", 451 | "unicode-normalization", 452 | ] 453 | 454 | [[package]] 455 | name = "idna" 456 | version = "0.5.0" 457 | source = "registry+https://github.com/rust-lang/crates.io-index" 458 | checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" 459 | dependencies = [ 460 | "unicode-bidi", 461 | "unicode-normalization", 462 | ] 463 | 464 | [[package]] 465 | name = "instant" 466 | version = "0.1.13" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" 469 | dependencies = [ 470 | "cfg-if", 471 | ] 472 | 473 | [[package]] 474 | name = "ipconfig" 475 | version = "0.2.2" 476 | source = "registry+https://github.com/rust-lang/crates.io-index" 477 | checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" 478 | dependencies = [ 479 | "socket2 0.3.19", 480 | "widestring", 481 | "winapi", 482 | "winreg", 483 | ] 484 | 485 | [[package]] 486 | name = "ipnet" 487 | version = "2.9.0" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" 490 | 491 | [[package]] 492 | name = "js-sys" 493 | version = "0.3.70" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" 496 | dependencies = [ 497 | "wasm-bindgen", 498 | ] 499 | 500 | [[package]] 501 | name = "lazy_static" 502 | version = "1.5.0" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 505 | 506 | [[package]] 507 | name = "libc" 508 | version = "0.2.158" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" 511 | 512 | [[package]] 513 | name = "linked-hash-map" 514 | version = "0.5.6" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" 517 | 518 | [[package]] 519 | name = "lock_api" 520 | version = "0.4.12" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 523 | dependencies = [ 524 | "autocfg", 525 | "scopeguard", 526 | ] 527 | 528 | [[package]] 529 | name = "log" 530 | version = "0.4.22" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" 533 | 534 | [[package]] 535 | name = "lru-cache" 536 | version = "0.1.2" 537 | source = "registry+https://github.com/rust-lang/crates.io-index" 538 | checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" 539 | dependencies = [ 540 | "linked-hash-map", 541 | ] 542 | 543 | [[package]] 544 | name = "match_cfg" 545 | version = "0.1.0" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" 548 | 549 | [[package]] 550 | name = "matches" 551 | version = "0.1.10" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" 554 | 555 | [[package]] 556 | name = "memchr" 557 | version = "2.7.4" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 560 | 561 | [[package]] 562 | name = "miniz_oxide" 563 | version = "0.7.4" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" 566 | dependencies = [ 567 | "adler", 568 | ] 569 | 570 | [[package]] 571 | name = "mio" 572 | version = "1.0.2" 573 | source = "registry+https://github.com/rust-lang/crates.io-index" 574 | checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" 575 | dependencies = [ 576 | "hermit-abi 0.3.9", 577 | "libc", 578 | "wasi", 579 | "windows-sys", 580 | ] 581 | 582 | [[package]] 583 | name = "nibble_vec" 584 | version = "0.1.0" 585 | source = "registry+https://github.com/rust-lang/crates.io-index" 586 | checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" 587 | dependencies = [ 588 | "smallvec", 589 | ] 590 | 591 | [[package]] 592 | name = "num-conv" 593 | version = "0.1.0" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" 596 | 597 | [[package]] 598 | name = "num-traits" 599 | version = "0.2.19" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 602 | dependencies = [ 603 | "autocfg", 604 | ] 605 | 606 | [[package]] 607 | name = "object" 608 | version = "0.36.3" 609 | source = "registry+https://github.com/rust-lang/crates.io-index" 610 | checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" 611 | dependencies = [ 612 | "memchr", 613 | ] 614 | 615 | [[package]] 616 | name = "once_cell" 617 | version = "1.19.0" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 620 | 621 | [[package]] 622 | name = "parking_lot" 623 | version = "0.11.2" 624 | source = "registry+https://github.com/rust-lang/crates.io-index" 625 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 626 | dependencies = [ 627 | "instant", 628 | "lock_api", 629 | "parking_lot_core 0.8.6", 630 | ] 631 | 632 | [[package]] 633 | name = "parking_lot" 634 | version = "0.12.3" 635 | source = "registry+https://github.com/rust-lang/crates.io-index" 636 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 637 | dependencies = [ 638 | "lock_api", 639 | "parking_lot_core 0.9.10", 640 | ] 641 | 642 | [[package]] 643 | name = "parking_lot_core" 644 | version = "0.8.6" 645 | source = "registry+https://github.com/rust-lang/crates.io-index" 646 | checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" 647 | dependencies = [ 648 | "cfg-if", 649 | "instant", 650 | "libc", 651 | "redox_syscall 0.2.16", 652 | "smallvec", 653 | "winapi", 654 | ] 655 | 656 | [[package]] 657 | name = "parking_lot_core" 658 | version = "0.9.10" 659 | source = "registry+https://github.com/rust-lang/crates.io-index" 660 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 661 | dependencies = [ 662 | "cfg-if", 663 | "libc", 664 | "redox_syscall 0.5.3", 665 | "smallvec", 666 | "windows-targets", 667 | ] 668 | 669 | [[package]] 670 | name = "percent-encoding" 671 | version = "2.3.1" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 674 | 675 | [[package]] 676 | name = "pin-project-lite" 677 | version = "0.2.14" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" 680 | 681 | [[package]] 682 | name = "pin-utils" 683 | version = "0.1.0" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 686 | 687 | [[package]] 688 | name = "powerfmt" 689 | version = "0.2.0" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" 692 | 693 | [[package]] 694 | name = "ppv-lite86" 695 | version = "0.2.20" 696 | source = "registry+https://github.com/rust-lang/crates.io-index" 697 | checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" 698 | dependencies = [ 699 | "zerocopy", 700 | ] 701 | 702 | [[package]] 703 | name = "proc-macro-error" 704 | version = "1.0.4" 705 | source = "registry+https://github.com/rust-lang/crates.io-index" 706 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 707 | dependencies = [ 708 | "proc-macro-error-attr", 709 | "proc-macro2", 710 | "quote", 711 | "syn 1.0.109", 712 | "version_check", 713 | ] 714 | 715 | [[package]] 716 | name = "proc-macro-error-attr" 717 | version = "1.0.4" 718 | source = "registry+https://github.com/rust-lang/crates.io-index" 719 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 720 | dependencies = [ 721 | "proc-macro2", 722 | "quote", 723 | "version_check", 724 | ] 725 | 726 | [[package]] 727 | name = "proc-macro2" 728 | version = "1.0.86" 729 | source = "registry+https://github.com/rust-lang/crates.io-index" 730 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" 731 | dependencies = [ 732 | "unicode-ident", 733 | ] 734 | 735 | [[package]] 736 | name = "quick-error" 737 | version = "1.2.3" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 740 | 741 | [[package]] 742 | name = "quote" 743 | version = "1.0.36" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 746 | dependencies = [ 747 | "proc-macro2", 748 | ] 749 | 750 | [[package]] 751 | name = "radix_trie" 752 | version = "0.2.1" 753 | source = "registry+https://github.com/rust-lang/crates.io-index" 754 | checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" 755 | dependencies = [ 756 | "endian-type", 757 | "nibble_vec", 758 | ] 759 | 760 | [[package]] 761 | name = "rand" 762 | version = "0.8.5" 763 | source = "registry+https://github.com/rust-lang/crates.io-index" 764 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 765 | dependencies = [ 766 | "libc", 767 | "rand_chacha", 768 | "rand_core", 769 | ] 770 | 771 | [[package]] 772 | name = "rand_chacha" 773 | version = "0.3.1" 774 | source = "registry+https://github.com/rust-lang/crates.io-index" 775 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 776 | dependencies = [ 777 | "ppv-lite86", 778 | "rand_core", 779 | ] 780 | 781 | [[package]] 782 | name = "rand_core" 783 | version = "0.6.4" 784 | source = "registry+https://github.com/rust-lang/crates.io-index" 785 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 786 | dependencies = [ 787 | "getrandom", 788 | ] 789 | 790 | [[package]] 791 | name = "redox_syscall" 792 | version = "0.2.16" 793 | source = "registry+https://github.com/rust-lang/crates.io-index" 794 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 795 | dependencies = [ 796 | "bitflags 1.3.2", 797 | ] 798 | 799 | [[package]] 800 | name = "redox_syscall" 801 | version = "0.5.3" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" 804 | dependencies = [ 805 | "bitflags 2.6.0", 806 | ] 807 | 808 | [[package]] 809 | name = "resolv-conf" 810 | version = "0.7.0" 811 | source = "registry+https://github.com/rust-lang/crates.io-index" 812 | checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" 813 | dependencies = [ 814 | "hostname", 815 | "quick-error", 816 | ] 817 | 818 | [[package]] 819 | name = "rustc-demangle" 820 | version = "0.1.24" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" 823 | 824 | [[package]] 825 | name = "scopeguard" 826 | version = "1.2.0" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 829 | 830 | [[package]] 831 | name = "serde" 832 | version = "1.0.208" 833 | source = "registry+https://github.com/rust-lang/crates.io-index" 834 | checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" 835 | dependencies = [ 836 | "serde_derive", 837 | ] 838 | 839 | [[package]] 840 | name = "serde_derive" 841 | version = "1.0.208" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" 844 | dependencies = [ 845 | "proc-macro2", 846 | "quote", 847 | "syn 2.0.75", 848 | ] 849 | 850 | [[package]] 851 | name = "sha2" 852 | version = "0.10.8" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" 855 | dependencies = [ 856 | "cfg-if", 857 | "cpufeatures", 858 | "digest", 859 | ] 860 | 861 | [[package]] 862 | name = "shlex" 863 | version = "1.3.0" 864 | source = "registry+https://github.com/rust-lang/crates.io-index" 865 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 866 | 867 | [[package]] 868 | name = "signal-hook-registry" 869 | version = "1.4.2" 870 | source = "registry+https://github.com/rust-lang/crates.io-index" 871 | checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" 872 | dependencies = [ 873 | "libc", 874 | ] 875 | 876 | [[package]] 877 | name = "slab" 878 | version = "0.4.9" 879 | source = "registry+https://github.com/rust-lang/crates.io-index" 880 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 881 | dependencies = [ 882 | "autocfg", 883 | ] 884 | 885 | [[package]] 886 | name = "smallvec" 887 | version = "1.13.2" 888 | source = "registry+https://github.com/rust-lang/crates.io-index" 889 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 890 | 891 | [[package]] 892 | name = "socket2" 893 | version = "0.3.19" 894 | source = "registry+https://github.com/rust-lang/crates.io-index" 895 | checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" 896 | dependencies = [ 897 | "cfg-if", 898 | "libc", 899 | "winapi", 900 | ] 901 | 902 | [[package]] 903 | name = "socket2" 904 | version = "0.5.7" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" 907 | dependencies = [ 908 | "libc", 909 | "windows-sys", 910 | ] 911 | 912 | [[package]] 913 | name = "strsim" 914 | version = "0.8.0" 915 | source = "registry+https://github.com/rust-lang/crates.io-index" 916 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 917 | 918 | [[package]] 919 | name = "structopt" 920 | version = "0.3.26" 921 | source = "registry+https://github.com/rust-lang/crates.io-index" 922 | checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" 923 | dependencies = [ 924 | "clap", 925 | "lazy_static", 926 | "structopt-derive", 927 | ] 928 | 929 | [[package]] 930 | name = "structopt-derive" 931 | version = "0.4.18" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" 934 | dependencies = [ 935 | "heck 0.3.3", 936 | "proc-macro-error", 937 | "proc-macro2", 938 | "quote", 939 | "syn 1.0.109", 940 | ] 941 | 942 | [[package]] 943 | name = "subtle" 944 | version = "2.6.1" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" 947 | 948 | [[package]] 949 | name = "syn" 950 | version = "1.0.109" 951 | source = "registry+https://github.com/rust-lang/crates.io-index" 952 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 953 | dependencies = [ 954 | "proc-macro2", 955 | "quote", 956 | "unicode-ident", 957 | ] 958 | 959 | [[package]] 960 | name = "syn" 961 | version = "2.0.75" 962 | source = "registry+https://github.com/rust-lang/crates.io-index" 963 | checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" 964 | dependencies = [ 965 | "proc-macro2", 966 | "quote", 967 | "unicode-ident", 968 | ] 969 | 970 | [[package]] 971 | name = "tdns-cli" 972 | version = "0.0.5" 973 | dependencies = [ 974 | "anyhow", 975 | "async-trait", 976 | "chrono", 977 | "data-encoding", 978 | "digest", 979 | "futures", 980 | "hmac", 981 | "once_cell", 982 | "rand", 983 | "sha2", 984 | "structopt", 985 | "tokio", 986 | "trust-dns-client", 987 | "trust-dns-resolver", 988 | ] 989 | 990 | [[package]] 991 | name = "textwrap" 992 | version = "0.11.0" 993 | source = "registry+https://github.com/rust-lang/crates.io-index" 994 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 995 | dependencies = [ 996 | "unicode-width", 997 | ] 998 | 999 | [[package]] 1000 | name = "thiserror" 1001 | version = "1.0.63" 1002 | source = "registry+https://github.com/rust-lang/crates.io-index" 1003 | checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" 1004 | dependencies = [ 1005 | "thiserror-impl", 1006 | ] 1007 | 1008 | [[package]] 1009 | name = "thiserror-impl" 1010 | version = "1.0.63" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" 1013 | dependencies = [ 1014 | "proc-macro2", 1015 | "quote", 1016 | "syn 2.0.75", 1017 | ] 1018 | 1019 | [[package]] 1020 | name = "time" 1021 | version = "0.3.36" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" 1024 | dependencies = [ 1025 | "deranged", 1026 | "num-conv", 1027 | "powerfmt", 1028 | "serde", 1029 | "time-core", 1030 | ] 1031 | 1032 | [[package]] 1033 | name = "time-core" 1034 | version = "0.1.2" 1035 | source = "registry+https://github.com/rust-lang/crates.io-index" 1036 | checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" 1037 | 1038 | [[package]] 1039 | name = "tinyvec" 1040 | version = "1.8.0" 1041 | source = "registry+https://github.com/rust-lang/crates.io-index" 1042 | checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" 1043 | dependencies = [ 1044 | "tinyvec_macros", 1045 | ] 1046 | 1047 | [[package]] 1048 | name = "tinyvec_macros" 1049 | version = "0.1.1" 1050 | source = "registry+https://github.com/rust-lang/crates.io-index" 1051 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 1052 | 1053 | [[package]] 1054 | name = "tokio" 1055 | version = "1.39.3" 1056 | source = "registry+https://github.com/rust-lang/crates.io-index" 1057 | checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" 1058 | dependencies = [ 1059 | "backtrace", 1060 | "bytes", 1061 | "libc", 1062 | "mio", 1063 | "parking_lot 0.12.3", 1064 | "pin-project-lite", 1065 | "signal-hook-registry", 1066 | "socket2 0.5.7", 1067 | "tokio-macros", 1068 | "windows-sys", 1069 | ] 1070 | 1071 | [[package]] 1072 | name = "tokio-macros" 1073 | version = "2.4.0" 1074 | source = "registry+https://github.com/rust-lang/crates.io-index" 1075 | checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" 1076 | dependencies = [ 1077 | "proc-macro2", 1078 | "quote", 1079 | "syn 2.0.75", 1080 | ] 1081 | 1082 | [[package]] 1083 | name = "trust-dns-client" 1084 | version = "0.20.4" 1085 | source = "registry+https://github.com/rust-lang/crates.io-index" 1086 | checksum = "5b4ef9b9bde0559b78a4abb00339143750085f05e5a453efb7b8bef1061f09dc" 1087 | dependencies = [ 1088 | "cfg-if", 1089 | "data-encoding", 1090 | "futures-channel", 1091 | "futures-util", 1092 | "lazy_static", 1093 | "log", 1094 | "radix_trie", 1095 | "rand", 1096 | "thiserror", 1097 | "time", 1098 | "tokio", 1099 | "trust-dns-proto", 1100 | ] 1101 | 1102 | [[package]] 1103 | name = "trust-dns-proto" 1104 | version = "0.20.4" 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" 1106 | checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31" 1107 | dependencies = [ 1108 | "async-trait", 1109 | "cfg-if", 1110 | "data-encoding", 1111 | "enum-as-inner", 1112 | "futures-channel", 1113 | "futures-io", 1114 | "futures-util", 1115 | "idna 0.2.3", 1116 | "ipnet", 1117 | "lazy_static", 1118 | "log", 1119 | "rand", 1120 | "smallvec", 1121 | "thiserror", 1122 | "tinyvec", 1123 | "tokio", 1124 | "url", 1125 | ] 1126 | 1127 | [[package]] 1128 | name = "trust-dns-resolver" 1129 | version = "0.20.4" 1130 | source = "registry+https://github.com/rust-lang/crates.io-index" 1131 | checksum = "ecae383baad9995efaa34ce8e57d12c3f305e545887472a492b838f4b5cfb77a" 1132 | dependencies = [ 1133 | "cfg-if", 1134 | "futures-util", 1135 | "ipconfig", 1136 | "lazy_static", 1137 | "log", 1138 | "lru-cache", 1139 | "parking_lot 0.11.2", 1140 | "resolv-conf", 1141 | "smallvec", 1142 | "thiserror", 1143 | "tokio", 1144 | "trust-dns-proto", 1145 | ] 1146 | 1147 | [[package]] 1148 | name = "typenum" 1149 | version = "1.17.0" 1150 | source = "registry+https://github.com/rust-lang/crates.io-index" 1151 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" 1152 | 1153 | [[package]] 1154 | name = "unicode-bidi" 1155 | version = "0.3.15" 1156 | source = "registry+https://github.com/rust-lang/crates.io-index" 1157 | checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" 1158 | 1159 | [[package]] 1160 | name = "unicode-ident" 1161 | version = "1.0.12" 1162 | source = "registry+https://github.com/rust-lang/crates.io-index" 1163 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 1164 | 1165 | [[package]] 1166 | name = "unicode-normalization" 1167 | version = "0.1.23" 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" 1169 | checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" 1170 | dependencies = [ 1171 | "tinyvec", 1172 | ] 1173 | 1174 | [[package]] 1175 | name = "unicode-segmentation" 1176 | version = "1.11.0" 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" 1178 | checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" 1179 | 1180 | [[package]] 1181 | name = "unicode-width" 1182 | version = "0.1.13" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" 1185 | 1186 | [[package]] 1187 | name = "url" 1188 | version = "2.5.2" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" 1191 | dependencies = [ 1192 | "form_urlencoded", 1193 | "idna 0.5.0", 1194 | "percent-encoding", 1195 | ] 1196 | 1197 | [[package]] 1198 | name = "vec_map" 1199 | version = "0.8.2" 1200 | source = "registry+https://github.com/rust-lang/crates.io-index" 1201 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 1202 | 1203 | [[package]] 1204 | name = "version_check" 1205 | version = "0.9.5" 1206 | source = "registry+https://github.com/rust-lang/crates.io-index" 1207 | checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 1208 | 1209 | [[package]] 1210 | name = "wasi" 1211 | version = "0.11.0+wasi-snapshot-preview1" 1212 | source = "registry+https://github.com/rust-lang/crates.io-index" 1213 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1214 | 1215 | [[package]] 1216 | name = "wasm-bindgen" 1217 | version = "0.2.93" 1218 | source = "registry+https://github.com/rust-lang/crates.io-index" 1219 | checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" 1220 | dependencies = [ 1221 | "cfg-if", 1222 | "once_cell", 1223 | "wasm-bindgen-macro", 1224 | ] 1225 | 1226 | [[package]] 1227 | name = "wasm-bindgen-backend" 1228 | version = "0.2.93" 1229 | source = "registry+https://github.com/rust-lang/crates.io-index" 1230 | checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" 1231 | dependencies = [ 1232 | "bumpalo", 1233 | "log", 1234 | "once_cell", 1235 | "proc-macro2", 1236 | "quote", 1237 | "syn 2.0.75", 1238 | "wasm-bindgen-shared", 1239 | ] 1240 | 1241 | [[package]] 1242 | name = "wasm-bindgen-macro" 1243 | version = "0.2.93" 1244 | source = "registry+https://github.com/rust-lang/crates.io-index" 1245 | checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" 1246 | dependencies = [ 1247 | "quote", 1248 | "wasm-bindgen-macro-support", 1249 | ] 1250 | 1251 | [[package]] 1252 | name = "wasm-bindgen-macro-support" 1253 | version = "0.2.93" 1254 | source = "registry+https://github.com/rust-lang/crates.io-index" 1255 | checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" 1256 | dependencies = [ 1257 | "proc-macro2", 1258 | "quote", 1259 | "syn 2.0.75", 1260 | "wasm-bindgen-backend", 1261 | "wasm-bindgen-shared", 1262 | ] 1263 | 1264 | [[package]] 1265 | name = "wasm-bindgen-shared" 1266 | version = "0.2.93" 1267 | source = "registry+https://github.com/rust-lang/crates.io-index" 1268 | checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" 1269 | 1270 | [[package]] 1271 | name = "widestring" 1272 | version = "0.4.3" 1273 | source = "registry+https://github.com/rust-lang/crates.io-index" 1274 | checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" 1275 | 1276 | [[package]] 1277 | name = "winapi" 1278 | version = "0.3.9" 1279 | source = "registry+https://github.com/rust-lang/crates.io-index" 1280 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1281 | dependencies = [ 1282 | "winapi-i686-pc-windows-gnu", 1283 | "winapi-x86_64-pc-windows-gnu", 1284 | ] 1285 | 1286 | [[package]] 1287 | name = "winapi-i686-pc-windows-gnu" 1288 | version = "0.4.0" 1289 | source = "registry+https://github.com/rust-lang/crates.io-index" 1290 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1291 | 1292 | [[package]] 1293 | name = "winapi-x86_64-pc-windows-gnu" 1294 | version = "0.4.0" 1295 | source = "registry+https://github.com/rust-lang/crates.io-index" 1296 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1297 | 1298 | [[package]] 1299 | name = "windows-core" 1300 | version = "0.52.0" 1301 | source = "registry+https://github.com/rust-lang/crates.io-index" 1302 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 1303 | dependencies = [ 1304 | "windows-targets", 1305 | ] 1306 | 1307 | [[package]] 1308 | name = "windows-sys" 1309 | version = "0.52.0" 1310 | source = "registry+https://github.com/rust-lang/crates.io-index" 1311 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1312 | dependencies = [ 1313 | "windows-targets", 1314 | ] 1315 | 1316 | [[package]] 1317 | name = "windows-targets" 1318 | version = "0.52.6" 1319 | source = "registry+https://github.com/rust-lang/crates.io-index" 1320 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1321 | dependencies = [ 1322 | "windows_aarch64_gnullvm", 1323 | "windows_aarch64_msvc", 1324 | "windows_i686_gnu", 1325 | "windows_i686_gnullvm", 1326 | "windows_i686_msvc", 1327 | "windows_x86_64_gnu", 1328 | "windows_x86_64_gnullvm", 1329 | "windows_x86_64_msvc", 1330 | ] 1331 | 1332 | [[package]] 1333 | name = "windows_aarch64_gnullvm" 1334 | version = "0.52.6" 1335 | source = "registry+https://github.com/rust-lang/crates.io-index" 1336 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1337 | 1338 | [[package]] 1339 | name = "windows_aarch64_msvc" 1340 | version = "0.52.6" 1341 | source = "registry+https://github.com/rust-lang/crates.io-index" 1342 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1343 | 1344 | [[package]] 1345 | name = "windows_i686_gnu" 1346 | version = "0.52.6" 1347 | source = "registry+https://github.com/rust-lang/crates.io-index" 1348 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1349 | 1350 | [[package]] 1351 | name = "windows_i686_gnullvm" 1352 | version = "0.52.6" 1353 | source = "registry+https://github.com/rust-lang/crates.io-index" 1354 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1355 | 1356 | [[package]] 1357 | name = "windows_i686_msvc" 1358 | version = "0.52.6" 1359 | source = "registry+https://github.com/rust-lang/crates.io-index" 1360 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1361 | 1362 | [[package]] 1363 | name = "windows_x86_64_gnu" 1364 | version = "0.52.6" 1365 | source = "registry+https://github.com/rust-lang/crates.io-index" 1366 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1367 | 1368 | [[package]] 1369 | name = "windows_x86_64_gnullvm" 1370 | version = "0.52.6" 1371 | source = "registry+https://github.com/rust-lang/crates.io-index" 1372 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1373 | 1374 | [[package]] 1375 | name = "windows_x86_64_msvc" 1376 | version = "0.52.6" 1377 | source = "registry+https://github.com/rust-lang/crates.io-index" 1378 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1379 | 1380 | [[package]] 1381 | name = "winreg" 1382 | version = "0.6.2" 1383 | source = "registry+https://github.com/rust-lang/crates.io-index" 1384 | checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" 1385 | dependencies = [ 1386 | "winapi", 1387 | ] 1388 | 1389 | [[package]] 1390 | name = "zerocopy" 1391 | version = "0.7.35" 1392 | source = "registry+https://github.com/rust-lang/crates.io-index" 1393 | checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" 1394 | dependencies = [ 1395 | "byteorder", 1396 | "zerocopy-derive", 1397 | ] 1398 | 1399 | [[package]] 1400 | name = "zerocopy-derive" 1401 | version = "0.7.35" 1402 | source = "registry+https://github.com/rust-lang/crates.io-index" 1403 | checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" 1404 | dependencies = [ 1405 | "proc-macro2", 1406 | "quote", 1407 | "syn 2.0.75", 1408 | ] 1409 | --------------------------------------------------------------------------------