Documentation ¶
Overview ¶
Package srv is a simple package for looking up and dialing hosts described in SRV records.
Index ¶
- Variables
- func Dial(network, address string) (net.Conn, error)
- func DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func DialSRV(ctx context.Context, service, proto, name string) (net.Conn, error)
- type Addr
- type DialFunc
- type Dialer
- func (d *Dialer) Dial(network, address string) (net.Conn, error)
- func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func (d *Dialer) DialSRV(ctx context.Context, service, proto, name string) (net.Conn, error)
- func (d *Dialer) LookupAddrs(ctx context.Context, service, proto, name string, limit int) ([]*Addr, error)
- type GetNetworkFunc
- type Resolver
Constants ¶
This section is empty.
Variables ¶
var ErrNoAddrs = errors.New("no addresses found")
ErrNoAddrs is returned if no names were returned in a request for SRV records.
Functions ¶
func Dial ¶
Dial is a convenience function for DialContext(context.Background, network, address). See DialContext for more information.
func DialContext ¶
DialContext looks up SRV records for the address and dials a randomly selected host and port from the returned records.
Types ¶
type Addr ¶
Addr contains a network (for use in net.Dial) and a SRV record. It is not a fully-resolved address.
func LookupAddrs ¶
LookupAddrs looks up SRV records. See (*Dialer).LookupAddrs for more information, as this calls it on a default Dialer.
type Dialer ¶
type Dialer struct { DialFunc DialFunc Resolver Resolver GetNetwork GetNetworkFunc RandInt func(int) int }
Dialer looks up services in using SRV records and dials host:port combinations described by SRV records.
func (*Dialer) Dial ¶
Dial is a convenience function for DialContext(context.Background, network, address). See DialContext for more information.
func (*Dialer) DialContext ¶
DialContext looks up SRV records for the address and dials a randomly selected host and port from the returned records.
Unlike DialSRV, if no SRV records are found for the given address, it will attempt to dial the address normally.
type GetNetworkFunc ¶
GetNetworkFunc is a callback used by Dialer. Given a service and proto (including _s using standard names), the function should return a network supported by net.Dial, such as "tcp" or "udp". If the names aren't recognized, it should return an empty string.