mirror of https://github.com/Dreamacro/clash.git
Chore: `mode` use lower case (backward compatible)
This commit is contained in:
parent
71d30e6654
commit
46244a6496
|
@ -92,8 +92,8 @@ allow-lan: false
|
|||
# "[aaaa::a8aa:ff:fe09:57d8]": bind a single IPv6 address
|
||||
# bind-address: "*"
|
||||
|
||||
# Rule / Global / Direct (default is Rule)
|
||||
mode: Rule
|
||||
# rule / global / direct (default is rule)
|
||||
mode: rule
|
||||
|
||||
# set log level to stdout (default is info)
|
||||
# info / warning / error / debug / silent
|
||||
|
|
|
@ -3,6 +3,7 @@ package tunnel
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type TunnelMode int
|
||||
|
@ -26,7 +27,7 @@ const (
|
|||
func (m *TunnelMode) UnmarshalJSON(data []byte) error {
|
||||
var tp string
|
||||
json.Unmarshal(data, &tp)
|
||||
mode, exist := ModeMapping[tp]
|
||||
mode, exist := ModeMapping[strings.ToLower(tp)]
|
||||
if !exist {
|
||||
return errors.New("invalid mode")
|
||||
}
|
||||
|
@ -38,7 +39,7 @@ func (m *TunnelMode) UnmarshalJSON(data []byte) error {
|
|||
func (m *TunnelMode) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var tp string
|
||||
unmarshal(&tp)
|
||||
mode, exist := ModeMapping[tp]
|
||||
mode, exist := ModeMapping[strings.ToLower(tp)]
|
||||
if !exist {
|
||||
return errors.New("invalid mode")
|
||||
}
|
||||
|
@ -59,11 +60,11 @@ func (m TunnelMode) MarshalYAML() (interface{}, error) {
|
|||
func (m TunnelMode) String() string {
|
||||
switch m {
|
||||
case Global:
|
||||
return "Global"
|
||||
return "global"
|
||||
case Rule:
|
||||
return "Rule"
|
||||
return "rule"
|
||||
case Direct:
|
||||
return "Direct"
|
||||
return "direct"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue