2024-09-25 20:08:23 -04:00
|
|
|
# sntp
|
|
|
|
--
|
2025-02-26 20:52:16 -05:00
|
|
|
import "github.com/go-i2p/go-i2p/lib/util/time/sntp"
|
|
|
|
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### type DefaultNTPClient
|
|
|
|
|
|
|
|
```go
|
|
|
|
type DefaultNTPClient struct{}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*DefaultNTPClient) QueryWithOptions
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (c *DefaultNTPClient) QueryWithOptions(host string, options ntp.QueryOptions) (*ntp.Response, error)
|
|
|
|
```
|
|
|
|
|
|
|
|
#### type NTPClient
|
|
|
|
|
2024-09-25 20:08:23 -04:00
|
|
|
```go
|
2025-02-26 20:52:16 -05:00
|
|
|
type NTPClient interface {
|
|
|
|
QueryWithOptions(host string, options ntp.QueryOptions) (*ntp.Response, error)
|
|
|
|
}
|
2024-09-25 20:08:23 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### type RouterTimestamper
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
```go
|
|
|
|
type RouterTimestamper struct {
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func NewRouterTimestamper
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
```go
|
|
|
|
func NewRouterTimestamper(client NTPClient) *RouterTimestamper
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func (*RouterTimestamper) AddListener
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) AddListener(listener UpdateListener)
|
|
|
|
```
|
|
|
|
|
|
|
|
#### func (*RouterTimestamper) GetCurrentTime
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) GetCurrentTime() time.Time
|
|
|
|
```
|
|
|
|
|
|
|
|
#### func (*RouterTimestamper) RemoveListener
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) RemoveListener(listener UpdateListener)
|
|
|
|
```
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
#### func (*RouterTimestamper) Start
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) Start()
|
|
|
|
```
|
|
|
|
|
|
|
|
#### func (*RouterTimestamper) Stop
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) Stop()
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func (*RouterTimestamper) TimestampNow
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) TimestampNow()
|
|
|
|
```
|
|
|
|
|
|
|
|
#### func (*RouterTimestamper) WaitForInitialization
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) WaitForInitialization()
|
|
|
|
```
|
|
|
|
|
|
|
|
#### type UpdateListener
|
|
|
|
|
|
|
|
```go
|
|
|
|
type UpdateListener interface {
|
|
|
|
SetNow(now time.Time, stratum uint8)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
UpdateListener is an interface that listeners must implement to receive time
|
|
|
|
updates.
|
|
|
|
|
|
|
|
#### type Zones
|
|
|
|
|
|
|
|
```go
|
|
|
|
type Zones struct {
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func NewZones
|
|
|
|
|
|
|
|
```go
|
|
|
|
func NewZones() *Zones
|
|
|
|
```
|
|
|
|
|
|
|
|
#### func (*Zones) GetZone
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (z *Zones) GetZone(countryCode string) string
|
|
|
|
```
|
|
|
|
|
|
|
|
# sntp
|
|
|
|
--
|
|
|
|
import "github.com/go-i2p/go-i2p/lib/util/time/sntp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
#### type DefaultNTPClient
|
|
|
|
|
|
|
|
```go
|
|
|
|
type DefaultNTPClient struct{}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*DefaultNTPClient) QueryWithOptions
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (c *DefaultNTPClient) QueryWithOptions(host string, options ntp.QueryOptions) (*ntp.Response, error)
|
|
|
|
```
|
|
|
|
|
|
|
|
#### type NTPClient
|
|
|
|
|
|
|
|
```go
|
|
|
|
type NTPClient interface {
|
|
|
|
QueryWithOptions(host string, options ntp.QueryOptions) (*ntp.Response, error)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### type RouterTimestamper
|
|
|
|
|
|
|
|
```go
|
|
|
|
type RouterTimestamper struct {
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### func NewRouterTimestamper
|
|
|
|
|
|
|
|
```go
|
|
|
|
func NewRouterTimestamper(client NTPClient) *RouterTimestamper
|
|
|
|
```
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
#### func (*RouterTimestamper) AddListener
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) AddListener(listener UpdateListener)
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func (*RouterTimestamper) GetCurrentTime
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) GetCurrentTime() time.Time
|
|
|
|
```
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
#### func (*RouterTimestamper) RemoveListener
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) RemoveListener(listener UpdateListener)
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func (*RouterTimestamper) Start
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
```go
|
2025-02-26 20:52:16 -05:00
|
|
|
func (rt *RouterTimestamper) Start()
|
2024-09-25 20:08:23 -04:00
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func (*RouterTimestamper) Stop
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) Stop()
|
|
|
|
```
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
#### func (*RouterTimestamper) TimestampNow
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) TimestampNow()
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func (*RouterTimestamper) WaitForInitialization
|
2024-09-25 20:08:23 -04:00
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
```go
|
|
|
|
func (rt *RouterTimestamper) WaitForInitialization()
|
|
|
|
```
|
|
|
|
|
|
|
|
#### type UpdateListener
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
```go
|
|
|
|
type UpdateListener interface {
|
2025-02-26 20:52:16 -05:00
|
|
|
SetNow(now time.Time, stratum uint8)
|
2024-09-25 20:08:23 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
UpdateListener is an interface that listeners must implement to receive time
|
|
|
|
updates.
|
2024-09-25 20:08:23 -04:00
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### type Zones
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
```go
|
|
|
|
type Zones struct {
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
#### func NewZones
|
2024-09-25 20:08:23 -04:00
|
|
|
|
|
|
|
```go
|
|
|
|
func NewZones() *Zones
|
|
|
|
```
|
|
|
|
|
|
|
|
#### func (*Zones) GetZone
|
|
|
|
|
|
|
|
```go
|
|
|
|
func (z *Zones) GetZone(countryCode string) string
|
|
|
|
```
|
|
|
|
|
2025-02-26 20:52:16 -05:00
|
|
|
|
|
|
|
|
|
|
|
sntp
|
|
|
|
|
|
|
|
github.com/go-i2p/go-i2p/lib/util/time/sntp
|