<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>
Eric S. Raymond pushed to branch master
at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/fa31911e80c85c20c4616fffb6b08fd036be3641">fa31911e</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-31T00:16:55Z</i>
</div>
<pre class='commit-message'>Replay - refactor syncgonous lookup in preparation for intercepting it.</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
ntpd/ntp_config.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/fa31911e80c85c20c4616fffb6b08fd036be3641#diff-0'>
<strong>
ntpd/ntp_config.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_config.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_config.c
</span><span style="color: #aaaaaa">@@ -3688,6 +3688,40 @@ peerflag_bits(
</span>   return peerflags;
 }
 
<span style="color: #000000;background-color: #ddffdd">+static bool sync_lookup(char *hname, sockaddr_u *peeraddrp)
+{
+       int a_info;
+       size_t octets;
+       struct addrinfo         hints, *res;
+
+       ZERO(hints);
+       hints.ai_family = AF_UNSPEC;
+       hints.ai_socktype = SOCK_DGRAM;
+       hints.ai_protocol = IPPROTO_UDP;
+       a_info = getaddrinfo(hname, "ntp", &hints, &res);
+       if (a_info == EAI_NONAME
+#ifdef EAI_NODATA
+           || a_info == EAI_NODATA
+#endif
+          ) {
+               hints.ai_flags = AI_CANONNAME;
+               hints.ai_flags |= AI_ADDRCONFIG;
+               a_info = getaddrinfo(hname, "ntp", &hints, &res);
+       }
+       if (a_info != 0) {
+               msyslog(LOG_ERR,
+                       "hostname %s can not be used (%s), please use IP address.",
+                       hname, gai_strerror(a_info));
+               return false;
+       } else {
+               INSIST(res != NULL);
+               memset(peeraddrp, '\0', sizeof(*peeraddrp));
+               octets = min(sizeof(*peeraddrp), res->ai_addrlen);
+               memcpy(peeraddrp, res->ai_addr, octets);
+               return true;
+       }
+}
+
</span> static void
 config_peers(
        config_tree *ptree
<span style="color: #aaaaaa">@@ -3729,39 +3763,7 @@ config_peers(
</span>                                   0,
                                        NULL);
                } else if (force_synchronous_dns) {
<span style="color: #000000;background-color: #ffdddd">-                        sockaddr_u              peeraddr;
-                       struct addrinfo         hints;
-
-                       struct addrinfo *res;
-                       int a_info;
-                       size_t octets;
-
-                       ZERO(hints);
-                       hints.ai_family = AF_UNSPEC;
-                       hints.ai_socktype = SOCK_DGRAM;
-                       hints.ai_protocol = IPPROTO_UDP;
-                       a_info = getaddrinfo(*cmdline_servers,
-                                            "ntp", &hints,
-                                            &res);
-                       if (a_info == EAI_NONAME
-#ifdef EAI_NODATA
-                           || a_info == EAI_NODATA
-#endif
-                          ) {
-                               hints.ai_flags = AI_CANONNAME;
-                               hints.ai_flags |= AI_ADDRCONFIG;
-                               a_info = getaddrinfo(*cmdline_servers, "ntp", &hints, &res);
-                       }
-                       if (a_info != 0) {
-                               msyslog(LOG_ERR,
-                                       "hostname %s can not be used (%s), please use IP address.",
-                                       *cmdline_servers, gai_strerror(a_info));
-                       } else {
-                               INSIST(res != NULL);
-                               ZERO(peeraddr);
-                               octets = min(sizeof(peeraddr), res->ai_addrlen);
-                               memcpy(&peeraddr, res->ai_addr, octets);
-
</span><span style="color: #000000;background-color: #ddffdd">+                   if (sync_lookup(*cmdline_servers, &peeraddr)) {
</span>                           peer_config(
                                        &peeraddr,
                                        NULL,
<span style="color: #aaaaaa">@@ -3851,39 +3853,7 @@ config_peers(
</span>            * synchronous lookup may be forced.
                 */
                } else if (force_synchronous_dns) {
<span style="color: #000000;background-color: #ffdddd">-                        sockaddr_u              peeraddr;
-                       struct addrinfo         hints;
-
-                       struct addrinfo *res;
-                       int a_info;
-                       size_t octets;
-
-                       ZERO(hints);
-                       hints.ai_family = curr_peer->addr->type;
-                       hints.ai_socktype = SOCK_DGRAM;
-                       hints.ai_protocol = IPPROTO_UDP;
-                       a_info = getaddrinfo(curr_peer->addr->address,
-                                            "ntp", &hints,
-                                            &res);
-                       if (a_info == EAI_NONAME
-#ifdef EAI_NODATA
-                           || a_info == EAI_NODATA
-#endif
-                          ) {
-                               hints.ai_flags = AI_CANONNAME;
-                               hints.ai_flags |= AI_ADDRCONFIG;
-                               a_info = getaddrinfo(curr_peer->addr->address, "ntp", &hints, &res);
-                       }
-                       if (a_info != 0) {
-                               msyslog(LOG_ERR,
-                                       "hostname %s can not be used, please use IP address.",
-                                       curr_peer->addr->address);
-                       } else {
-                               INSIST(res != NULL);
-                               ZERO(peeraddr);
-                               octets = min(sizeof(peeraddr), res->ai_addrlen);
-                               memcpy(&peeraddr, res->ai_addr, octets);
-
</span><span style="color: #000000;background-color: #ddffdd">+                   if (sync_lookup(curr_peer->addr->address, &peeraddr)) {
</span>                           peer_config(
                                        &peeraddr,
                                        NULL,
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/fa31911e80c85c20c4616fffb6b08fd036be3641">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/fa31911e80c85c20c4616fffb6b08fd036be3641"}}</script>
</p>
</div>
</body>
</html>