{"id":21682328,"url":"https://github.com/beevik/nts","last_synced_at":"2025-04-12T06:52:55.965Z","repository":{"id":184348656,"uuid":"665800582","full_name":"beevik/nts","owner":"beevik","description":"network time security client package for go","archived":false,"fork":false,"pushed_at":"2025-01-30T04:47:25.000Z","size":51,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T06:52:49.179Z","etag":null,"topics":["go","ntp","ntp-client","ntp-protocol","nts","nts-client","nts-protocol","security","time"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beevik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-13T03:18:41.000Z","updated_at":"2025-04-07T01:59:23.000Z","dependencies_parsed_at":"2025-01-30T05:32:38.284Z","dependency_job_id":null,"html_url":"https://github.com/beevik/nts","commit_stats":null,"previous_names":["beevik/nts"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Fnts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Fnts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Fnts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Fnts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beevik","download_url":"https://codeload.github.com/beevik/nts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530594,"owners_count":21119595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","ntp","ntp-client","ntp-protocol","nts","nts-client","nts-protocol","security","time"],"created_at":"2024-11-25T15:35:38.711Z","updated_at":"2025-04-12T06:52:55.926Z","avatar_url":"https://github.com/beevik.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/beevik/nts?status.svg)](https://godoc.org/github.com/beevik/nts)\n\nnts\n===\n\nThe nts package provides a client implementation of Network Time Security\n(NTS) for the Network Time Protocol (NTP). It enables the secure querying of\ntime-related information that can be used to synchronize the local system\nclock with a more accurate network clock. See\n[RFC 8915](https://tools.ietf.org/html/rfc8915) for further details.\n\nThis package is implemented as an extension to the go-based [simple ntp\nclient package](https://github.com/beevik/ntp), but it may be used without\ndirectly installing that package.\n\n\n## Creating an NTS session\n\nBefore requesting time synchronization data, you must first establish a\n\"session\" with an NTS key-exchange server.\n\n```go\nsession, err := nts.NewSession(\"time.cloudflare.com\")\n```\n\nThis is not a session in the typical sense of the word, which often implies a\nlong-running network connection to a server. Rather, it is merely a collection\nof cryptographic keys and other state used to communicate securely with an\nNTS-capable NTP server. Once the session has been created, the network\nconnection to the key-exchange server is immediately dropped and all future\nqueries proceed via NTP using the session's query functions.\n\nIf you wish to customize the behavior of the session, you may do so by using\n[`NewSessionWithOptions`](https://godoc.org/github.com/beevik/nts#NewSessionWithOptions)\ninstead of `NewSession`. For example:\n\n```go\nopt := \u0026nts.SessionOptions{\n    TLSConfig: \u0026tls.Config{\n        RootCAs: certPool,\n    },\n    Timeout: 30 * time.Second,\n    Dialer: customDialer,\n    Resolver: customResolver,\n}\nsession, err := nts.NewSessionWithOptions(host, opt)\n```\n\nSee the documentation for\n[`SessionOptions`](https://godoc.org/github.com/beevik/nts#SessionOptions) for a\nlist of available customizations.\n\n## Querying time synchronization data\n\nAfter successful establishment of the session, you may issue NTP\n[`Query`](https://godoc.org/github.com/beevik/nts#Query) requests for time\nsynchronization data.\n\n```go\nif response, err := session.Query(); err != nil {\n    accurateTime := time.Now().Add(response.ClockOffset)\n    fmt.Printf(\"The current time is: %s\\n\", accurateTime)\n}\n```\n\nIn addition to the clock offset, the\n[`Response`](https://godoc.org/github.com/beevik/ntp#Response) includes\ninformation you can use to tune future queries. For instance, it includes a\n`Poll` interval, which describes how long you should wait before querying\nagain. The response also has a\n[`Validate`](https://godoc.org/github.com/beevik/ntp#Response.Validate)\nfunction, which you can use to perform additional sanity checks on the data to\ndetermine whether it is suitable for time synchronization purposes.\n```go\nerr := response.Validate()\nif err == nil {\n    // response data is suitable for synchronization purposes\n}\n```\n\nIf you wish to customize the behavior of the query, you may do so by using\n[`QueryWithOptions`](https://godoc.org/github.com/beevik/nts#QueryWithOptions)\ninstead of `Query`.\n\n```go\nopt := \u0026ntp.QueryOptions{ Timeout: 30 * time.Second }\nresponse, err := session.QueryWithOptions(opt)\n```\n\nSee the documentation for\n[`QueryOptions`](https://godoc.org/github.com/beevik/ntp#QueryOptions) for a\nlist of available customizations.\n\n\n## Choosing an NTS server\n\nNTS is a relatively new protocol, having become an IETF RFC in September 2020.\nSo there are a limited number of NTS key-exchange servers available for public\nuse. You can find a list [here](https://netfuture.ch/public-nts-server-list/).\nThe [NTP pool](https://www.pool.ntp.org) does not currently support NTS.\n\nIf you wish to operate your own NTS-capable NTP server, you may install\n[NTPsec](https://docs.ntpsec.org/latest/NTS-QuickStart.html) or\n[Chrony](https://chrony.tuxfamily.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeevik%2Fnts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeevik%2Fnts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeevik%2Fnts/lists"}