1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
7 ##################################################################### */
12 #include <arpa/nameser.h>
25 // each server is assigned a interval [start, end] in the space of [0, max]
26 int random_number_range_start
;
27 int random_number_range_end
;
28 int random_number_range_max
;
30 bool operator<(SrvRec
const &other
) const {
31 return this->priority
< other
.priority
;
33 bool operator==(SrvRec
const &other
) const {
34 return std::tie(target
, priority
, weight
, port
) == std::tie(other
.target
, other
.priority
, other
.weight
, other
.port
);
37 SrvRec(std::string
const Target
, u_int16_t
const Priority
,
38 u_int16_t
const Weight
, u_int16_t
const Port
) :
39 target(Target
), priority(Priority
), weight(Weight
), port(Port
),
40 random_number_range_start(0), random_number_range_end(0),
41 random_number_range_max(0) {}
44 /** \brief Get SRV records from host/port (builds the query string internally)
46 bool GetSrvRecords(std::string name
, std::vector
<SrvRec
> &Result
);
48 /** \brief Get SRV records for query string like: _http._tcp.example.com
50 bool GetSrvRecords(std::string host
, int port
, std::vector
<SrvRec
> &Result
);
52 /** \brief Pop a single SRV record from the vector of SrvRec taking
53 * priority and weight into account
55 SrvRec
PopFromSrvRecs(std::vector
<SrvRec
> &Recs
);