From 852b710585e65bc259dc6fe44e43f64cb9d13a4a Mon Sep 17 00:00:00 2001 From: Bradley Kemp Date: Sun, 23 May 2021 18:10:31 +0100 Subject: [PATCH] Export the slice of WHOIS/SharedHosting matchers --- matchers/shared_hosting.go | 8 ++++---- matchers/types.go | 6 +++--- matchers/whois_matchers.go | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/matchers/shared_hosting.go b/matchers/shared_hosting.go index a7a13a2..58e6ead 100644 --- a/matchers/shared_hosting.go +++ b/matchers/shared_hosting.go @@ -9,9 +9,9 @@ import ( // If this matches, these contact details should be preferred over the // registrar and hosting provider. func IsSharedHostingProvider(u *url.URL) (bool, ProviderContact) { - for _, m := range sharedHostMatchers { - if m.matches(u.Host) { - return true, m.contact + for _, m := range SharedHosts { + if m.Matches(u.Host) { + return true, m.Contact } } return false, nil @@ -21,7 +21,7 @@ func IsSharedHostingProvider(u *url.URL) (bool, ProviderContact) { // is not served by the domain/server owner. // // Try to keep this sorted alphabetically by ProviderName -var sharedHostMatchers = []matcher{ +var SharedHosts = []Matcher{ {OnlineForm{"000webhost", "https://www.000webhost.com/report-abuse"}, isSubDomainOf("000webhost.com", "000webhostapp.com")}, {AbuseEmail{"Adobe", "hellospark@adobe.com"}, isSubDomainOf("spark.adobe.com")}, {OnlineForm{"Bitly", "https://bitly.is/reporting-abuse"}, isSubDomainOf("bit.ly")}, diff --git a/matchers/types.go b/matchers/types.go index ce4035e..3e3aed5 100644 --- a/matchers/types.go +++ b/matchers/types.go @@ -40,7 +40,7 @@ func (m ProviderName) Name() string { return string(m) } -type matcher struct { - contact ProviderContact - matches func(string) bool +type Matcher struct { + Contact ProviderContact + Matches func(string) bool } diff --git a/matchers/whois_matchers.go b/matchers/whois_matchers.go index 9bd3a31..c0b94de 100644 --- a/matchers/whois_matchers.go +++ b/matchers/whois_matchers.go @@ -8,7 +8,7 @@ import ( // Matches WHOIS data to the best way to report abuse to the registrar/hosting provider. // // Try to keep this sorted alphabetically by ProviderName -var whoisMatchers = []matcher{ +var WHOIS = []Matcher{ {OnlineForm{"Cloudflare", "https://www.cloudflare.com/abuse/form"}, whoisContains("abuse@cloudflare.com")}, {OnlineForm{"Digital Ocean", "https://www.digitalocean.com/company/contact/#abuse"}, whoisContains("descr: Digital Ocean, Inc.")}, {OnlineForm{"Dynadot", "https://www.dynadot.com/report_abuse.html"}, whoisContains("abuse@dynadot.com")}, @@ -39,13 +39,13 @@ func getContactsFromWHOIS(query string) ([]ProviderContact, error) { } var contacts []ProviderContact - for _, m := range whoisMatchers { - if m.matches(string(rawWhois)) { - contacts = append(contacts, m.contact) + for _, m := range WHOIS { + if m.Matches(string(rawWhois)) { + contacts = append(contacts, m.Contact) } } - // One of the whoisMatchers matched so return that info + // One of the WHOIS matched so return that info if len(contacts) > 0 { return contacts, nil }