X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/f106fecc1d7d0250d1d76c2ba837dc0c870c5fff..671a55ba455dcf4e5ce6d86b202761666f54d5c6:/apt-pkg/contrib/srvrec.h?ds=sidebyside diff --git a/apt-pkg/contrib/srvrec.h b/apt-pkg/contrib/srvrec.h index 583907706..01b810281 100644 --- a/apt-pkg/contrib/srvrec.h +++ b/apt-pkg/contrib/srvrec.h @@ -3,7 +3,7 @@ /* ###################################################################### SRV record support - + ##################################################################### */ /*}}}*/ #ifndef SRVREC_H @@ -21,10 +21,34 @@ class SrvRec u_int16_t weight; u_int16_t port; - // see rfc-2782 - //int random; + // each server is assigned a interval [start, end] in the space of [0, max] + int random_number_range_start; + int random_number_range_end; + int random_number_range_max; + + bool operator<(SrvRec const &other) const { + return this->priority < other.priority; + } + bool operator==(SrvRec const &other) const; + + SrvRec(std::string const Target, u_int16_t const Priority, + u_int16_t const Weight, u_int16_t const Port) : + target(Target), priority(Priority), weight(Weight), port(Port), + random_number_range_start(0), random_number_range_end(0), + random_number_range_max(0) {} }; +/** \brief Get SRV records from host/port (builds the query string internally) + */ bool GetSrvRecords(std::string name, std::vector &Result); +/** \brief Get SRV records for query string like: _http._tcp.example.com + */ +bool GetSrvRecords(std::string host, int port, std::vector &Result); + +/** \brief Pop a single SRV record from the vector of SrvRec taking + * priority and weight into account + */ +SrvRec PopFromSrvRecs(std::vector &Recs); + #endif