| 89 | super.close(); |
| 90 | } |
| 91 | callback(message, value) { |
| 92 | if (Socket.readable !== message) |
| 93 | return; |
| 94 | |
| 95 | if (48 !== value) |
| 96 | this.failed("unexpected SNTP packet length"); |
| 97 | else |
| 98 | if (4 !== (7 & this.read(Number))) // NTP server mode |
| 99 | this.failed("unexpected SNTP packet first byte"); |
| 100 | else if (0 === this.read(Number)) { |
| 101 | this.read(null); // clear unread |
| 102 | return; // Kiss-o'-Death - "...KoD packets have no protocol significance and are discarded after inspection" |
| 103 | } |
| 104 | else { |
| 105 | this.read(null, 38); |
| 106 | const time = toNumber(this.read(Number), this.read(Number), this.read(Number), this.read(Number)); |
| 107 | this.close(); |
| 108 | return this.#callback(SNTP.time, time); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | static time = 1; |
| 113 | static retry = 2; |