mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-28 18:08:51 +03:00
30c6676dc0
Merge in DNS/adguard-home from AG-25392-confmigrate-vol.3 to master Squashed commit of the following: commit 925b35b9fedcdcf18474785530189a1eb504e1d6 Merge: 232f18481581891af2
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Sep 6 12:48:05 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.3 commit 232f18481bbf3400da0b95bcec7949fb3868bf85 Merge: c0d880bed5bd452516
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Sep 5 18:54:47 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.3 commit c0d880bed6e3270e88f5377e66b787565e1249ce Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Sep 5 17:21:57 2023 +0300 confmigrate: fix v15 commit 8a27148b708e6d6a61f8097bf7792aefa1055772 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Sep 5 15:47:18 2023 +0300 confmigrate: imp gocognit, overall
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package confmigrate
|
|
|
|
// migrateTo7 performs the following changes:
|
|
//
|
|
// # BEFORE:
|
|
// 'schema_version': 6
|
|
// 'dhcp':
|
|
// 'enabled': false
|
|
// 'interface_name': vboxnet0
|
|
// 'gateway_ip': '192.168.56.1'
|
|
// 'subnet_mask': '255.255.255.0'
|
|
// 'range_start': '192.168.56.10'
|
|
// 'range_end': '192.168.56.240'
|
|
// 'lease_duration': 86400
|
|
// 'icmp_timeout_msec': 1000
|
|
// # …
|
|
//
|
|
// # AFTER:
|
|
// 'schema_version': 7
|
|
// 'dhcp':
|
|
// 'enabled': false
|
|
// 'interface_name': vboxnet0
|
|
// 'dhcpv4':
|
|
// 'gateway_ip': '192.168.56.1'
|
|
// 'subnet_mask': '255.255.255.0'
|
|
// 'range_start': '192.168.56.10'
|
|
// 'range_end': '192.168.56.240'
|
|
// 'lease_duration': 86400
|
|
// 'icmp_timeout_msec': 1000
|
|
// # …
|
|
func migrateTo7(diskConf yobj) (err error) {
|
|
diskConf["schema_version"] = 7
|
|
|
|
dhcp, ok, _ := fieldVal[yobj](diskConf, "dhcp")
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
dhcpv4 := yobj{}
|
|
err = coalesceError(
|
|
moveSameVal[string](dhcp, dhcpv4, "gateway_ip"),
|
|
moveSameVal[string](dhcp, dhcpv4, "subnet_mask"),
|
|
moveSameVal[string](dhcp, dhcpv4, "range_start"),
|
|
moveSameVal[string](dhcp, dhcpv4, "range_end"),
|
|
moveSameVal[int](dhcp, dhcpv4, "lease_duration"),
|
|
moveSameVal[int](dhcp, dhcpv4, "icmp_timeout_msec"),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
dhcp["dhcpv4"] = dhcpv4
|
|
|
|
return nil
|
|
}
|