Giter Club home page Giter Club logo

ntp's People

Contributors

abh avatar alcutter avatar alphab avatar beevik avatar chbatey avatar darkk avatar knyar avatar mengzhuo avatar pixelbender avatar silves-xiang avatar smira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ntp's Issues

KoD support?

Any plan on KoD support?

In NTPv4 and SNTPv4, packets of this kind are called Kiss-o'-Death (KoD) packets, and the ASCII messages they convey are called kiss codes. The KoD packets got their name because an early use was to tell clients to stop sending packets that violate server access controls.

i/o timeout error and bogus values

The following is the output of a program querying the ntp servers 0.centos.pool.ntp.org and 1.centos.pool.ntp.org while sleeping for a few seconds between queries.

I've run into two kinds of errors

  1. Failed to reach NTP server: 1.centos.pool.ntp.org error: read udp 10.4.67.150:37627->171.66.97.126:123: i/o timeout. I've tried increasing the timeout to 10 seconds from the default of 5 but that hasn't helped. Please share any suggestions you might have.

  2. And the other is for invalid values Reached NTP server: 1.centos.pool.ntp.org offset: 3754691965.127657. Where the 3754691965.127657 is way higher than the expected offset.

I've been using the 0.3 release but have experienced the same errors in the 0.2 release.

Reached NTP server: 0.centos.pool.ntp.org offset: 19.631600
Failed to reach NTP server: 1.centos.pool.ntp.org error: read udp 10.4.67.150:57557->104.155.144.4:123: i/o timeout
Reached NTP server: 0.centos.pool.ntp.org offset: 19.626120
Reached NTP server: 1.centos.pool.ntp.org offset: 19.636507
Reached NTP server: 0.centos.pool.ntp.org offset: 19.631544
Failed to reach NTP server: 1.centos.pool.ntp.org error: read udp 10.4.67.150:38249->104.155.144.4:123: i/o timeout
Reached NTP server: 0.centos.pool.ntp.org offset: 19.626148
Failed to reach NTP server: 1.centos.pool.ntp.org error: read udp 10.4.67.150:34181->162.248.241.94:123: i/o timeout
Reached NTP server: 0.centos.pool.ntp.org offset: 19.631553
Reached NTP server: 1.centos.pool.ntp.org offset: 19.636571
Reached NTP server: 0.centos.pool.ntp.org offset: 19.633790
Reached NTP server: 1.centos.pool.ntp.org offset: 3754691965.127657
Reached NTP server: 0.centos.pool.ntp.org offset: 19.635017
Reached NTP server: 1.centos.pool.ntp.org offset: 19.626531
Reached NTP server: 0.centos.pool.ntp.org offset: 19.626131
Reached NTP server: 1.centos.pool.ntp.org offset: 19.634028
Reached NTP server: 0.centos.pool.ntp.org offset: 19.631843
Failure count: 6 bogus values: 4

Expose NTP Server Version as a property

I used your library to write a tiny diagnostic tool, thanks!

I noticed that Wireshark's dissector can tell me if the NTP version in the response was 3 or 4, it might be nice to have this in this library as well.

Two test cases try to access the Internet

Running the test cases during package build on Ubuntu fail [1]:

   dh_auto_test -O--builddirectory=_build -O--buildsystem=golang
	cd _build && go test -vet=off -v -p 4 github.com/beevik/ntp
=== RUN   TestTime
    ntp_test.go:34: [0.beevik-ntp.pool.ntp.org] Query failed: lookup 0.beevik-ntp.pool.ntp.org: no such host
--- FAIL: TestTime (0.02s)
=== RUN   TestTimeFailure
--- PASS: TestTimeFailure (5.01s)
=== RUN   TestQuery
    ntp_test.go:77: [0.beevik-ntp.pool.ntp.org] ----------------------
    ntp_test.go:78: [0.beevik-ntp.pool.ntp.org] NTP protocol version 4
    ntp_test.go:34: [0.beevik-ntp.pool.ntp.org] Query failed: lookup 0.beevik-ntp.pool.ntp.org: no such host
--- FAIL: TestQuery (0.00s)
=== RUN   TestValidate
--- PASS: TestValidate (0.00s)
=== RUN   TestBadServerPort
--- PASS: TestBadServerPort (0.00s)
=== RUN   TestTTL
--- PASS: TestTTL (0.00s)
=== RUN   TestQueryTimeout
--- PASS: TestQueryTimeout (0.00s)
=== RUN   TestShortConversion
--- PASS: TestShortConversion (0.00s)
=== RUN   TestLongConversion
--- PASS: TestLongConversion (0.00s)
=== RUN   TestOffsetCalculation
--- PASS: TestOffsetCalculation (0.00s)
=== RUN   TestOffsetCalculationNegative
--- PASS: TestOffsetCalculationNegative (0.00s)
=== RUN   TestMinError
--- PASS: TestMinError (0.01s)
=== RUN   TestTimeConversions
--- PASS: TestTimeConversions (0.00s)
=== RUN   TestKissCode
--- PASS: TestKissCode (0.00s)
FAIL
FAIL	github.com/beevik/ntp	5.091s
FAIL

This is caused by the package build host having no Internet access. Please change the test cases to not require Internet access. The positive side effect will be that the test cases can't break by changes to the NTP host 0.beevik-ntp.pool.ntp.org.

[1] Full log: https://launchpadlibrarian.net/575776629/buildlog_ubuntu-jammy-amd64.golang-github-beevik-ntp_0.3.0-2_BUILDING.txt.gz

Check version of response

I have a need to filter server responses that are v3, since some of my devices only accept a v4 server, I'm halfway through checking the header flag myself in an extension, but was wondering if this might be a valid feature request? Would adding Version to the response struct make sense to anyone else?

time.Duration to NtpTime

Any chance for you to add the reverse function of (t ntpTimeShort) Duration() time.Duration?

like a toNtpTime(t time.Duration) NtpTime function?

I can't figure the formula myself.

Or can you provide any link where I can find the formula? Sorry but I can't contact you privately

Rename branch to `main`

It'd be nice if the main branch was renamed to main instead of the legacy / old term.

(Also, thank you for this package -- the NTP Pool is using it to do hundreds of millions of monitoring probes every month!)

IPv6 support

Hi,

nice package. I saw in the code that you use IPv4 connection. Is there a reason for that?

Can this implementation support both v4 & v6?

Support for querying clock discipline system variables?

Hi,

I wanted to use this package to monitor stratum 1 servers.
There doesn't seem to be support for querying some fields useful for plotting the oscillator stability.
I'm looking for in particular these fields reported by ntpq -c rv

  • time constant
  • frequency error
  • system jitter
  • clock jitter
  • clock wander

Would you consider adding support for that?

Please license the code

Hi,

I am packaging dependencies for prometheus.io for Debian, and since they use your package I need to package it too. The problem is that without an explicit license attached to the code it is not legal for Debian to include the package.

Could you add that?

Support IPv6-only hosts

Hi,

I have machines that have only IPv6 connectivity. Using net.ResolveUDPAddr with udp will always* return IPv4 if the DNS name has an IPv4 configured, regardless if the system can route it.

Consider either giving the user a possibility of specifying "udp6" for IPv6, or better yet try with "udp" first, then "udp4" and then "udp6".

Thanks!
* See https://golang.org/src/net/ipsock.go line 85.

Don't change stratum data

It's confusing that stratum=0 gets changed to 16.

I understand that implementations are suggested to do this, but I think it's "later" than "when processing packets". For my application I want to know what the server said.

The RFC also says to process the referenceID separately if the stratum is 0, right now that's impossible to do correctly with the Go client because you can't know if the server said 16 or if it said 0 and it was changed.

1.2.0 broke querying IPv6 IPs

In 1.2.0 the API for querying an IPv6 IP by IP address got a little awkward.

I used to just pass the IP (because that was the API, I think). In 1.2.0 I get a "missing port" address.

For an API that takes an optional IP usually sending the IP in brackets like [fe80::1] would work, but getTime() use net.JoinHostPort which messes that up a returns an error that [[fe80::1]] is missing a port number. (see https://go.dev/play/p/Wi0YDXQ0gUH )

Passing a string with the port number works [fe80::1]:123, but that seems to defeat the intention of having the Port number in the opts. Maybe the awkwardness comes from trying to support the port number in the address AND in the opts; currently making the opts version not actually work for IPv6 IPs.

Example of errors from SplitHostPort that might be helpful in figuring out how to fix it: https://go.dev/play/p/mJR_MD9PDUn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.