mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-06 08:06:53 +08:00
Compress TXT metrics.status.sslip.io: 508 → 431
The TXT response to the query `metrics.status.sslip.io` was doomed to exceed the UDP 512-byte limit, which would have forced the client to re-attempt via TCP, and our server doesn't yet bind to TCP. This commit fixes that by squeezing the packet. We haven't dropped any information, but we made it more succinct. Per [Infoblox](https://www.infoblox.com/dns-security-resource-center/dns-security-faq/is-dns-tcp-or-udp-port-53/): > when the message size exceeds 512 bytes, it will trigger the ‘TC’ bit (Truncation) in DNS to be set, informing the client that the message length has exceeded the allowed size. In these situations, the client needs to re-transmit over TCP
This commit is contained in:
@@ -146,9 +146,6 @@ var _ = Describe("IntegrationMetrics", func() {
|
||||
expectedMetrics.AnsweredTXTDelKvQueries++
|
||||
expectedMetrics = bumpExpectedToAccountForMetricsQuery(expectedMetrics)
|
||||
actualMetrics = digAndGetMetrics("@localhost delete.key.k-v.io txt +short -p " + strconv.Itoa(port))
|
||||
fmt.Println()
|
||||
fmt.Println(expectedMetrics)
|
||||
fmt.Println(actualMetrics)
|
||||
Expect(expectedMetrics.MostlyEquals(actualMetrics)).To(BeTrue())
|
||||
|
||||
// PTR version.sslip.io updates .Queries, .AnsweredQueries, .AnsweredPTRQueriesIPv4
|
||||
@@ -206,28 +203,24 @@ func getMetrics() (m xip.Metrics) {
|
||||
var uptime int
|
||||
var junk string
|
||||
_, err = fmt.Sscanf(string(stdout),
|
||||
"\"Uptime (seconds): %d\"\n"+
|
||||
"\"Key-value store: %s\n"+ // %s "swallows" the double-quote at the end
|
||||
"\"Uptime: %d\"\n"+
|
||||
"\"KV Store: %s\n"+ // %s "swallows" the double-quote at the end
|
||||
"\"Blocklist: %s %s %s\n"+
|
||||
"\"Queries: %d\"\n"+
|
||||
"\"Queries/second: %s\n"+
|
||||
"\"AnsQueries: %d\"\n"+
|
||||
"\"AnsQueries/second: %s\n"+
|
||||
"\"AnsA: %d\"\n"+
|
||||
"\"AnsAAAA: %d\"\n"+
|
||||
"\"Source IP TXT: %d\"\n"+
|
||||
"\"Version TXT: %d\"\n"+
|
||||
"\"Key-Value TXT GET/PUT/DEL: %d/%d/%d\"\n"+
|
||||
"\"Queries: %d (%s\n"+ // %s "swallows" the `/s"` at the end
|
||||
"\"Answered Queries: %d (%s\n"+ // %s "swallows" the `/s"` at the end
|
||||
"\"A: %d\"\n"+
|
||||
"\"AAAA: %d\"\n"+
|
||||
"\"TXT Source: %d\"\n"+
|
||||
"\"TXT Version: %d\"\n"+
|
||||
"\"TXT KV GET/PUT/DEL: %d/%d/%d\"\n"+
|
||||
"\"PTR IPv4/IPv6: %d/%d\"\n"+
|
||||
"\"DNS-01 challenge: %d\"\n"+
|
||||
"\"NS DNS-01: %d\"\n"+
|
||||
"\"Blocked: %d\"\n",
|
||||
&uptime,
|
||||
&junk,
|
||||
&junk, &junk, &junk,
|
||||
&m.Queries,
|
||||
&junk,
|
||||
&m.AnsweredQueries,
|
||||
&junk,
|
||||
&m.Queries, &junk,
|
||||
&m.AnsweredQueries, &junk,
|
||||
&m.AnsweredAQueries,
|
||||
&m.AnsweredAAAAQueries,
|
||||
&m.AnsweredTXTSrcIPQueries,
|
||||
|
@@ -910,27 +910,25 @@ func metricsSslipIo(x *Xip, _ net.IP) (txtResources []dnsmessage.TXTResource, er
|
||||
<-x.DnsAmplificationAttackDelay
|
||||
var metrics []string
|
||||
uptime := time.Since(x.Metrics.Start)
|
||||
metrics = append(metrics, fmt.Sprintf("Uptime (seconds): %.0f", uptime.Seconds()))
|
||||
metrics = append(metrics, fmt.Sprintf("Uptime: %.0f", uptime.Seconds()))
|
||||
keyValueStore := "etcd"
|
||||
if x.isEtcdNil() {
|
||||
keyValueStore = "builtin"
|
||||
}
|
||||
metrics = append(metrics, "Key-value store: "+keyValueStore)
|
||||
metrics = append(metrics, "KV Store: "+keyValueStore)
|
||||
metrics = append(metrics, fmt.Sprintf("Blocklist: %s %d,%d",
|
||||
x.BlocklistUpdated.Format("2006-01-02 15:04:05-07"),
|
||||
len(x.BlocklistStrings),
|
||||
len(x.BlocklistCDIRs)))
|
||||
metrics = append(metrics, fmt.Sprintf("Queries: %d", x.Metrics.Queries))
|
||||
metrics = append(metrics, fmt.Sprintf("Queries/second: %.1f", float64(x.Metrics.Queries)/uptime.Seconds()))
|
||||
metrics = append(metrics, fmt.Sprintf("AnsQueries: %d", x.Metrics.AnsweredQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("AnsQueries/second: %.1f", float64(x.Metrics.AnsweredQueries)/uptime.Seconds()))
|
||||
metrics = append(metrics, fmt.Sprintf("AnsA: %d", x.Metrics.AnsweredAQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("AnsAAAA: %d", x.Metrics.AnsweredAAAAQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("Source IP TXT: %d", x.Metrics.AnsweredTXTSrcIPQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("Version TXT: %d", x.Metrics.AnsweredTXTVersionQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("Key-Value TXT GET/PUT/DEL: %d/%d/%d", x.Metrics.AnsweredTXTGetKvQueries, x.Metrics.AnsweredTXTPutKvQueries, x.Metrics.AnsweredTXTDelKvQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("Queries: %d (%.1f/s)", x.Metrics.Queries, float64(x.Metrics.Queries)/uptime.Seconds()))
|
||||
metrics = append(metrics, fmt.Sprintf("Answered Queries: %d (%.1f/s)", x.Metrics.AnsweredQueries, float64(x.Metrics.AnsweredQueries)/uptime.Seconds()))
|
||||
metrics = append(metrics, fmt.Sprintf("A: %d", x.Metrics.AnsweredAQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("AAAA: %d", x.Metrics.AnsweredAAAAQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("TXT Source: %d", x.Metrics.AnsweredTXTSrcIPQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("TXT Version: %d", x.Metrics.AnsweredTXTVersionQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("TXT KV GET/PUT/DEL: %d/%d/%d", x.Metrics.AnsweredTXTGetKvQueries, x.Metrics.AnsweredTXTPutKvQueries, x.Metrics.AnsweredTXTDelKvQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("PTR IPv4/IPv6: %d/%d", x.Metrics.AnsweredPTRQueriesIPv4, x.Metrics.AnsweredPTRQueriesIPv6))
|
||||
metrics = append(metrics, fmt.Sprintf("DNS-01 challenge: %d", x.Metrics.AnsweredNSDNS01ChallengeQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("NS DNS-01: %d", x.Metrics.AnsweredNSDNS01ChallengeQueries))
|
||||
metrics = append(metrics, fmt.Sprintf("Blocked: %d", x.Metrics.AnsweredBlockedQueries))
|
||||
for _, metric := range metrics {
|
||||
txtResources = append(txtResources, dnsmessage.TXTResource{TXT: []string{metric}})
|
||||
|
Reference in New Issue
Block a user