Documentation
¶
Index ¶
- type Config
- type Database
- type SQLDatabase
- func (db SQLDatabase) ClearTables() error
- func (db SQLDatabase) DomainsToValidate() ([]string, error)
- func (db SQLDatabase) GetAllScans(domain string) ([]models.Scan, error)
- func (db SQLDatabase) GetDomain(domain string, state models.DomainState) (models.Domain, error)
- func (db SQLDatabase) GetDomains(state models.DomainState) ([]models.Domain, error)
- func (db *SQLDatabase) GetHostnameScan(hostname string) (checker.HostnameResult, error)
- func (db SQLDatabase) GetLatestScan(domain string) (models.Scan, error)
- func (db SQLDatabase) GetMTASTSDomains() ([]models.Domain, error)
- func (db *SQLDatabase) GetStats(source string) (stats.Series, error)
- func (db *SQLDatabase) GetTokenByDomain(domain string) (string, error)
- func (db SQLDatabase) HostnamesForDomain(domain string) ([]string, error)
- func (db SQLDatabase) IsBlacklistedEmail(email string) (bool, error)
- func (db *SQLDatabase) PutAggregatedScan(a checker.AggregatedScan) error
- func (db SQLDatabase) PutBlacklistedEmail(email string, reason string, timestamp string) error
- func (db *SQLDatabase) PutDomain(domain models.Domain) error
- func (db *SQLDatabase) PutHostnameScan(hostname string, result checker.HostnameResult) error
- func (db *SQLDatabase) PutLocalStats(date time.Time) (checker.AggregatedScan, error)
- func (db *SQLDatabase) PutScan(scan models.Scan) error
- func (db *SQLDatabase) PutToken(domain string) (models.Token, error)
- func (db SQLDatabase) RemoveDomain(domain string, state models.DomainState) (models.Domain, error)
- func (db SQLDatabase) SetStatus(domain string, state models.DomainState) error
- func (db *SQLDatabase) UseToken(tokenStr string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Port string DbHost string DbName string DbUsername string DbPass string DbTokenTable string DbScanTable string DbDomainTable string }
Config is a configuration struct for a Database.
func LoadEnvironmentVariables ¶
LoadEnvironmentVariables loads relevant environment variables into a Config object.
type Database ¶
type Database interface { // Puts new scandata for domain PutScan(models.Scan) error // Retrieves most recent scandata for domain GetLatestScan(string) (models.Scan, error) // Retrieves all scandata for domain GetAllScans(string) ([]models.Scan, error) // Gets the token for a domain GetTokenByDomain(string) (string, error) // Creates a token in the db PutToken(string) (models.Token, error) // Uses a token in the db UseToken(string) (string, error) // Adds a bounce or complaint notification to the email blacklist. PutBlacklistedEmail(email string, reason string, timestamp string) error // Returns true if we've blacklisted an email. IsBlacklistedEmail(string) (bool, error) // Retrieves a hostname scan for a particular hostname GetHostnameScan(string) (checker.HostnameResult, error) // Enters a hostname scan. PutHostnameScan(string, checker.HostnameResult) error // Writes an aggregated scan to the database PutAggregatedScan(checker.AggregatedScan) error // Caches stats for the 14 days preceding time.Time PutLocalStats(time.Time) (checker.AggregatedScan, error) // Gets counts per day of hosts supporting MTA-STS for a given source. GetStats(string) (stats.Series, error) // Upserts domain state. PutDomain(models.Domain) error // Retrieves state of a domain GetDomain(string, models.DomainState) (models.Domain, error) // Retrieves all domains in a particular state. GetDomains(models.DomainState) ([]models.Domain, error) SetStatus(string, models.DomainState) error RemoveDomain(string, models.DomainState) (models.Domain, error) ClearTables() error }
Database interface: These are the things that the Database should be able to do. Slightly more limited than CRUD for all the schemas.
type SQLDatabase ¶
type SQLDatabase struct {
// contains filtered or unexported fields
}
SQLDatabase is a Database interface backed by postgresql.
func InitSQLDatabase ¶
func InitSQLDatabase(cfg Config) (*SQLDatabase, error)
InitSQLDatabase creates a DB connection based on information in a Config, and returns a pointer the resulting SQLDatabase object. If connection fails, returns an error.
func (SQLDatabase) ClearTables ¶
func (db SQLDatabase) ClearTables() error
ClearTables nukes all the tables. ** Should only be used during testing **
func (SQLDatabase) DomainsToValidate ¶
func (db SQLDatabase) DomainsToValidate() ([]string, error)
DomainsToValidate [interface Validator] retrieves domains from the DB whose policies should be validated.
func (SQLDatabase) GetAllScans ¶
func (db SQLDatabase) GetAllScans(domain string) ([]models.Scan, error)
GetAllScans retrieves all the scans performed for a particular domain.
func (SQLDatabase) GetDomain ¶
func (db SQLDatabase) GetDomain(domain string, state models.DomainState) (models.Domain, error)
GetDomain retrieves the status and information associated with a particular mailserver domain.
func (SQLDatabase) GetDomains ¶
func (db SQLDatabase) GetDomains(state models.DomainState) ([]models.Domain, error)
GetDomains retrieves all the domains which match a particular state, that are not in MTA_STS mode
func (*SQLDatabase) GetHostnameScan ¶
func (db *SQLDatabase) GetHostnameScan(hostname string) (checker.HostnameResult, error)
GetHostnameScan retrives most recent scan from database.
func (SQLDatabase) GetLatestScan ¶
func (db SQLDatabase) GetLatestScan(domain string) (models.Scan, error)
GetLatestScan retrieves the most recent scan performed on a particular email domain.
func (SQLDatabase) GetMTASTSDomains ¶
func (db SQLDatabase) GetMTASTSDomains() ([]models.Domain, error)
GetMTASTSDomains retrieves domains which wish their policy to be queued with their MTASTS.
func (*SQLDatabase) GetStats ¶
func (db *SQLDatabase) GetStats(source string) (stats.Series, error)
GetStats returns statistics about a MTA-STS adoption from a single source domains to check.
func (*SQLDatabase) GetTokenByDomain ¶
func (db *SQLDatabase) GetTokenByDomain(domain string) (string, error)
GetTokenByDomain gets the token for a domain name.
func (SQLDatabase) HostnamesForDomain ¶
func (db SQLDatabase) HostnamesForDomain(domain string) ([]string, error)
HostnamesForDomain [interface Validator] retrieves the hostname policy for a particular domain.
func (SQLDatabase) IsBlacklistedEmail ¶
func (db SQLDatabase) IsBlacklistedEmail(email string) (bool, error)
IsBlacklistedEmail returns true iff we've blacklisted the passed email address for sending.
func (*SQLDatabase) PutAggregatedScan ¶
func (db *SQLDatabase) PutAggregatedScan(a checker.AggregatedScan) error
PutAggregatedScan writes and AggregatedScan to the db.
func (SQLDatabase) PutBlacklistedEmail ¶
func (db SQLDatabase) PutBlacklistedEmail(email string, reason string, timestamp string) error
PutBlacklistedEmail adds a bounce or complaint notification to the email blacklist.
func (*SQLDatabase) PutDomain ¶
func (db *SQLDatabase) PutDomain(domain models.Domain) error
PutDomain inserts a particular domain into the database. If the domain does not yet exist in the database, we initialize it with StateUnconfirmed If there is already a domain in the database with StateUnconfirmed, performs an update of the fields.
func (*SQLDatabase) PutHostnameScan ¶
func (db *SQLDatabase) PutHostnameScan(hostname string, result checker.HostnameResult) error
PutHostnameScan puts this scan into the database.
func (*SQLDatabase) PutLocalStats ¶
func (db *SQLDatabase) PutLocalStats(date time.Time) (checker.AggregatedScan, error)
PutLocalStats writes aggregated stats for the 14 days preceding `date` to the aggregated_stats table.
func (*SQLDatabase) PutScan ¶
func (db *SQLDatabase) PutScan(scan models.Scan) error
PutScan inserts a new scan for a particular domain into the database.
func (*SQLDatabase) PutToken ¶
func (db *SQLDatabase) PutToken(domain string) (models.Token, error)
PutToken generates and inserts a token into the database for a particular domain, and returns the resulting token row.
func (SQLDatabase) RemoveDomain ¶
func (db SQLDatabase) RemoveDomain(domain string, state models.DomainState) (models.Domain, error)
RemoveDomain removes a particular domain and returns it.
func (SQLDatabase) SetStatus ¶
func (db SQLDatabase) SetStatus(domain string, state models.DomainState) error
SetStatus sets the status of a particular domain object to |state|.