|
|
@ -11,11 +11,12 @@ from urllib.parse import urlparse
|
|
|
|
from xmrnodes.helpers import determine_crypto
|
|
|
|
from xmrnodes.helpers import determine_crypto
|
|
|
|
from xmrnodes.forms import SubmitNode
|
|
|
|
from xmrnodes.forms import SubmitNode
|
|
|
|
from xmrnodes.models import Node
|
|
|
|
from xmrnodes.models import Node
|
|
|
|
|
|
|
|
from xmrnodes import config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.INFO,
|
|
|
|
level=logging.INFO,
|
|
|
|
format='%(asctime)s - %(levelname)s - %(message)s'
|
|
|
|
format="%(asctime)s - %(levelname)s - %(message)s"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
app = Flask(__name__)
|
|
|
@ -61,16 +62,16 @@ def add():
|
|
|
|
if request.method == "POST":
|
|
|
|
if request.method == "POST":
|
|
|
|
url = request.form.get("node_url")
|
|
|
|
url = request.form.get("node_url")
|
|
|
|
regex = re.compile(
|
|
|
|
regex = re.compile(
|
|
|
|
r'^(?:http)s?://' # http:// or https://
|
|
|
|
r"^(?:http)s?://" # http:// or https://
|
|
|
|
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
|
|
|
|
r"(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|" #domain...
|
|
|
|
r'localhost|' #localhost...
|
|
|
|
r"localhost|" #localhost...
|
|
|
|
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
|
|
|
|
r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" # ...or ip
|
|
|
|
r'(?::\d+)?' # optional port
|
|
|
|
r"(?::\d+)?" # optional port
|
|
|
|
r'(?:/?|[/?]\S+)$', re.IGNORECASE
|
|
|
|
r"(?:/?|[/?]\S+)$", re.IGNORECASE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
re_match = re.match(regex, url)
|
|
|
|
re_match = re.match(regex, url)
|
|
|
|
if re_match is None:
|
|
|
|
if re_match is None:
|
|
|
|
flash("This doesn't look like a valid URL")
|
|
|
|
flash("This doesn\"t look like a valid URL")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
_url = urlparse(url)
|
|
|
|
_url = urlparse(url)
|
|
|
|
url = f"{_url.scheme}://{_url.netloc}"
|
|
|
|
url = f"{_url.scheme}://{_url.netloc}"
|
|
|
@ -152,9 +153,9 @@ def validate():
|
|
|
|
logging.info("failed for reasons unknown")
|
|
|
|
logging.info("failed for reasons unknown")
|
|
|
|
node.delete_instance()
|
|
|
|
node.delete_instance()
|
|
|
|
|
|
|
|
|
|
|
|
@app.template_filter('humanize')
|
|
|
|
@app.template_filter("humanize")
|
|
|
|
def humanize(d):
|
|
|
|
def humanize(d):
|
|
|
|
t = arrow.get(d, 'UTC')
|
|
|
|
t = arrow.get(d, "UTC")
|
|
|
|
return t.humanize()
|
|
|
|
return t.humanize()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|