blob: 3873c00afec4cf3eb899959abc285e1cc9d744ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
# T6981:
# - remove "service dns dynamic name <service> protocol googledomains"
# - remove "service dns dynamic name <service> protocol woima"
# - remove "service dns dynamic name <service> address web url ..."
# when url is https://domains.google.com/*
import re
from vyos.base import Warning
from vyos.configtree import ConfigTree
base_path = ['service', 'dns', 'dynamic', 'name']
def migrate(config: ConfigTree) -> None:
if not config.exists(base_path):
# Nothing to do
return
for service in config.list_nodes(base_path):
service_path = base_path + [service]
# Remove configurations using protocol 'googledomains' and 'woima'
if config.exists(service_path + ['protocol']):
protocol = config.return_value(service_path + ['protocol'])
if protocol in ['googledomains', 'woima']:
Warning(f'Removing {service} using protocol "{protocol}" because the service has been shutdown')
config.delete(service_path)
# Look for 'address web' with 'url' set to 'googledomains' or 'https://domains.google.com'
# and remove them so that ddclient defaults apply for 'address web'
if config.exists(service_path + ['address', 'web']):
web_addr_path = service_path + ['address', 'web']
if config.exists(web_addr_path + ['url']):
url = config.return_value(web_addr_path + ['url'])
if url == 'googledomains' or re.search(r'^(https?://)?domains\.google\.com', url):
config.delete(web_addr_path + ['url'])
if config.exists(web_addr_path + ['skip']):
config.delete(web_addr_path + ['skip'])
|