{"id":16934048,"url":"https://github.com/shogo82148/go-webntp","last_synced_at":"2025-03-22T12:31:31.371Z","repository":{"id":18445187,"uuid":"84319241","full_name":"shogo82148/go-webntp","owner":"shogo82148","description":"ntp service via WebSocket","archived":false,"fork":false,"pushed_at":"2024-06-14T20:49:50.000Z","size":142,"stargazers_count":14,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-15T21:17:21.639Z","etag":null,"topics":["go","golang","ntp","websocket"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shogo82148.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":"2017-03-08T12:44:43.000Z","updated_at":"2025-01-08T11:43:42.000Z","dependencies_parsed_at":"2023-12-14T15:28:04.867Z","dependency_job_id":"49dc5c59-a0ce-424a-9590-c568686eec70","html_url":"https://github.com/shogo82148/go-webntp","commit_stats":{"total_commits":79,"total_committers":2,"mean_commits":39.5,"dds":0.08860759493670889,"last_synced_commit":"559527f8166afe504142c4bb3469006ce1c53e35"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-webntp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-webntp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-webntp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-webntp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shogo82148","download_url":"https://codeload.github.com/shogo82148/go-webntp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959434,"owners_count":20538625,"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","golang","ntp","websocket"],"created_at":"2024-10-13T20:51:10.988Z","updated_at":"2025-03-22T12:31:30.501Z","avatar_url":"https://github.com/shogo82148.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/shogo82148/go-webntp.svg?branch=master)](https://travis-ci.com/shogo82148/go-webntp)\n[![Go Reference](https://pkg.go.dev/badge/github.com/shogo82148/go-webntp.svg)](https://pkg.go.dev/github.com/shogo82148/go-webntp)\n\n# WebNTP\n\nWebNTP is NTP(-like) service via HTTP/WebSocket.\n\n## Synopsis\n\nFirst, `go install` and start the WebNTP Server.\n\n``` plain\n$ go install github.com/shogo82148/go-webntp/cmd/webntp\n$ webntp -serve :8080\n```\n\nSync with the server via HTTP.\n\n``` plain\n$ webntp http://localhost:8080/\nserver http://localhost:8080/, offset -0.000066, delay 0.001453\n2017-03-11 18:25:10.905049427 +0900 JST, server http://localhost:8080/, offset -0.000066\n```\n\nSync with the server via WebSocket.\n\n``` plain\n$ webntp ws://localhost:8080/\nserver ws://localhost:8080/, offset -0.000013, delay 0.000288\n2017-03-11 18:25:36.668531757 +0900 JST, server ws://localhost:8080/, offset -0.000013\n```\n\nI provide a public WebNTP API.\n\n``` plain\n$ webntp https://webntp.shogo82148.com/api\nserver https://webntp.shogo82148.com/api, offset -0.006376, delay 0.024411\n2017-03-11 16:08:06.150393313 +0900 JST, server https://webntp.shogo82148.com/api, offset -0.006376\n```\n\n## Shared Memory support for ntpd\n\nAdd a new server to your `ntpd.conf`.\n\n``` plain\nserver 127.127.28.2 noselect\nfudge 127.127.28.2 refid PYTH stratum 10\n```\n\nRun WebNTP with `-shm 2` option.\n\n``` plain\n$ webntp -p 1 -shm 2 https://webntp.shogo82148.com/api\nserver https://webntp.shogo82148.com/api, offset -0.003258, delay 0.018910\n```\n\nntpd starts syncing with WebNTP.\n\n``` plain\n$ ntpq -p\n     remote           refid      st t when poll reach   delay   offset  jitter\n==============================================================================\n SHM(2)          .PYTH.          10 l    2   64   17    0.000   -3.331   0.384\n*webntp.shogo82. .NICT.           1 u   58   64   37   10.280    1.494   2.028\n```\n\n\n## Usage\n\n``` plain\n$ webntp --help\n  -allow-cross-origin\n    \tallow cross origin request\n  -help\n    \tshow help\n  -leap-second-path string\n    \tpath for leap-seconds.list cache (default \"leap-seconds.list\")\n  -leap-second-url string\n    \turl for leap-seconds.list (default \"https://www.ietf.org/timezones/data/leap-seconds.list\")\n  -p int\n    \tSpecify the number of samples (default 4)\n  -serve string\n    \tserver host name\n  -shm uint\n    \tntpd shared-memory-segment\n```\n\n\n## Protocol\n\n### JSON over HTTP\n\nThe WebNTP clients access to `http://example.com/?\u003ctimestamp\u003e`,\nand then the WebNTP server returns the time information formatted by JSON.\n\n- `id`: hostname of the server\n- `it`: the client's timestamp of the request transmission\n- `st`: the server's timestamp\n- `leap`: the seconds of TAI - UTC (before `next`)\n- `next`: the timestamp of the next or last leap second \n- `step`: positive leap second: 1, negative leap second: -1\n\nExample:\n\n``` plain\n$ curl -s http://localhost:8080/?1489217288.328757 | jq .\n{\n  \"id\": \"localhost:8080\",\n  \"it\": 1489217288.328757,\n  \"st\": 1489224472.995564,\n  \"time\": 1489224472.995564,\n  \"leap\": 36,\n  \"next\": 1483228800,\n  \"step\": 1\n}\n```\n\nIt is based on [the document of http/https service](https://jjy.nict.go.jp/QandA/reference/http-archive.html) by NICT (the National Institute of Information and Communications Technology).\n(the content is written in Japanese)\n\n### JSON over WebSocket\n\nThe WebNTP clients send a message including timestamp,\nand then the WebNTP server returns the time information formatted by JSON.\nJSON format is same as HTTP response.\n\nExample:\n\n```plain\n$ wscat --connect localhost:8080\nconnected (press CTRL+C to quit)\n\u003e 1558915619.944235\n\u003c {\"id\":\"localhost:8080\",\"it\":1558915619.944235,\"st\":1558916776.363423,\"time\":1558916776.363423,\"leap\":36,\"next\":1483228800.000000,\"step\":1}\n```\n\n### Time over HTTPS with Improved timekeeping response\n\nThe clients send `HEAD /.well-known/time` HTTP request,\nand then the server returns the timestamp in the response header.\n\n```plain\nX-HTTPSTIME: \u003ctimestamp\u003e\n```\n\nExample:\n\n```plain\n$ curl -I localhost:8080\nHTTP/1.1 204 No Content\nX-Httpstime: 1558915632.285965\nDate: Mon, 27 May 2019 00:07:12 GMT\n```\n\nIt is based on [Time over HTTPS specification](http://phk.freebsd.dk/time/20151129/).\n\n## License\n\nThis software is released under the MIT License, see LICENSE.\n\n\n## SEE ALSO\n\n- [Time over HTTPS](http://phk.freebsd.dk/time/20151129/)\n- [htp](http://www.vervest.org/htp/)\n- [http/httpsを利用した時刻配信(アーカイブ)](https://jjy.nict.go.jp/QandA/reference/http-archive.html) (The time server using http/https (archived))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshogo82148%2Fgo-webntp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshogo82148%2Fgo-webntp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshogo82148%2Fgo-webntp/lists"}