Skip to content

Commit f1e9f8b

Browse files
committed
feat: round TTL flag
1 parent b25213c commit f1e9f8b

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

README.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,28 @@ All long form (--) flags can be toggled with the dig-standard +[no]flag notation
3636
Application Options:
3737
-q, --qname= Query name
3838
-s, --server= DNS server(s)
39-
-t, --type= RR type (e.g. A, AAAA, MX, etc.) or type
40-
integer
39+
-t, --type= RR type (e.g. A, AAAA, MX, etc.) or type integer
4140
-x, --reverse Reverse lookup
4241
-d, --dnssec Set the DO (DNSSEC OK) bit in the OPT record
4342
-n, --nsid Set EDNS0 NSID opt
4443
--subnet= Set EDNS0 client subnet
4544
-c, --chaos Use CHAOS query class
46-
-C= Set query class (default: IN 0x01) (default:
47-
1)
45+
-C= Set query class (default: IN 0x01) (default: 1)
4846
-p, --odoh-proxy= ODoH proxy
4947
--timeout= Query timeout (default: 10s)
5048
--pad Set EDNS0 padding
5149
--http3 Use HTTP/3 for DoH
5250
--id-check Check DNS response ID (default: true)
53-
--reuse-conn Reuse connections across queries to the same
54-
server (default: true)
51+
--reuse-conn Reuse connections across queries to the same server (default: true)
5552
--txtconcat Concatenate TXT responses
5653
--qid= Set query ID (-1 for random) (default: -1)
5754
-b, --bootstrap-server= DNS server to use for bootstrapping
5855
--bootstrap-timeout= Bootstrapping timeout (default: 5s)
5956
--cookie= EDNS0 cookie
6057
--recaxfr Perform recursive AXFR
61-
-f, --format= Output format (pretty, column, json, yaml,
62-
raw) (default: pretty)
63-
--pretty-ttls Format TTLs in human readable format
64-
(default: true)
65-
--short-ttls Remove zero components of pretty TTLs.
66-
(24h0m0s->24h) (default: true)
58+
-f, --format= Output format (pretty, column, json, yaml, raw) (default: pretty)
59+
--pretty-ttls Format TTLs in human readable format (default: true)
60+
--short-ttls Remove zero components of pretty TTLs. (24h0m0s->24h) (default: true)
6761
--color Enable color output
6862
--question Show question section
6963
--answer Show answer section (default: true)
@@ -73,13 +67,12 @@ Application Options:
7367
--all Show all sections and statistics
7468
-w Resolve ASN/ASName for A and AAAA records
7569
-r, --short Show record values only
76-
-R, --resolve-ips Resolve PTR records for IP addresses in A and
77-
AAAA records
70+
-R, --resolve-ips Resolve PTR records for IP addresses in A and AAAA records
71+
--round-ttls Round TTLs to the nearest minute
7872
--aa Set AA (Authoritative Answer) flag in query
7973
--ad Set AD (Authentic Data) flag in query
8074
--cd Set CD (Checking Disabled) flag in query
81-
--rd Set RD (Recursion Desired) flag in query
82-
(default: true)
75+
--rd Set RD (Recursion Desired) flag in query (default: true)
8376
--ra Set RA (Recursion Available) flag in query
8477
--z Set Z (Zero) flag in query
8578
--t Set TC (Truncated) flag in query
@@ -97,15 +90,12 @@ Application Options:
9790
--http-method= HTTP method (default: GET)
9891
--pmtud PMTU discovery (default: true)
9992
--quic-alpn-tokens= QUIC ALPN tokens (default: doq, doq-i11)
100-
--quic-length-prefix Add RFC 9250 compliant length prefix
101-
(default: true)
93+
--quic-length-prefix Add RFC 9250 compliant length prefix (default: true)
10294
--dnscrypt-tcp Use TCP for DNSCrypt (default UDP)
103-
--dnscrypt-udp-size= Maximum size of a DNS response this client
104-
can sent or receive (default: 0)
95+
--dnscrypt-udp-size= Maximum size of a DNS response this client can sent or receive (default: 0)
10596
--dnscrypt-key= DNSCrypt public key
10697
--dnscrypt-provider= DNSCrypt provider name
107-
--default-rr-types= Default record types (default: A, AAAA, NS,
108-
MX, TXT, CNAME)
98+
--default-rr-types= Default record types (default: A, AAAA, NS, MX, TXT, CNAME)
10999
--udp-buffer= Set EDNS0 UDP size in query (default: 1232)
110100
-v, --verbose Show verbose log messages
111101
--trace Show trace log messages

cli/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Flags struct {
5050
Whois bool `short:"w" description:"Resolve ASN/ASName for A and AAAA records"`
5151
ValueOnly bool `short:"r" long:"short" description:"Show record values only"`
5252
ResolveIPs bool `short:"R" long:"resolve-ips" description:"Resolve PTR records for IP addresses in A and AAAA records"`
53+
RoundTTLs bool `long:"round-ttls" description:"Round TTLs to the nearest minute"`
5354

5455
// Header flags
5556
AuthoritativeAnswer bool `long:"aa" description:"Set AA (Authoritative Answer) flag in query"`

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,15 @@ All long form (--) flags can be toggled with the dig-standard +[no]flag notation
449449
}
450450
}
451451

452+
// Round TTL
453+
if opts.RoundTTLs {
454+
for _, reply := range replies {
455+
for _, rr := range reply.Answer {
456+
rr.Header().Ttl = rr.Header().Ttl - (rr.Header().Ttl % 60)
457+
}
458+
}
459+
}
460+
452461
entries = append(entries, &output.Entry{
453462
Queries: msgs,
454463
Replies: replies,

0 commit comments

Comments
 (0)