[Git][NTPsec/ntpsec][master] 3 commits: Try 4 times to get Nonce. Don't give up on first failure.

Gary E. Miller gitlab at mg.gitlab.com
Wed Aug 9 21:13:02 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
caab6983 by Gary E. Miller at 2017-08-09T13:38:01-07:00
Try 4 times to get Nonce.  Don't give up on first failure.

"If at first you do not suceed, try, try again."

- - - - -
28b2f8da by Gary E. Miller at 2017-08-09T13:38:01-07:00
INSTALL: typo.

- - - - -
5613ab38 by Gary E. Miller at 2017-08-09T13:38:01-07:00
ntpmon detail mode styling

- - - - -


3 changed files:

- INSTALL
- ntpclients/ntpmon
- pylib/packet.py


Changes:

=====================================
INSTALL
=====================================
--- a/INSTALL
+++ b/INSTALL
@@ -120,7 +120,7 @@ On macOS you can use this command to turn off the Apple version of NTP:
 sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist
 ----
 
-Under Mac OS X 10.6.8 (Snow Leopard) and proibably older versions, you
+Under Mac OS X 10.6.8 (Snow Leopard) and probably older versions, you
 may find that configuration fails with a message about -o being an
 unknown option.  This is due to a bad interaction with waf. To work
 around this, find your waflib/Tools/gcc.py under the waf temporary


=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -139,16 +139,17 @@ def peer_detail(variables, showunits=False):
 
     peerfmt = """\
 %(adr)s
-leap=%(leap)s\treftime=%(reftime)s\trootdelay=%(rootdelay)s
-stratum=%(stratum)2d\trec=%(rec)s\trootdisp=%(rootdisp)s
-precision=%(precision)3d\txmt=%(xmt)s\tdispersion=%(dispersion)s
+reftime=%(reftime)s\tleap=%(leap)s\trootdelay=%(rootdelay)s
+    rec=%(rec)s\tstratum=%(stratum)2d\trootdisp=%(rootdisp)s
+    xmt=%(xmt)s\tprecision=%(precision)3d\tdispersion=%(dispersion)s
 unreach=%(unreach)d hmode=%(hmode)d pmode=%(pmode)d hpoll=%(hpoll)d \
 ppoll=%(ppoll)d headway=%(headway)s flash=%(flash)s keyid=%(keyid)s
 filtdelay  = %(filtdelay)s
 filtoffset = %(filtoffset)s
 filtdisp   = %(filtdisp)s
 """
-    return peerfmt % vcopy
+    str = peerfmt % vcopy
+    return str.expandtabs()
 
 
 class Fatal(Exception):


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1338,14 +1338,21 @@ class ControlSession:
 
     def fetch_nonce(self):
         """
-Receive a nonce that can be replayed - combats source address spoofing
+Ask for, and get, a nonce that can be replayed.
+This combats source address spoofing
 """
-        self.doquery(opcode=ntp.control.CTL_OP_REQ_NONCE)
-        self.nonce_xmit = time.time()
-        if not self.response.startswith(polybytes("nonce=")):
-            print("## Nonce expected: %s" % self.response)
-            raise ControlException(SERR_BADNONCE)
-        return polystr(self.response.strip())
+        for i in range(3):
+            # retry 4 times
+            self.doquery(opcode=ntp.control.CTL_OP_REQ_NONCE)
+            self.nonce_xmit = time.time()
+            if self.response.startswith(polybytes("nonce=")):
+                return polystr(self.response.strip())
+            # maybe a delay between tries?
+
+        # uh, oh, no nonce seen
+        # this print probably never can be seen...
+        print("## Nonce expected: %s" % self.response)
+        raise ControlException(SERR_BADNONCE)
 
     def mrulist(self, variables=None, rawhook=None, direct=None):
         "Retrieve MRU list data"



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/66458e4b627f4aae85dd5e0902f80da2f6cba6a3...5613ab384a1fa2001f17512762f8d90b413431bf

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/66458e4b627f4aae85dd5e0902f80da2f6cba6a3...5613ab384a1fa2001f17512762f8d90b413431bf
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170809/ca84ebb3/attachment.html>


More information about the vc mailing list