# Copyright VyOS maintainers and contributors # # 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 . # T6981: # - remove "service dns dynamic name protocol googledomains" # - remove "service dns dynamic name protocol woima" # - remove "service dns dynamic name 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'])