{"id":13581920,"url":"https://github.com/pd/srvaddr","last_synced_at":"2026-05-09T16:48:11.282Z","repository":{"id":66371632,"uuid":"59309354","full_name":"pd/srvaddr","owner":"pd","description":"Simple SRV record querying from the CLI","archived":false,"fork":false,"pushed_at":"2016-05-23T18:36:22.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T21:37:56.788Z","etag":null,"topics":["command-line","dns","docker-image","golang","srv-record"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-20T16:26:20.000Z","updated_at":"2022-08-10T08:02:06.000Z","dependencies_parsed_at":"2023-03-14T01:45:38.806Z","dependency_job_id":null,"html_url":"https://github.com/pd/srvaddr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pd/srvaddr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pd%2Fsrvaddr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pd%2Fsrvaddr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pd%2Fsrvaddr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pd%2Fsrvaddr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pd","download_url":"https://codeload.github.com/pd/srvaddr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pd%2Fsrvaddr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278547821,"owners_count":26004775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","dns","docker-image","golang","srv-record"],"created_at":"2024-08-01T15:02:19.259Z","updated_at":"2025-10-06T02:10:57.046Z","avatar_url":"https://github.com/pd.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# srvaddr\n\nSmall command-line utility for querying SRV DNS records and rendering the results into a template\nor an easily manipulated JSON structure.\n\n## Installation\n\nThe usual:\n\n    $ go get -u github.com/pd/srvaddr\n    $ go install github.com/pd/srvaddr\n    \nYou can download binaries from the [Github Releases][]:\n\n    $ curl -o srvaddr https://github.com/pd/srvaddr/releases/download/v0.1/srvaddr_linux_amd64 \u0026\u0026 \\\n        chmod +x ./srvaddr \u0026\u0026 \\\n        ./srvaddr -h\n\nAlternatively, it's available as a [docker image][]:\n\n    $ docker run philodespotos/srvaddr _xmpp-server._tcp.google.com\n    xmpp-server.l.google.com:5269\n    alt1.xmpp-server.l.google.com:5269\n    alt2.xmpp-server.l.google.com:5269\n    alt3.xmpp-server.l.google.com:5269\n    alt4.xmpp-server.l.google.com:5269\n\n## Examples\n\nThe default template simply lists the hostname(s) and port(s) returned for the given query:\n\n    $ srvaddr _frontend._tcp.tld\n    box2.example.com:1234\n    box3.example.com:7654\n    box1.example.com:9876\n\nThe results are displayed in no particular order.\n\n\u003e NB: Nothing I use in practice actually populates the priority or weight values in SRV\n\u003e records, but the results should _probably_ be sorted based on those.\n\nTo lookup multiple services at once, the default unlabeled output is ambiguous. You can label\neach service and use the \"env-style\" template:\n\n    $ srvaddr ZK=_zookeeper._tcp.service.consul MQ=_rabbit._tcp.service.consul\n    ZK_ADDR0=spof.node.dc1.consul:2181\n    ZK_HOST0=spof.node.dc1.consul\n    ZK_PORT0=2181\n    ZK_ADDR1=spof.node.dc1.consul:2181\n    ZK_HOST1=spof.node.dc1.consul\n    ZK_PORT1=2181\n    MQ_ADDR0=spof.node.dc1.consul:5672\n    MQ_HOST0=spof.node.dc1.consul\n    MQ_PORT0=5672\n\nUnder the hood, the output formats are all just defined with [text/template][]. You can use\na custom template with `-t filename` (with `-` representing stdin, as usual):\n\n    $ echo '{{with index .db 0}}database port is {{.Port}}{{end}}' | \\\n        srvaddr -t - db=_postgres._tcp.internal\n    database port is 16273\n\nGo's templating can be unwieldy at times. You can just emit JSON, maybe pipe it into [jq][]:\n\n    $ srvaddr -json zk=_zookeeper._tcp.service.consul | jq .\n    {\n      \"zk\": [\n        {\n          \"Host\": \"deadbeef.node.dc1.consul.\",\n          \"IP\": \"10.2.2.2\",\n          \"Port\": 2181\n        },\n        {\n          \"Host\": \"beadfeed.node.dc1.consul.\",\n          \"IP\": \"10.1.1.1\",\n          \"Port\": 2181\n        }\n      ]\n    }\n\nNot all DNS servers will return the additional `A` records necessary for the IP\nto be known; favor using the hostname, which is part of the SRV record itself,\nwhenever possible.\n\nBy default, `srvaddr` uses a nameserver from `resolv.conf`; to use a different nameserver:\n\n    $ srvaddr -ns 127.0.0.1:8600 _kafka._tcp.service.consul\n\n## Development\n\nI'll probably write tests at some point. Setting up the mocks was too distracting early on.\nMeanwhile, a fairly low friction way of serving up some SRV records is to run consul locally.\nHere's a minimal example config:\n\n~~~json\n{\n  \"server\": true,\n  \"bootstrap_expect\": 1,\n  \"log_level\": \"debug\",\n  \"services\": [\n    { \"id\": \"zk1\", \"name\": \"zk\", \"address\": \"10.1.1.1\", \"port\": 2181 },\n    { \"id\": \"zk2\", \"name\": \"zk\", \"address\": \"10.2.2.2\", \"port\": 2181 },\n    { \"name\": \"api\", \"address\": \"10.3.3.3\", \"port\": 443 },\n    { \"name\": \"mq\", \"address\": \"127.0.0.1\", \"port\": 5672 }\n  ]\n}\n~~~\n\n[Github Releases]: https://github.com/pd/srvaddr/releases\n[docker image]: https://hub.docker.com/r/philodespotos/srvaddr/\n[text/template]: https://godoc.org/pkg/text/template\n[jq]: https://stedolan.github.io/jq/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpd%2Fsrvaddr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpd%2Fsrvaddr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpd%2Fsrvaddr/lists"}