optimize: smoothly migrate option portSharing from ipforward

This commit is contained in:
mzz2017 committed 2021-09-24 23:23:04 +08:00
1 parent 859dfbd00c
commit f76d1fd8ff
1 file changed
+9 -1
+9 -1
View File
@@ -235,7 +235,15 @@ func GetSubscriptionV2(index int) *SubscriptionRawV2 {
func GetSettingNotNil() *Setting {
r := new(Setting)
_ = db.Get("system", "setting", r)
b, e := db.GetRaw("system", "setting")
if e == nil {
_ = jsoniter.Unmarshal(b, r)
// migrate
if gjson.GetBytes(b, "ipforward").Exists() &&
!gjson.GetBytes(b, "portSharing").Exists() {
r.PortSharing = r.IpForward
}
}
_ = common.FillEmpty(r, NewSetting())
if r.SpecialMode == "" {
r.SpecialMode = SpecialModeNone