├── Dig.alfredworkflow ├── Makefile ├── README.md ├── dig.sh ├── icon.png ├── icons ├── a.png ├── aaaa.png ├── afsdb.png ├── any.png ├── apl.png ├── axfr.png ├── caa.png ├── cert.png ├── cname.png ├── dhcid.png ├── dlv.png ├── dname.png ├── dnskey.png ├── ds.png ├── hip.png ├── ipseckey.png ├── ixfr.png ├── key.png ├── kx.png ├── loc.png ├── makeicons.sh ├── mx.png ├── naptr.png ├── ns.png ├── nsec.png ├── nsec3.png ├── nsec3param.png ├── opt.png ├── ptr.png ├── rp.png ├── rrsig.png ├── sig.png ├── soa.png ├── spf.png ├── srv.png ├── sshfp.png ├── ta.png ├── tkey.png ├── tlsa.png ├── tsig.png └── txt.png ├── info.plist ├── screenshots ├── 1.png ├── 2.png └── 3.png └── tests └── test_dig.sh /Dig.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/Dig.alfredworkflow -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EXTENSION = Dig.alfredworkflow 2 | BUNDLEID = pjkh.dig 3 | VERSION = 1.2 4 | SOURCE_FILES = dig.sh icon.png icons info.plist 5 | PKG_FILES = $(SOURCE_FILES) 6 | 7 | WORKFLOW_DIR = $(HOME)/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows 8 | INSTALL_DIR = `grep -l -- ">$(BUNDLEID)<" "$(WORKFLOW_DIR)"/*/info.plist | sed 's/\/info.plist//'` 9 | 10 | all: $(EXTENSION) 11 | 12 | $(EXTENSION): $(SOURCE_FILES) VERSION 13 | zip -rT $(EXTENSION) $(PKG_FILES) 14 | 15 | VERSION: 16 | touch info.plist 17 | 18 | clean: 19 | rm -rf $(EXTENSION) 20 | 21 | test: 22 | @roundup tests/test_* 23 | 24 | local-install: 25 | [[ -d "$(INSTALL_DIR)" ]] && cp -r $(PKG_FILES) "$(INSTALL_DIR)/" 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alfred Workflow - Dig 2 | 3 | A workflow for [Alfred](https://www.alfredapp.com/) to perform DNS lookups using [dig][dig] 4 | and optionally copy a specific result to the clipboard. 5 | 6 | ![Example 1](https://raw.github.com/phallstrom/AlfredDig/master/screenshots/1.png) 7 | 8 | ![Example 2](https://raw.github.com/phallstrom/AlfredDig/master/screenshots/2.png) 9 | 10 | ![Example 3](https://raw.github.com/phallstrom/AlfredDig/master/screenshots/3.png) 11 | 12 | ## Requirements 13 | 14 | - Alfred Version 2+. 15 | - The Alfred [Powerpack](http://www.alfredapp.com/powerpack/). 16 | - [Dig.alfredworkflow](https://raw.github.com/phallstrom/AlfredDig/master/Dig.alfredworkflow). 17 | 18 | ## Usage 19 | 20 | Type `dig` in Alfred and follow it's instructions. 21 | 22 | ## Help 23 | 24 | Having a problem? [Open an issue](https://github.com/phallstrom/AlfredDig/issues) and I'll see what I can do. 25 | 26 | ## Contributions & Thanks 27 | 28 | - aquadan 29 | - isometry 30 | 31 | ## License: 32 | 33 | (The MIT License) 34 | 35 | Copyright (c) 2013 Philip Hallstrom 36 | 37 | Permission is hereby granted, free of charge, to any person obtaining 38 | a copy of this software and associated documentation files (the 39 | 'Software'), to deal in the Software without restriction, including 40 | without limitation the rights to use, copy, modify, merge, publish, 41 | distribute, sublicense, and/or sell copies of the Software, and to 42 | permit persons to whom the Software is furnished to do so, subject to 43 | the following conditions: 44 | 45 | The above copyright notice and this permission notice shall be 46 | included in all copies or substantial portions of the Software. 47 | 48 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 49 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 50 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 51 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 52 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 53 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 54 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 55 | 56 | [dig]: https://en.wikipedia.org/wiki/Dig_(command) 57 | -------------------------------------------------------------------------------- /dig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo '' 4 | echo '' 5 | 6 | if [[ -z "$*" || ! "$*" =~ ^.*\ $ && ! "$*" =~ ^.*\ (any|a|aaaa|afsdb|apl|caa|cert|cname|dhcid|dlv|dname|dnskey|ds|hip|ipseckey|key|kx|loc|mx|naptr|ns|nsec|nsec3|nsec3param|ptr|rrsig|rp|sig|soa|spf|srv|sshfp|ta|tkey|tlsa|tsig|txt|axfr|ixfr|opt)$ ]] 7 | then 8 | 9 | echo "Keep typing…End your query with a space to initiate lookup. Optionally append a type such as 'mx'.icon.png" 10 | 11 | else 12 | 13 | read qdomain qtype <<< $* 14 | [[ -z "$qtype" ]] && qtype=a 15 | 16 | dig_opts='' 17 | if [[ "$qdomain" =~ ^([0-9\.]+|[0-9a-fA-F:]+)$ ]] 18 | then 19 | dig_opts="-x" 20 | qtype="ptr" 21 | fi 22 | 23 | while read line 24 | do 25 | answers_found='yes' 26 | # pjkh.com. 751 IN A 74.207.251.140 27 | # pjkh.com. 683 IN MX 10 mx2.emailsrvr.com. 28 | read question ttl class atype answer <<< $line 29 | 30 | [[ ! "$answer" =~ *\ * ]] && answer=${answer%.} 31 | title=$answer 32 | 33 | [[ "$atype" = "MX" ]] && answer=${answer#[0-9]*\ } 34 | 35 | if [[ -e "icons/$atype.png" ]] 36 | then 37 | icon="icons/$atype.png" 38 | subtitle="$question TTL=$ttl" 39 | else 40 | icon="" 41 | subtitle="$atype $question TTL=$ttl" 42 | fi 43 | 44 | 45 | echo "$title$subtitle$icon" 46 | 47 | done < <(dig $dig_opts $qdomain $qtype | sed -e '1,/^;; ANSWER SECTION/d' -e '/^$/,$d') 48 | 49 | if [[ -z "$answers_found" ]] 50 | then 51 | echo "No ResultsNo results found querying for $qdomain, type $qtype.icon.png" 52 | fi 53 | 54 | fi 55 | 56 | echo '' 57 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icon.png -------------------------------------------------------------------------------- /icons/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/a.png -------------------------------------------------------------------------------- /icons/aaaa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/aaaa.png -------------------------------------------------------------------------------- /icons/afsdb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/afsdb.png -------------------------------------------------------------------------------- /icons/any.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/any.png -------------------------------------------------------------------------------- /icons/apl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/apl.png -------------------------------------------------------------------------------- /icons/axfr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/axfr.png -------------------------------------------------------------------------------- /icons/caa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/caa.png -------------------------------------------------------------------------------- /icons/cert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/cert.png -------------------------------------------------------------------------------- /icons/cname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/cname.png -------------------------------------------------------------------------------- /icons/dhcid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/dhcid.png -------------------------------------------------------------------------------- /icons/dlv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/dlv.png -------------------------------------------------------------------------------- /icons/dname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/dname.png -------------------------------------------------------------------------------- /icons/dnskey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/dnskey.png -------------------------------------------------------------------------------- /icons/ds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/ds.png -------------------------------------------------------------------------------- /icons/hip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/hip.png -------------------------------------------------------------------------------- /icons/ipseckey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/ipseckey.png -------------------------------------------------------------------------------- /icons/ixfr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/ixfr.png -------------------------------------------------------------------------------- /icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/key.png -------------------------------------------------------------------------------- /icons/kx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/kx.png -------------------------------------------------------------------------------- /icons/loc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/loc.png -------------------------------------------------------------------------------- /icons/makeicons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for i in any a aaaa afsdb apl caa cert cname dhcid dlv dname dnskey ds hip ipseckey key kx loc mx naptr ns nsec nsec3 nsec3param ptr rrsig rp sig soa spf srv sshfp ta tkey tlsa tsig txt axfr ixfr opt 4 | do 5 | echo $i 6 | label="$(echo $i | tr [a-z] [A-Z])" 7 | convert -background transparent -fill '#666666' -size 128x128 -gravity center label:$label $i.png 8 | done 9 | 10 | -------------------------------------------------------------------------------- /icons/mx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/mx.png -------------------------------------------------------------------------------- /icons/naptr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/naptr.png -------------------------------------------------------------------------------- /icons/ns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/ns.png -------------------------------------------------------------------------------- /icons/nsec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/nsec.png -------------------------------------------------------------------------------- /icons/nsec3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/nsec3.png -------------------------------------------------------------------------------- /icons/nsec3param.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/nsec3param.png -------------------------------------------------------------------------------- /icons/opt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/opt.png -------------------------------------------------------------------------------- /icons/ptr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/ptr.png -------------------------------------------------------------------------------- /icons/rp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/rp.png -------------------------------------------------------------------------------- /icons/rrsig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/rrsig.png -------------------------------------------------------------------------------- /icons/sig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/sig.png -------------------------------------------------------------------------------- /icons/soa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/soa.png -------------------------------------------------------------------------------- /icons/spf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/spf.png -------------------------------------------------------------------------------- /icons/srv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/srv.png -------------------------------------------------------------------------------- /icons/sshfp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/sshfp.png -------------------------------------------------------------------------------- /icons/ta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/ta.png -------------------------------------------------------------------------------- /icons/tkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/tkey.png -------------------------------------------------------------------------------- /icons/tlsa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/tlsa.png -------------------------------------------------------------------------------- /icons/tsig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/tsig.png -------------------------------------------------------------------------------- /icons/txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/icons/txt.png -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | pjkh.dig 7 | connections 8 | 9 | 8901B669-3C82-4B63-99EC-00C8185D4952 10 | 11 | 12 | destinationuid 13 | 05A3ACCF-091F-4CBF-84E9-65C15EB74A7C 14 | modifiers 15 | 0 16 | modifiersubtext 17 | 18 | 19 | 20 | 21 | createdby 22 | Philip Hallstrom 23 | description 24 | Perform DNS lookups using dig. 25 | disabled 26 | 27 | name 28 | Dig 29 | objects 30 | 31 | 32 | config 33 | 34 | argumenttype 35 | 0 36 | escaping 37 | 63 38 | keyword 39 | dig 40 | runningsubtext 41 | Looking up DNS records... 42 | script 43 | bash ./dig.sh {query} 44 | subtext 45 | Lookup DNS records. Select result to copy to clipboard. 46 | title 47 | Dig 48 | type 49 | 0 50 | withspace 51 | 52 | 53 | type 54 | alfred.workflow.input.scriptfilter 55 | uid 56 | 8901B669-3C82-4B63-99EC-00C8185D4952 57 | 58 | 59 | config 60 | 61 | autopaste 62 | 63 | clipboardtext 64 | {query} 65 | 66 | type 67 | alfred.workflow.output.clipboard 68 | uid 69 | 05A3ACCF-091F-4CBF-84E9-65C15EB74A7C 70 | 71 | 72 | readme 73 | 74 | uidata 75 | 76 | 05A3ACCF-091F-4CBF-84E9-65C15EB74A7C 77 | 78 | ypos 79 | 160 80 | 81 | 8901B669-3C82-4B63-99EC-00C8185D4952 82 | 83 | ypos 84 | 160 85 | 86 | 87 | webaddress 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/screenshots/1.png -------------------------------------------------------------------------------- /screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/screenshots/2.png -------------------------------------------------------------------------------- /screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phallstrom/AlfredDig/257590bd4a36664c17333cb9780c6b11a7d9e718/screenshots/3.png -------------------------------------------------------------------------------- /tests/test_dig.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env roundup 2 | 3 | describe "dig" 4 | 5 | it_does_nothing_with_no_argument() { 6 | result=$(bash dig.sh) 7 | [[ "$result" =~ uid=.dig_keep_typing ]] 8 | } 9 | 10 | it_does_nothing_with_blank_argument() { 11 | result=$(bash dig.sh '') 12 | [[ "$result" =~ uid=.dig_keep_typing ]] 13 | } 14 | 15 | it_does_nothing_with_single_word() { 16 | result=$(bash dig.sh 'pjkh') 17 | [[ "$result" =~ uid=.dig_keep_typing ]] 18 | } 19 | 20 | it_does_nothing_with_invalid_type() { 21 | result=$(bash dig.sh 'pjkh.com foo') 22 | [[ "$result" =~ uid=.dig_keep_typing ]] 23 | } 24 | 25 | it_queries_if_ends_with_space() { 26 | result=$(bash dig.sh 'pjkh.com ') 27 | [[ "$result" =~ uid=.dig_answer ]] 28 | } 29 | 30 | it_queries_if_ends_with_valid_type() { 31 | result=$(bash dig.sh 'pjkh.com mx') 32 | [[ "$result" =~ uid=.dig_answer ]] 33 | } 34 | 35 | it_notifies_about_no_results() { 36 | result=$(bash dig.sh 'nonexistent.pjkh.com a') 37 | [[ "$result" =~ uid=.dig_no_results ]] 38 | } 39 | 40 | it_reverse_lookups_ipv4_address() { 41 | result=$(bash dig.sh '127.0.0.1 ') 42 | [[ "$result" =~ uid=.dig_answer ]] 43 | [[ "$result" =~ ptr.png ]] 44 | [[ "$result" =~ title.localhost ]] 45 | } 46 | 47 | it_reverse_lookups_ipv6_address() { 48 | result=$(bash dig.sh '::1 ') 49 | [[ "$result" =~ uid=.dig_answer ]] 50 | [[ "$result" =~ ptr.png ]] 51 | [[ "$result" =~ title.localhost ]] 52 | } 53 | 54 | it_strips_priority_from_mx_records() { 55 | result=$(bash dig.sh 'pjkh.com mx') 56 | [[ "$result" =~ uid=.dig_answer ]] 57 | [[ "$result" =~ arg=\'mx2.emailsrvr.com\' ]] 58 | [[ "$result" =~ title.10\ mx2.emailsrvr.com ]] 59 | } 60 | 61 | --------------------------------------------------------------------------------