Skip to content

Commit

Permalink
Add Raw text support to SPF TXT field.
Browse files Browse the repository at this point in the history
  • Loading branch information
nzlosh committed May 15, 2018
1 parent 3741e5a commit 9bc9e09
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added


### Changed

### Removed

## [0.0.1] - 2018-05-15
### Added
- Added Raw Text configuration option. It can be used to insert raw text into the SPF TXT field
before any domain resolution occurs.

### Changed


### Removed
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ version: spf1
domain: domain.example
spfmaxchars: 500
policy: "~all"
rawtxt: "include:anotherdomain.example"
ipv4:
- 127.0.0.1/8
ipv6:
Expand All @@ -39,6 +40,7 @@ redirect: []
| `version` | string | The spf version string, `spf1` is the current version as of writing. |
| `domain` | string | The name of the domain to be used when generating include directives. (normally the owners domain) |
| `spfmaxchars` | integer | The maximum number of characters an SPF TXT record may contain before another is created. |
| `rawtxt` | string | Insert raw text into the SPF TXT record before any name resolution is performed. |
| `policy` | string | The SPF policy to be used when generating the SPF TXT records. |
| `ipv4` | list of strings | IPv4 addresses in CIDR notation to be included. |
| `ipv6` | list of strings | IPv6 addresses in CIDR notation to be included. |
Expand Down
6 changes: 2 additions & 4 deletions spf_packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
Version string
Domain string
SpfMaxChars int
Rawtxt string
Policy string
Ipv4 []string
Ipv6 []string
Expand Down Expand Up @@ -111,9 +112,6 @@ func expandFields(result []string) []string {
p := "a:"
if strings.HasPrefix(field, p) {
ips := resolveA(field[len(p):])
//~ for _, ip := range ips {
//~ fmt.Printf("a:%s/32\n", ip)
//~ }
spf_set = append(spf_set, ips...)
continue
}
Expand Down Expand Up @@ -160,7 +158,7 @@ func outputSpfText(result []string, cfg *Config) {
suffix := "a"
include_spf := "include:spf_" + suffix + "." + domain
spf_records := []string{}
current_record := "v=" + cfg.Version
current_record := "v=" + cfg.Version + " " + cfg.Rawtxt
spf_max_chars := cfg.SpfMaxChars

for i, record := range result {
Expand Down

0 comments on commit 9bc9e09

Please sign in to comment.