diff --git a/config/config.go b/config/config.go index 4a65a3e..db98490 100644 --- a/config/config.go +++ b/config/config.go @@ -21,8 +21,9 @@ type Global struct { UdpCheckDns string `mapstructure:"udp_check_dns" default:"dns.google:53"` CheckInterval time.Duration `mapstructure:"check_interval" default:"30s"` CheckTolerance time.Duration `mapstructure:"check_tolerance" default:"0"` - DnsUpstream string `mapstructure:"dns_upstream" default:""` - LanInterface []string `mapstructure:"lan_interface"` + // Deprecated: + DnsUpstream string `mapstructure:"dns_upstream" default:""` + LanInterface []string `mapstructure:"lan_interface"` // Deprecated: LanNatDirect bool `mapstructure:"lan_nat_direct" default:"false"` WanInterface []string `mapstructure:"wan_interface"` diff --git a/config/outline.go b/config/outline.go index 64760c1..7938269 100644 --- a/config/outline.go +++ b/config/outline.go @@ -18,13 +18,14 @@ type Outline struct { } type OutlineElem struct { - Name string `json:"name,omitempty"` - Mapping string `json:"mapping,omitempty"` - IsArray bool `json:"isArray,omitempty"` - Type string `json:"type,omitempty"` - ElemType string `json:"elemType,omitempty"` - Desc string `json:"desc,omitempty"` - Structure []*OutlineElem `json:"structure,omitempty"` + Name string `json:"name,omitempty"` + Mapping string `json:"mapping,omitempty"` + IsArray bool `json:"isArray,omitempty"` + DefaultValue string `json:"defaultValue,omitempty"` + Required bool `json:"required,omitempty"` + Type string `json:"type,omitempty"` + Desc string `json:"desc,omitempty"` + Structure []*OutlineElem `json:"structure,omitempty"` } func ExportOutline(version string) *Outline { @@ -101,13 +102,16 @@ func (e *outlineExporter) exportStruct(t reflect.Type, descSource Desc, inheritS // Record leaves. e.leaves[typ.String()] = typ } + _, required := section.Tag.Lookup("required") outlines = append(outlines, &OutlineElem{ - Name: section.Name, - Mapping: section.Tag.Get("mapstructure"), - IsArray: isArray, - Type: typ.String(), - Desc: desc, - Structure: children, + Name: section.Name, + Mapping: section.Tag.Get("mapstructure"), + IsArray: isArray, + DefaultValue: section.Tag.Get("default"), + Required: required, + Type: typ.String(), + Desc: desc, + Structure: children, }) } return outlines