Chore: support MarshalYAML to some config filed (#581)
This commit is contained in:
parent
9471d80785
commit
082847b403
3 changed files with 12 additions and 3 deletions
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/Dreamacro/clash/log"
|
"github.com/Dreamacro/clash/log"
|
||||||
|
|
||||||
D "github.com/miekg/dns"
|
D "github.com/miekg/dns"
|
||||||
yaml "gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -46,8 +45,8 @@ func (e *EnhancedMode) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalYAML serialize EnhancedMode with yaml
|
// MarshalYAML serialize EnhancedMode with yaml
|
||||||
func (e EnhancedMode) MarshalYAML() ([]byte, error) {
|
func (e EnhancedMode) MarshalYAML() (interface{}, error) {
|
||||||
return yaml.Marshal(e.String())
|
return e.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unserialize EnhancedMode with json
|
// UnmarshalJSON unserialize EnhancedMode with json
|
||||||
|
|
|
@ -55,6 +55,11 @@ func (l LogLevel) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(l.String())
|
return json.Marshal(l.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalYAML serialize LogLevel with yaml
|
||||||
|
func (l LogLevel) MarshalYAML() (interface{}, error) {
|
||||||
|
return l.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (l LogLevel) String() string {
|
func (l LogLevel) String() string {
|
||||||
switch l {
|
switch l {
|
||||||
case INFO:
|
case INFO:
|
||||||
|
|
|
@ -51,6 +51,11 @@ func (m TunnelMode) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(m.String())
|
return json.Marshal(m.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalYAML serialize TunnelMode with yaml
|
||||||
|
func (m TunnelMode) MarshalYAML() (interface{}, error) {
|
||||||
|
return m.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m TunnelMode) String() string {
|
func (m TunnelMode) String() string {
|
||||||
switch m {
|
switch m {
|
||||||
case Global:
|
case Global:
|
||||||
|
|
Loading…
Reference in a new issue