Skip to content

Commit

Permalink
Capture list of MTA-STS domains
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrown608 committed Mar 7, 2019
1 parent a8f20d4 commit 3a6d3d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions checker/totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type DomainTotals struct {
Source string
Attempted int
Connected int // Connected to at least one mx
MTASTSTesting int
MTASTSEnforce int
MTASTSTesting []string
MTASTSEnforce []string
}

// Add the result of a single domain check to aggregated stats.
Expand All @@ -37,9 +37,9 @@ func (t *DomainTotals) HandleDomain(r DomainResult) {
if r.MTASTSResult != nil {
switch r.MTASTSResult.Mode {
case "enforce":
t.MTASTSEnforce += 1
t.MTASTSEnforce = append(t.MTASTSEnforce, r.Domain)
case "testing":
t.MTASTSTesting += 1
t.MTASTSTesting = append(t.MTASTSTesting, r.Domain)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions checker/totals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func TestCheckCSV(t *testing.T) {
checkMTASTSOverride: mockCheckMTASTS,
}
totals := DomainTotals{}
c.CheckCSV(reader, &totals)
c.CheckCSV(reader, &totals, 0)

if totals.Attempted != 6 {
t.Errorf("Expected 6 attempted connections, got %d", totals.Attempted)
}
if totals.Connected != 4 {
t.Errorf("Expected 4 successfully connecting domains, got %d", totals.Connected)
}
if totals.MTASTSTesting != 4 {
t.Errorf("Expected 4 domains in MTA-STS testing mode, got %d", totals.MTASTSTesting)
if len(totals.MTASTSTesting) != 4 {
t.Errorf("Expected 4 domains in MTA-STS testing mode, got %d", len(totals.MTASTSTesting))
}
}
2 changes: 1 addition & 1 deletion db/sqldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,6 @@ func (db *SQLDatabase) PutHostnameScan(hostname string, result checker.HostnameR

func (db *SQLDatabase) PutDomainTotals(totals checker.DomainTotals) error {
_, err := db.conn.Exec("INSERT INTO domain_totals(time, source, attempted, connected, mta_sts_testing, mta_sts_enforce) VALUES($1, $2, $3, $4, $5, $6)",
totals.Time, totals.Source, totals.Attempted, totals.Connected, totals.MTASTSTesting, totals.MTASTSEnforce)
totals.Time, totals.Source, totals.Attempted, totals.Connected, len(totals.MTASTSTesting), len(totals.MTASTSEnforce))
return err
}
4 changes: 2 additions & 2 deletions db/sqldb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ func TestPutDomainTotals(t *testing.T) {
Source: "Tom's Domain Emporium",
Attempted: 1000000000,
Connected: 10000,
MTASTSTesting: 1000,
MTASTSEnforce: 1000,
MTASTSTesting: []string{"a.com", "b.com", "c.com"},
MTASTSEnforce: []string{"d.com", "e.com", "f.com"},
}
err := database.PutDomainTotals(totals)
if err != nil {
Expand Down

0 comments on commit 3a6d3d0

Please sign in to comment.