Skip to content

Instantly share code, notes, and snippets.

@llasram
Created November 30, 2013 21:31
Show Gist options
  • Save llasram/7724741 to your computer and use it in GitHub Desktop.
Save llasram/7724741 to your computer and use it in GitHub Desktop.
(defn parse-nx
"Parse & filter raw NX records. Truncate QNAMEs to E2LDs."
[[sensor rest]]
(ignore-errors
(am/domonad am/maybe-m
[:when (not (v-sensor? sensor))
[ts client domain :as fields] (str/split rest #"\t" 3)
:when (valid-fields? 3 fields)
ts (Long/parseLong ts 10)
domain (flat/domain-e2ld @etlds domain)
oplab (-> domain dns/domain-labels first)
:when (interesting? oplab domain)
[ipv iph :as fields] (str/split client #":")
:when (valid-fields? 2 fields)
ipv (Long/parseLong ipv 10)
iph (Long/parseLong iph 16)]
[oplab ts [sensor ipv iph] domain])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment