Discovery
in package
Provides a service to discover the addressbooks for a CardDAV account.
It implements the discovery using the mechanisms specified in RFC 6764, which is based on DNS SRV/TXT records and/or well-known URI redirection on the server.
Tags
Table of Contents
- KNOWN_SERVERS = ["gmail.com" => "www.googleapis.com", "googlemail.com" => "www.googleapis.com"]
- Some builtins for public providers that don't have discovery properly set up.
- discoverAddressbooks() : array<int, AddressbookCollection>
- Discover the addressbooks for a CardDAV account.
- discoverContextPath() : array<string|int, string>
- Provides a list of URIs to check for discovering the location of the CardDAV service.
- discoverServers() : array<string|int, mixed>
- Discovers the CardDAV service for the given domain using DNS SRV lookups.
- orderDnsRecords() : int
- Orders DNS records by their prio and weight.
Constants
KNOWN_SERVERS
Some builtins for public providers that don't have discovery properly set up.
private
array<string, string>
KNOWN_SERVERS
= ["gmail.com" => "www.googleapis.com", "googlemail.com" => "www.googleapis.com"]
It maps a domain name that is part of the typically used usernames to a working discovery URI. This allows discovery from data as typically provided by a user without the application having to care about it.
Methods
discoverAddressbooks()
Discover the addressbooks for a CardDAV account.
public
discoverAddressbooks(Account $account) : array<int, AddressbookCollection>
Parameters
- $account : Account
-
The CardDAV account providing credentials and initial discovery URI.
Tags
Return values
array<int, AddressbookCollection> —The discovered addressbooks.
discoverContextPath()
Provides a list of URIs to check for discovering the location of the CardDAV service.
private
discoverContextPath(array<string|int, mixed> $server) : array<string|int, string>
The provided context paths comprise both well-known URIs as well as paths discovered via DNS TXT records. DNS TXT lookup is only performed for servers that have themselves been discovery using DNS SRV lookups, using the same service resource record.
Parameters
- $server : array<string|int, mixed>
-
A server record (associative array) as returned by discoverServers()
Tags
Return values
array<string|int, string> —The context paths that should be tried for discovery in the provided order.
discoverServers()
Discovers the CardDAV service for the given domain using DNS SRV lookups.
private
discoverServers(string $host, bool $force_ssl) : array<string|int, mixed>
Parameters
- $host : string
-
A domain name to discover the service for
- $force_ssl : bool
-
If true, only services with transport encryption (carddavs) will be discovered, otherwise the function will try to discover unencrypted (carddav) services after failing to discover encrypted ones.
Tags
Return values
array<string|int, mixed> —Returns an array of associative arrays of services discovered via DNS. If nothing was found, the returned array is empty.
orderDnsRecords()
Orders DNS records by their prio and weight.
private
static orderDnsRecords(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>