浏览代码

Fix missing omitempty for NTP server fields

世界 1 年之前
父节点
当前提交
cffc07579d
共有 2 个文件被更改,包括 4 次插入3 次删除
  1. 1 1
      ntp/service.go
  2. 3 2
      option/ntp.go

+ 1 - 1
ntp/service.go

@@ -33,7 +33,7 @@ type Service struct {
 
 func NewService(ctx context.Context, router adapter.Router, logger logger.Logger, options option.NTPOptions) (*Service, error) {
 	ctx, cancel := common.ContextWithCancelCause(ctx)
-	server := options.ServerOptions.Build()
+	server := M.ParseSocksaddrHostPort(options.Server, options.ServerPort)
 	if server.Port == 0 {
 		server.Port = 123
 	}

+ 3 - 2
option/ntp.go

@@ -1,9 +1,10 @@
 package option
 
 type NTPOptions struct {
-	Enabled       bool     `json:"enabled"`
+	Enabled       bool     `json:"enabled,omitempty"`
+	Server        string   `json:"server,omitempty"`
+	ServerPort    uint16   `json:"server_port,omitempty"`
 	Interval      Duration `json:"interval,omitempty"`
 	WriteToSystem bool     `json:"write_to_system,omitempty"`
-	ServerOptions
 	DialerOptions
 }