Skip to content

koron-go/dialsrv

Repository files navigation

koron-go/dialsrv

PkgGoDev Actions/Go Go Report Card

Dialer with SRV lookup.

Sample codes

HTTP

import "github.com/koron-go/dialsrv"

// query SRV records for "_myservice._tcp.example.com" then make HTTP GET.
r, err := dialsrv.HTTPClient.Get("http://srv+myservice+example.com/")
// TODO: work with r and err as usual.
// GET from example.com without SRV.
r, err := dialsrv.HTTPClient.Get("http://example.com/")
// TODO: work with r and err as usual.
import "net/http"

// replace http.DefaultClient
http.DefaultClient = dialsrv.HTTPClient
r, err := http.Get("http://srv+myservice+example.com/")
// TODO: work with r and err as usual.

Dialer

import "net"
import "github.com/koron-go/dialsrv"

// wrap *net.Dialer with SRV record querying
d := dialsrv.New(&net.Dialer{/* net.Dialer with your configurations */})

Acceptable formats

  • srv+{service}+{hostname} - SRV for _{service}._{network}.{hostname}
  • srv+{hostname} - SRV for {hostname}