dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

dmarc (1115B)


      1 #!/bin/sh
      2 
      3 tr -d '\r' | xml2tsv | tr -d ' ' | awk -F"\t" '
      4 $1 == "/feedback/record/row/policy_evaluated/disposition" {disposition=$NF}
      5 $1 == "/feedback/record/row/policy_evaluated/dkim" {dkimstat=$NF}
      6 $1 == "/feedback/record/row/policy_evaluated/spf" {spfstat=$NF}
      7 $1 == "/feedback/record/identifiers/header_from" {hfrom=$NF}
      8 $1 == "/feedback/report_metadata/date_range/begin" {begindate=$NF}
      9 $1 == "/feedback/report_metadata/date_range/end" {enddate=$NF}
     10 $1 == "/feedback/record/row/source_ip" {ip=$NF}
     11 $1 == "/feedback/record/row/count" {count=$NF}
     12 
     13 function colourise(str) {
     14 	if (str == "fail" || str == "reject")
     15 		colour = 160
     16 	if (str == "quarantine")
     17 		colour = 136
     18 	if (str == "pass")
     19 		colour = 28
     20 	printf("\x1b[38;5;%dm%s\x1b[0m", colour, str)
     21 }
     22 
     23 END {
     24 	begindatef = strftime("%b %d %Y", begindate)
     25 	enddatef   = strftime("%b %d %Y", enddate)
     26 
     27 	printf("%s - %s\n\n", begindatef, enddatef)
     28 	printf("\"From\":\t%s\n", hfrom)
     29 	printf("IP:\t%s (x%d)\n", ip, count)
     30 	printf("DKIM:\t")
     31 	colourise(dkimstat)
     32 	printf("\nSPF:\t")
     33 	colourise(spfstat)
     34 	printf("\nAction:\t")
     35 	colourise(disposition)
     36 	printf("\n")
     37 }'