discovery

package
v0.0.0-...-eb0ccd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderGeneric is for generic IMAP providers
	ProviderGeneric = "GENERIC"
	// ProviderGMail is for GMail IMAP
	ProviderGMail = "GMAIL"
	// ProviderGoogleapps is for google apps (g-suite) IMAP
	ProviderGoogleapps = "GOOGLEAPPS"
	// ProviderMicrosoft is for Microsoft IMAP
	ProviderMicrosoft = "MICROSOFT"
	// ProviderYahoo is for Yahoo IMAP
	ProviderYahoo = "YAHOO"
	// ProviderAOL is for AOL IMAP
	ProviderAOL = "AOL"
	// ProviderApple is for Apple IMAP
	ProviderApple = "APPLE"
)
View Source
const DomainFormat = "http://autoconfig.%s/mail/config-v1.1.xml?emailaddress=%s"

DomainFormat is the generic domain autoconfig url format

View Source
const MozillaFormat = "https://autoconfig.thunderbird.net/v1.1/%s"

MozillaFormat is the mozilla endpoint for domain config

Variables

View Source
var AppleDocumentation = []ImapDocumentation{
	ImapDocumentation{
		Description: "Using app-specific passwords",
		URL:         "https://support.apple.com/en-us/HT204397",
	},
}

AppleDocumentation are some hard-coded documentation links for apple accounts

Functions

func DiscoverAllImapConfigs

func DiscoverAllImapConfigs(email string) (*[]Config, error)

DiscoverAllImapConfigs is an option that tries all of the approaches, returning a list of all successful discoveries.

Types

type Account

type Account struct {
	Protocols []Protocol `xml:"Protocol"`
}

Account is part of the AutoDiscover body

type AutoConfigResponse

type AutoConfigResponse struct {
	EmailProvider *EmailProvider `xml:"emailProvider"`
	Response      *Response      `xml:"Response"`
}

AutoConfigResponse is a parent struct used for parsing different response formats

type Config

type Config struct {
	Email         string              `json:"email"`
	Username      string              `json:"username"`
	Provider      string              `json:"provider"`
	Server        string              `json:"server"`
	Port          int                 `json:"port"`
	SSL           bool                `json:"ssl"`
	OAuth         bool                `json:"oauth"`
	Documentation []ImapDocumentation `json:"documentation"`
}

Config represents the IMAP Config response from this service

func ConvertAutoDiscoverResponse

func ConvertAutoDiscoverResponse(config *Response, username string, domain string) (*Config, error)

ConvertAutoDiscoverResponse parses the autodiscover response into an ImapConfig.

func ConvertClientConfigResponse

func ConvertClientConfigResponse(config *EmailProvider, username string, domain string) (*Config, error)

ConvertClientConfigResponse parses the client config response into an ImapConfig.

func DiscoverImapConfig

func DiscoverImapConfig(email string) (*Config, error)

DiscoverImapConfig is the library entrypoint! The options that are more likely to succeed are tried first. In order: Known Domain Configs, Domain Autoconfig endpoints, Mozilla Autoconfig information, and finally MX records for the domain itself

func GetAutoConfig

func GetAutoConfig(url string, username string, domain string) (*Config, error)

GetAutoConfig fetches the xml autoconfig info from a given url. It attempts to parse one of two supported formats, Autodiscover and clientConfig.

func GetDomainAutoConfig

func GetDomainAutoConfig(username string, domain string) (*Config, error)

GetDomainAutoConfig fetches the domain config information.

func GetKnownDomainConfig

func GetKnownDomainConfig(username string, domain string) (*Config, error)

GetKnownDomainConfig returns pre-defined configs for known domains

func GetMXRecord

func GetMXRecord(domain string, email string) (*Config, error)

GetMXRecord checks the MX records of a given domain and returns a config for known records

func GetMozillaAutoConfig

func GetMozillaAutoConfig(username string, domain string) (*Config, error)

GetMozillaAutoConfig fetches the mozilla default domain config information. https://developer.mozilla.org/en/Thunderbird/Autoconfiguration

type Documentation

type Documentation struct {
	URL  string              `xml:"url,attr"`
	Text []DocumentationText `xml:"descr"`
}

Documentation are the documentation links provided by the clientconfig info

type DocumentationText

type DocumentationText struct {
	Language string `xml:"lang,attr"`
	Text     string `xml:",chardata"`
}

DocumentationText is the localized text of a Documentation

type EmailProvider

type EmailProvider struct {
	ID              string           `xml:"id,attr"`
	IncomingServers []IncomingServer `xml:"incomingServer"`
	Documentation   []Documentation  `xml:"documentation"`
}

EmailProvider is the domain clientconfig provider type Response is the other supported domain response.

type ImapDocumentation

type ImapDocumentation struct {
	URL         string `json:"url"`
	Description string `json:"description"`
}

ImapDocumentation represents provided documentation

type IncomingServer

type IncomingServer struct {
	Type           string `xml:"type,attr"`
	Hostname       string `xml:"hostname"`
	Port           int    `xml:"port"`
	SocketType     string `xml:"socketType"`
	Username       string `xml:"username"`
	Authentication string `xml:"authentication"`
}

IncomingServer contains most of the useful domain clientconfig info

type Protocol

type Protocol struct {
	Type   string `xml:"Type"`
	Server string `xml:"Server"`
	Port   int    `xml:"Port"`
	SSL    string `xml:"SSL"`
}

Protocol is where all the useful info in an AutoDiscover response lies

type Response

type Response struct {
	Account Account `xml:"Account"`
}

Response is the domain AutoDiscover body. EmailProvider is the other supported domain response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL