https://github.com/trailofbits/spf-query
Ruby SPF Parser
https://github.com/trailofbits/spf-query
dns email sender-policy-framework spf
Last synced: 9 months ago
JSON representation
Ruby SPF Parser
- Host: GitHub
- URL: https://github.com/trailofbits/spf-query
- Owner: trailofbits
- License: mit
- Created: 2014-11-20T22:30:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-09-12T16:14:45.000Z (over 1 year ago)
- Last Synced: 2025-09-16T22:40:38.910Z (9 months ago)
- Topics: dns, email, sender-policy-framework, spf
- Language: Ruby
- Homepage:
- Size: 88.9 KB
- Stars: 30
- Watchers: 40
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE.txt
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# spf-query
[](https://codeclimate.com/github/trailofbits/spf-query)
[](https://codeclimate.com/github/trailofbits/spf-query)
[](https://travis-ci.org/trailofbits/spf-query)
The `spf-query` library searches the [SPF] records for a host. We assume the
host uses standard spf 'selectors', and also check if they use their own
'selector'.
## Features
* Queries and parses SPF records.
* Supports querying both TXT and SPF records.
## Examples
require 'spf/query'
SPF::Query::Record.query('twitter.com')
# => #
SPF::Query::Record.parse("v=spf1 ip4:199.16.156.0/22 ip4:199.59.148.0/22 ip4:8.25.194.0/23 ip4:8.25.196.0/23 ip4:204.92.114.203 ip4:204.92.114.204/31 ip4:107.20.52.15 ip4:23.21.83.90 include:_spf.google.com include:_thirdparty.twitter.com -all")
# => #
## Synopsis
Query a domain:
spf-query google.com
____________________________
SPF record search for google.com
- found SPF record for google.com at google.com:
v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all
____________________________
Query multiple domains:
spf-query trailofbits.com facebook.com yahoo.com
____________________________
SPF record search for trailofbits.com
- found SPF record for trailofbits.com at trailofbits.com:
v=spf1 include:_spf.google.com ~all
____________________________
____________________________
SPF record search for facebook.com
- found SPF record for facebook.com at facebook.com:
v=spf1 redirect=_spf.facebook.com
____________________________
____________________________
SPF record search for yahoo.com
- found SPF record for yahoo.com at yahoo.com:
v=spf1 redirect=_spf.mail.yahoo.com
____________________________
## Requirements
* [ruby] >= 1.9.1
* [parslet] ~> 1.0
## Install
$ gem install spf-query
## License
See the {file:LICENSE.txt} file.
[ruby]: https://www.ruby-lang.org/
[parslet]: http://kschiess.github.io/parslet/
[SPF]: https://tools.ietf.org/html/rfc7208