mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
37 lines
763 B
Python
37 lines
763 B
Python
from lnbits.extensions.subdomains.models import Subdomains
|
|
|
|
# Python3 program to validate
|
|
# domain name
|
|
# using regular expression
|
|
import re
|
|
import socket
|
|
|
|
# Function to validate domain name.
|
|
def isValidDomain(str):
|
|
# Regex to check valid
|
|
# domain name.
|
|
regex = "^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}"
|
|
# Compile the ReGex
|
|
p = re.compile(regex)
|
|
|
|
# If the string is empty
|
|
# return false
|
|
if str == None:
|
|
return False
|
|
|
|
# Return if the string
|
|
# matched the ReGex
|
|
if re.search(p, str):
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
# Function to validate IP address
|
|
def isvalidIPAddress(str):
|
|
try:
|
|
socket.inet_aton(str)
|
|
return True
|
|
except socket.error:
|
|
return False
|