fix: hostname validation when provided by config

This commit is contained in:
Simone Margaritelli 2019-10-24 18:12:10 +02:00
parent 4445ef6432
commit 97733cbf43
2 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import subprocess
import os import os
import logging import logging
import time import time
import re
import pwnagotchi.ui.view as view import pwnagotchi.ui.view as view
version = '1.1.0b' version = '1.1.0b'
@ -17,6 +18,10 @@ def set_name(new_name):
if new_name == '': if new_name == '':
return return
if not re.match(r'^[a-zA-Z0-9\-]{2,25}$', new_name):
logging.warning("name '%s' is invalid: min length is 2, max length 25, only a-zA-Z0-9- allowed", new_name)
return
current = name() current = name()
if new_name != current: if new_name != current:
global _name global _name

View File

@ -6,7 +6,7 @@
# #
# main algorithm configuration # main algorithm configuration
main: main:
# if set this will set the hostname of the unit # if set this will set the hostname of the unit. min length is 2, max length 25, only a-zA-Z0-9- allowed
name: '' name: ''
# currently implemented: en (default), de, el, fr, it, mk, nl, ru, se, pt-BR, es, pt # currently implemented: en (default), de, el, fr, it, mk, nl, ru, se, pt-BR, es, pt
lang: en lang: en