| 195 | } |
| 196 | |
| 197 | void |
| 198 | HostDBHash::refresh() |
| 199 | { |
| 200 | CryptoContext ctx; |
| 201 | |
| 202 | if (host_name) { |
| 203 | const char *server_line = dns_server ? dns_server->x_dns_ip_line : nullptr; |
| 204 | uint8_t m = static_cast<uint8_t>(db_mark); // be sure of the type. |
| 205 | |
| 206 | ctx.update(host_name.data(), host_name.size()); |
| 207 | ctx.update(reinterpret_cast<uint8_t *>(&port), sizeof(port)); |
| 208 | ctx.update(&m, sizeof(m)); |
| 209 | if (server_line) { |
| 210 | ctx.update(server_line, strlen(server_line)); |
| 211 | } |
| 212 | } else { |
| 213 | // CryptoHash the ip, pad on both sizes with 0's |
| 214 | // so that it does not intersect the string space |
| 215 | // |
| 216 | char buff[TS_IP6_SIZE + 4]; |
| 217 | int n = ip.isIp6() ? sizeof(in6_addr) : sizeof(in_addr_t); |
| 218 | memset(buff, 0, 2); |
| 219 | memcpy(buff + 2, ip._addr._byte, n); |
| 220 | memset(buff + 2 + n, 0, 2); |
| 221 | ctx.update(buff, n + 4); |
| 222 | } |
| 223 | ctx.finalize(hash); |
| 224 | } |
| 225 | |
| 226 | HostDBHash::~HostDBHash() |
| 227 | { |
no test coverage detected