def chkInput(src): # Determine the input, if we can. src_out = (None, None) try: ipaddress.IPv4Address(src) return(('ipv4', src)) except ipaddress.AddressValueError: pass try: ipaddress.IPv6Address(src) return(('ipv6', src)) except ipaddress.AddressValueError: pass _p = os.path.abspath(os.path.expanduser(src)) if os.path.isfile(_p): return(('file', _p)) # Last shot - is it a DNS record? # Not quite perfect, as it's strictly RFC and there are plenty of # subdomains out there that break RFC. f = fqdn.FQDN(src) if f.is_valid: return(('dns', src)) return(src_out)
def is_valid_fqdn(self, domain): """Test if a provided domain is a valid FQDN.""" is_valid_fqdn = fqdn.FQDN(domain).is_valid return is_valid_fqdn
def is_valid_fqdn(domain): """Return True/False if a provided domain is a valid FQDN, not necessarily if it contains a valid top level domain.""" domain_is_valid_fqdn = fqdn.FQDN(domain).is_valid return domain_is_valid_fqdn
except mariadb.Error as e: logging.critical(f"Database - Main Conection to Database Failed! {e}") sys.exit(1) except IndexError: logging.critical( "Database - No Database Conection Creditals Provided in /skylabpanel/main.conf !" ) else: cur = conn.cursor() #conn.autocommit=True logging.info("Database - Main Conection to Database Successful!") ############ ### FQDN ### ############ system_fqdn = fqdn.FQDN(socket.getfqdn()) if system_fqdn.is_valid_relative == True: fqdn_or_ip = socket.getfqdn() elif system_fqdn.is_valid_relative == False: fqdn_or_ip = socket.gethostbyname(socket.gethostname()) else: logging.critical("Network - Failed to get Valid IP or FQDN") ################# ### Main Page ### ################# @app.route('/') def home_page(): if 'username' in session: return render_template('base.html')