]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: add sources specified by IP directly without name resolving
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 May 2015 09:20:03 +0000 (11:20 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 May 2015 11:12:00 +0000 (13:12 +0200)
ntp_sources.c

index 6fc05c4515acbc44b38ce631173156d35b8b9ecc..d166d4d0a43e476471b7d47f6189ea2529e93976 100644 (file)
@@ -505,6 +505,15 @@ NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type, Source
 {
   struct UnresolvedSource *us;
   struct SourcePool *sp;
+  NTP_Remote_Address remote_addr;
+
+  /* If the name is an IP address, don't bother with full resolving now
+     or later when trying to replace the source */
+  if (UTI_StringToIP(name, &remote_addr.ip_addr)) {
+    remote_addr.port = port;
+    NSR_AddSource(&remote_addr, type, params);
+    return;
+  }
 
   us = MallocNew(struct UnresolvedSource);
   us->name = Strdup(name);