AdGuardHome/internal/configmigrate/v7.go

58 lines
1.3 KiB
Go
Raw Normal View History

package configmigrate
Pull request 1991: AG-25392 confmigrate vol.2 Merge in DNS/adguard-home from AG-25392-confmigrate-vol.2 to master Squashed commit of the following: commit 7bcdf443135523022a7e5ed6b2da05fcd784a896 Merge: 4c25331b5 f84ff2bd0 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:33:08 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.2 commit 4c25331b507078670e7f3505384b53179a210292 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:14:23 2023 +0300 confmigrate: fix fmt commit d7dbfc46a7f825d248cb028d50b60eede941bf67 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:07:25 2023 +0300 confmigrate: imp code commit cd29729a23d1782a0b5fbd1e9153fe61ff3dbc71 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 18:21:14 2023 +0300 confmigrate: imp code, split files commit f075a14c251c68a13152709e14a326ad17c2f889 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 17:19:47 2023 +0300 confmigrate: imp code commit 37335597e7870184528c1d868e2d5bd5525a74bb Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 16:54:13 2023 +0300 confmigrate: imp code, docs commit 1df0ddcad99e5056b4989d17490ca4b44ae17838 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 14:41:52 2023 +0300 all: add testdata commit e62690dbe8e458811bbd6b115b4449affa729560 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Aug 31 16:13:14 2023 +0300 all: imp code commit 0934d5974b31a58b31b12412c3cd1a50810ffc4f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:50:52 2023 +0300 home: don't reread config commit 7566ab6f330460bd608aae6dc0428a631e2fa4e3 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:43:57 2023 +0300 all: imp code commit 6f6aae6290f8d3101f3678ecc705eee7030ad8d5 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:25:46 2023 +0300 all: introduce confmigrate
2023-09-04 18:45:50 +01:00
import "github.com/AdguardTeam/golibs/errors"
Pull request 1991: AG-25392 confmigrate vol.2 Merge in DNS/adguard-home from AG-25392-confmigrate-vol.2 to master Squashed commit of the following: commit 7bcdf443135523022a7e5ed6b2da05fcd784a896 Merge: 4c25331b5 f84ff2bd0 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:33:08 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.2 commit 4c25331b507078670e7f3505384b53179a210292 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:14:23 2023 +0300 confmigrate: fix fmt commit d7dbfc46a7f825d248cb028d50b60eede941bf67 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:07:25 2023 +0300 confmigrate: imp code commit cd29729a23d1782a0b5fbd1e9153fe61ff3dbc71 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 18:21:14 2023 +0300 confmigrate: imp code, split files commit f075a14c251c68a13152709e14a326ad17c2f889 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 17:19:47 2023 +0300 confmigrate: imp code commit 37335597e7870184528c1d868e2d5bd5525a74bb Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 16:54:13 2023 +0300 confmigrate: imp code, docs commit 1df0ddcad99e5056b4989d17490ca4b44ae17838 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 14:41:52 2023 +0300 all: add testdata commit e62690dbe8e458811bbd6b115b4449affa729560 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Aug 31 16:13:14 2023 +0300 all: imp code commit 0934d5974b31a58b31b12412c3cd1a50810ffc4f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:50:52 2023 +0300 home: don't reread config commit 7566ab6f330460bd608aae6dc0428a631e2fa4e3 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:43:57 2023 +0300 all: imp code commit 6f6aae6290f8d3101f3678ecc705eee7030ad8d5 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:25:46 2023 +0300 all: introduce confmigrate
2023-09-04 18:45:50 +01:00
// 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) {
Pull request 1991: AG-25392 confmigrate vol.2 Merge in DNS/adguard-home from AG-25392-confmigrate-vol.2 to master Squashed commit of the following: commit 7bcdf443135523022a7e5ed6b2da05fcd784a896 Merge: 4c25331b5 f84ff2bd0 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:33:08 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.2 commit 4c25331b507078670e7f3505384b53179a210292 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:14:23 2023 +0300 confmigrate: fix fmt commit d7dbfc46a7f825d248cb028d50b60eede941bf67 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:07:25 2023 +0300 confmigrate: imp code commit cd29729a23d1782a0b5fbd1e9153fe61ff3dbc71 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 18:21:14 2023 +0300 confmigrate: imp code, split files commit f075a14c251c68a13152709e14a326ad17c2f889 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 17:19:47 2023 +0300 confmigrate: imp code commit 37335597e7870184528c1d868e2d5bd5525a74bb Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 16:54:13 2023 +0300 confmigrate: imp code, docs commit 1df0ddcad99e5056b4989d17490ca4b44ae17838 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 14:41:52 2023 +0300 all: add testdata commit e62690dbe8e458811bbd6b115b4449affa729560 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Aug 31 16:13:14 2023 +0300 all: imp code commit 0934d5974b31a58b31b12412c3cd1a50810ffc4f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:50:52 2023 +0300 home: don't reread config commit 7566ab6f330460bd608aae6dc0428a631e2fa4e3 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:43:57 2023 +0300 all: imp code commit 6f6aae6290f8d3101f3678ecc705eee7030ad8d5 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:25:46 2023 +0300 all: introduce confmigrate
2023-09-04 18:45:50 +01:00
diskConf["schema_version"] = 7
dhcp, ok, _ := fieldVal[yobj](diskConf, "dhcp")
if !ok {
Pull request 1991: AG-25392 confmigrate vol.2 Merge in DNS/adguard-home from AG-25392-confmigrate-vol.2 to master Squashed commit of the following: commit 7bcdf443135523022a7e5ed6b2da05fcd784a896 Merge: 4c25331b5 f84ff2bd0 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:33:08 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.2 commit 4c25331b507078670e7f3505384b53179a210292 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:14:23 2023 +0300 confmigrate: fix fmt commit d7dbfc46a7f825d248cb028d50b60eede941bf67 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:07:25 2023 +0300 confmigrate: imp code commit cd29729a23d1782a0b5fbd1e9153fe61ff3dbc71 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 18:21:14 2023 +0300 confmigrate: imp code, split files commit f075a14c251c68a13152709e14a326ad17c2f889 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 17:19:47 2023 +0300 confmigrate: imp code commit 37335597e7870184528c1d868e2d5bd5525a74bb Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 16:54:13 2023 +0300 confmigrate: imp code, docs commit 1df0ddcad99e5056b4989d17490ca4b44ae17838 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 14:41:52 2023 +0300 all: add testdata commit e62690dbe8e458811bbd6b115b4449affa729560 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Aug 31 16:13:14 2023 +0300 all: imp code commit 0934d5974b31a58b31b12412c3cd1a50810ffc4f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:50:52 2023 +0300 home: don't reread config commit 7566ab6f330460bd608aae6dc0428a631e2fa4e3 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:43:57 2023 +0300 all: imp code commit 6f6aae6290f8d3101f3678ecc705eee7030ad8d5 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:25:46 2023 +0300 all: introduce confmigrate
2023-09-04 18:45:50 +01:00
return nil
}
dhcpv4 := yobj{}
err = errors.Join(
Pull request 1991: AG-25392 confmigrate vol.2 Merge in DNS/adguard-home from AG-25392-confmigrate-vol.2 to master Squashed commit of the following: commit 7bcdf443135523022a7e5ed6b2da05fcd784a896 Merge: 4c25331b5 f84ff2bd0 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:33:08 2023 +0300 Merge branch 'master' into AG-25392-confmigrate-vol.2 commit 4c25331b507078670e7f3505384b53179a210292 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:14:23 2023 +0300 confmigrate: fix fmt commit d7dbfc46a7f825d248cb028d50b60eede941bf67 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 20:07:25 2023 +0300 confmigrate: imp code commit cd29729a23d1782a0b5fbd1e9153fe61ff3dbc71 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 18:21:14 2023 +0300 confmigrate: imp code, split files commit f075a14c251c68a13152709e14a326ad17c2f889 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 17:19:47 2023 +0300 confmigrate: imp code commit 37335597e7870184528c1d868e2d5bd5525a74bb Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 16:54:13 2023 +0300 confmigrate: imp code, docs commit 1df0ddcad99e5056b4989d17490ca4b44ae17838 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Sep 4 14:41:52 2023 +0300 all: add testdata commit e62690dbe8e458811bbd6b115b4449affa729560 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Aug 31 16:13:14 2023 +0300 all: imp code commit 0934d5974b31a58b31b12412c3cd1a50810ffc4f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:50:52 2023 +0300 home: don't reread config commit 7566ab6f330460bd608aae6dc0428a631e2fa4e3 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:43:57 2023 +0300 all: imp code commit 6f6aae6290f8d3101f3678ecc705eee7030ad8d5 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Aug 30 15:25:46 2023 +0300 all: introduce confmigrate
2023-09-04 18:45:50 +01:00
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
}