srv

package module
v0.0.0-...-5e6693b Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2016 License: MIT Imports: 4 Imported by: 0

README

srv

Documentation

Overview

Package srv simplify connecting to services by resolving SRV query and then connect to it in order of priority.

A complete list of Service Name and Transport Protocol Port Number is found at: http://www.iana.org/assignments/service-names-port-numbers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(protocol, address string) (net.Conn, error)

Dial resolves a DNS SRV query of the given address. Then it will attempt to connect to the service in order priority.

Values for protocol are "tcp" or "udp", address is in the form: domain:service

Examples:

conn, err := Dial("tcp", "example.com:xmpp-client")
conn, err := Dial("udp", "example.com:stun")

func DialSRV

func DialSRV(service, protocol, domain string) (net.Conn, error)

DialSRV resolves a DNS SRV query of the given service, protocol and domain name. Then it will attempt to connect to the service in order priority.

Values for protocol are "tcp" or "udp".

Examples:

conn, err := DialSRV("xmpp-client", "tcp", "example.com")
conn, err := DialSRV("stun", "udp", "example.com")

func DialTCP

func DialTCP(localAddr *net.TCPAddr, address string) (*net.TCPConn, error)

DialTCP resolves and connects the given address.

Address is in the form: domain:service. If localAddr is not nil, it is used as the local address for the connection.

Examples:

conn, err := DialTCP(nil, "example.com:xmpp-client")

func DialUDP

func DialUDP(localAddr *net.UDPAddr, address string) (*net.UDPConn, error)

DialUDP resolves and connects the given address.

Address is in the form: domain:service. If localAddr is not nil, it is used as the local address for the connection.

Examples:

conn, err := DialUDP(nil, "example.com:stun")

func Lookup

func Lookup(protocol, address string) ([]net.Addr, error)

Lookup resolves a SRV query of the given protocol and address

Values for protocol are "tcp" or "udp" address is in the form: domain:service

Examples:

Lookup("tcp", "example.com:xmpp-client")
Lookup("udp", "example.com:stun")

The returned records are net.Addr containing the CNAME and port of the service, sorted by priority and randomized by weight within a priority.

func LookupSRV

func LookupSRV(service, protocol, domain string) ([]net.Addr, error)

LookupSRV resolves a SRV query of the given service, protocol, and domain name. Values for protocol are "tcp" or "udp"

LookupSRV constructs the DNS name to look up following RFC 2782. That is, it looks up _service._proto.name. To accommodate services publishing SRV records under non-standard names.

The returned records are net.Addr containing the CNAME and port of the service, sorted by priority and randomized by weight within a priority.

Types

This section is empty.

Jump to

Keyboard shortcuts

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