query.go 715 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package query
  2. import (
  3. "git.giaever.org/joachimmg/m-dns/errors"
  4. "git.giaever.org/joachimmg/m-dns/host"
  5. "git.git.giaever.org/joachimmg/m-dns/query/params"
  6. )
  7. type Query struct {
  8. params.Params
  9. unicast
  10. timeout time.Duration
  11. instances chan<- *host.Host
  12. }
  13. func New(p params.Params, unicast bool, timeout int) (Query, error) {
  14. q := new(Query)
  15. if q == nil {
  16. log.Traceln(errors.Client, errors.OutOfMemory)
  17. return nil, errors.OutOfMemory
  18. }
  19. q.Params = p
  20. q.unicast = u
  21. q.timeout = t
  22. return q, nil
  23. }
  24. func NewDefault(service, domain string) (Query, error) {
  25. p, err := params.New(service, domain, nil)
  26. if err != nil {
  27. return nil, err
  28. }
  29. return New(p, config.ForceUnicast, config.QueryTimeout)
  30. }