Documentation
¶
Index ¶
- Variables
- func AllSRV(hostname string) ([]string, error)
- func AllSRVContext(ctx context.Context, hostname string) ([]string, error)
- func AllSRVTranslate(hostname string) ([]string, error)
- func AllSRVTranslateContext(ctx context.Context, hostname string) ([]string, error)
- func MaybeSRV(host string) string
- func MaybeSRVURL(host string) string
- func MaybeSRVURLContext(ctx context.Context, host string) string
- func SRV(hostname string) (string, error)
- func SRVContext(ctx context.Context, hostname string) (string, error)
- func SRVNoPort(hostname string) (string, error)
- func SRVNoPortContext(ctx context.Context, hostname string) (string, error)
- func SRVNoTranslate(hostname string) (string, error)
- func SRVNoTranslateContext(ctx context.Context, hostname string) (string, error)
- func WithoutCancel(ctx context.Context) context.Contextdeprecated
- type ErrNotFound
- type SRVClient
- func (sc *SRVClient) AllSRV(hostname string) ([]string, error)
- func (sc *SRVClient) AllSRVContext(ctx context.Context, hostname string) ([]string, error)
- func (sc *SRVClient) AllSRVNoCacheContext(ctx context.Context, hostname string) ([]string, error)
- func (sc *SRVClient) AllSRVTranslate(hostname string) ([]string, error)
- func (sc *SRVClient) AllSRVTranslateContext(ctx context.Context, hostname string) ([]string, error)
- func (sc *SRVClient) EnableCacheLast()
- func (sc *SRVClient) MaybeSRV(host string) string
- func (sc *SRVClient) MaybeSRVContext(ctx context.Context, host string) string
- func (sc *SRVClient) MaybeSRVURL(host string) string
- func (sc *SRVClient) MaybeSRVURLContext(ctx context.Context, host string) string
- func (sc *SRVClient) SRV(hostname string) (string, error)
- func (sc *SRVClient) SRVContext(ctx context.Context, hostname string) (string, error)
- func (sc *SRVClient) SRVNoCacheContext(ctx context.Context, hostname string) (string, error)
- func (sc *SRVClient) SRVNoPort(hostname string) (string, error)
- func (sc *SRVClient) SRVNoPortContext(ctx context.Context, hostname string) (string, error)
- func (sc *SRVClient) SRVNoTranslate(hostname string) (string, error)
- func (sc *SRVClient) SRVNoTranslateContext(ctx context.Context, hostname string) (string, error)
- func (sc *SRVClient) Stats() SRVStats
- type SRVStats
Constants ¶
This section is empty.
Variables ¶
var DefaultSRVClient = new(SRVClient)
DefaultSRVClient is an instance of SRVClient with all zero'd values, used as the default client for all global methods. It can be overwritten prior to any of the methods being used in order to modify their behavior
Functions ¶
func AllSRVContext ¶ added in v1.1.0
AllSRVContext calls the AllSRVContext method on the DefaultSRVClient
func AllSRVTranslate ¶ added in v1.0.0
AllSRVTranslate calls the AllSRVTranslate method on the DefaultSRVClient
func AllSRVTranslateContext ¶ added in v1.1.0
AllSRVTranslateContext calls the AllSRVTranslateContext method on the DefaultSRVClient
func MaybeSRVURL ¶ added in v0.4.0
MaybeSRVURL calls the MaybeSRVURL method on the DefaultSRVClient
func MaybeSRVURLContext ¶ added in v1.1.0
MaybeSRVURLContext calls the MaybeSRVURLContext method on the DefaultSRVClient
func SRVContext ¶ added in v1.1.0
SRVContext calls the SRVContext method on the DefaultSRVClient
func SRVNoPortContext ¶ added in v1.1.0
SRVNoPortContext calls the SRVNoPortContext method on the DefaultSRVClient
func SRVNoTranslate ¶ added in v0.5.0
SRVNoTranslate calls the SRVNoTranslate method on the DefaultSRVClient
func SRVNoTranslateContext ¶ added in v1.1.0
SRVNoTranslateContext calls the SRVNoTranslateContext method on the DefaultSRVClient
func WithoutCancel
deprecated
added in
v1.1.0
WithoutCancel returns a context identical to the given one, but which will never be canceled, regardless of if the given one is because the context methods will only propagate cancellations if the Done() method returns non-nil, but we override the Done method to return nil. Additionally, this will overwrite the Deadline method to return no deadline so if you call WithTimeout/WithDeadline it'll use the new value and not retain the parent one if its sooner.
Deprecated: use context.WithoutCancel instead.
Types ¶
type ErrNotFound ¶ added in v0.5.0
type ErrNotFound struct {
// contains filtered or unexported fields
}
ErrNotFound is returned when there were no SRV records for the given hostname
func (*ErrNotFound) Error ¶ added in v0.5.0
func (err *ErrNotFound) Error() string
Error implements the error interface
type SRVClient ¶ added in v0.4.0
type SRVClient struct { // OnExchangeError specifies an optional function to call for exchange errors // that otherwise might be ignored if another server did not error. OnExchangeError func(ctx context.Context, hostname string, server string, error error) // UDPSize specifies the maximum receive buffer for UDP messages UDPSize uint16 // If IgnoreTruncated is true, then lookups will NOT fallback to TCP when // they were truncated over UDP. IgnoreTruncated bool // A list of addresses ("ip:port") which should be used as the resolver // list. If none are set then the resolver settings in /etc/resolv.conf are // used. This can only be updated before the SRVClient is used for the first // time. ResolverAddrs []string // If non-nill, will be called on messages returned from dns servers prior // to them being processed (i.e. before they are cached, sorted, // ip-replaced, etc...) Preprocess func(*dns.Msg) // SingleInFlight will combine duplicate lookups and only issue a single DNS // query, mirroring the response to all callers. SingleInFlight bool // contains filtered or unexported fields }
SRVClient is a holder for methods related to SRV lookups. Use new(SRVClient) to initialize one.
func (*SRVClient) AllSRVContext ¶ added in v1.1.0
AllSRVContext returns the list of all hostnames and ports for the SRV lookup The results are sorted by priority and then weight. Like SRV, if hostname contained a port then the port on all results will be replaced with the originally-passed port AllSRVContext will NOT replace hostnames with their respective IPs
func (*SRVClient) AllSRVNoCacheContext ¶ added in v1.2.0
AllSRVNoCacheContext calls AllSRVContext but ignores the cache
func (*SRVClient) AllSRVTranslate ¶ added in v1.0.0
AllSRVTranslate calls AllSRVTranslateContext with an empty context
func (*SRVClient) AllSRVTranslateContext ¶ added in v1.1.0
AllSRVTranslateContext returns the list of all IPs and ports for the SRV lookup The results are sorted by priority and then weight. Like SRV, if hostname contained a port then the port on all results will be replaced with the originally-passed port
func (*SRVClient) EnableCacheLast ¶ added in v0.4.0
func (sc *SRVClient) EnableCacheLast()
EnableCacheLast is used to make SRVClient cache the last successful SRV response for each domain requested, and if the next request results in some kind of error it will use that last response instead.
func (*SRVClient) MaybeSRVContext ¶ added in v1.1.0
MaybeSRVContext attempts a SRV lookup if the host doesn't contain a port and if the SRV lookup succeeds it'll rewrite the host and return it with the lookup result. If it fails it'll just return the host originally sent
func (*SRVClient) MaybeSRVURL ¶ added in v0.4.0
MaybeSRVURL calls MaybeSRVURLContext with an empty context
func (*SRVClient) MaybeSRVURLContext ¶ added in v1.1.0
MaybeSRVURLContext calls MaybeSRVContext and also prepends http:// if no scheme was sent
func (*SRVClient) SRVContext ¶ added in v1.1.0
SRVContext will perform a SRV request on the given hostname, and then choose one of the returned entries randomly based on the priority and weight fields it sees. It will return the address ("host:port") of the winning entry, or an error if the query couldn't be made or it returned no entries. If the DNS server provided the A records for the hosts, then the result will have the target replaced with its respective IP.
If the given hostname already has a ":port" appended to it, only the ip will be looked up from the SRV request, but the port given will be returned
If the given hostname is "ip:port", it'll just immediately return what you sent.
func (*SRVClient) SRVNoCacheContext ¶ added in v1.2.0
SRVNoCacheContext calls SRVContext but ignores the cache
func (*SRVClient) SRVNoPort ¶ added in v0.4.0
SRVNoPort behaves the same as SRV, but the returned address string will not contain the port
func (*SRVClient) SRVNoPortContext ¶ added in v1.1.0
SRVNoPortContext behaves the same as SRVContext, but the returned address string will not contain the port
func (*SRVClient) SRVNoTranslate ¶ added in v0.5.0
SRVNoTranslate is exactly like SRV except it won't translate names to their respective IPs
func (*SRVClient) SRVNoTranslateContext ¶ added in v1.1.0
SRVNoTranslateContext is exactly like SRVContext except it won't translate names to their respective IPs