示例#1
0
def validate_bypass_dns():
    if not functions.matches_regex("^(yes|no)$", configuration_variables.BYPASS_DNS):
        print("Invalid 'bypass-dns' option: " + configuration_variables.BYPASS_DNS)
        quit()
    if configuration_variables.REDIRECT_ALL_TRAFFIC == "no" and configuration_variables.BYPASS_DNS != "no":
        print("Invalid 'bypass-dns' option: " + configuration_variables.BYPASS_DNS)
        print("The 'bypass-dns' option must be disabled when not redirecting all traffic.")
        quit()
示例#2
0
def validate_enable_clients_passwords_array():
    if len(configuration_variables.CLIENTS_ARRAY) != len(configuration_variables.ENABLE_CLIENTS_PASSWORDS_ARRAY):
        print("The number of clients should be equal to the number of password activation options.")
        quit()
    for i in range(len(configuration_variables.ENABLE_CLIENTS_PASSWORDS_ARRAY)):
        configuration_variables.ENABLE_CLIENTS_PASSWORDS_ARRAY[i] = configuration_variables.ENABLE_CLIENTS_PASSWORDS_ARRAY[i].lower()
        enable_password = configuration_variables.ENABLE_CLIENTS_PASSWORDS_ARRAY[i]
        if not functions.matches_regex("^(yes|no)$", enable_password):
            print("Invalid 'enable password' option: " + enable_password)
            quit()
示例#3
0
def validate_clients_array():
    for client in configuration_variables.CLIENTS_ARRAY:
        if not functions.matches_regex("^([a-zA-Z0-9_-]+)$", client):
            print("Invalid name: " + client)
            print("Please, do not use spaces or special characters.")
            quit()
示例#4
0
def validate_firewall_mode():
    configuration_variables.FIREWALL_MODE = configuration_variables.FIREWALL_MODE.lower()
    if not functions.matches_regex("^(limit|allow)$", configuration_variables.FIREWALL_MODE):
        print("Invalid mode: " + FIREWALL_MODE)
        quit()
示例#5
0
def validate_allow_duplicate_cn():
    configuration_variables.ALLOW_DUPLICATE_CN = configuration_variables.ALLOW_DUPLICATE_CN.lower()
    if not functions.matches_regex("^(yes|no)$", configuration_variables.ALLOW_DUPLICATE_CN):
        print("Invalid 'duplicate-cn' option: " + configuration_variables.ALLOW_DUPLICATE_CN)
        quit()
示例#6
0
def validate_allow_client_to_client():
    configuration_variables.ALLOW_CLIENT_TO_CLIENT = configuration_variables.ALLOW_CLIENT_TO_CLIENT.lower()
    if not functions.matches_regex("^(yes|no)$", configuration_variables.ALLOW_CLIENT_TO_CLIENT):
        print("Invalid 'client-to-client' option: " + configuration_variables.ALLOW_CLIENT_TO_CLIENT)
        quit()
示例#7
0
def validate_redirect_all_traffic():
    if not functions.matches_regex("^(yes|no)$", configuration_variables.REDIRECT_ALL_TRAFFIC):
        print("Invalid 'redirect-all-traffic' option: " + configuration_variables.REDIRECT_ALL_TRAFFIC)
        quit()
示例#8
0
def validate_server_protocol():
    configuration_variables.SERVER_PROTOCOL = configuration_variables.SERVER_PROTOCOL.lower()
    if not functions.matches_regex("^(udp|tcp)$", configuration_variables.SERVER_PROTOCOL):
        print("Invalid protocol: " + configuration_variables.SERVER_PROTOCOL)
        quit()
示例#9
0
def validate_server_name():
    if not functions.matches_regex("^([a-zA-Z0-9_-]+)$", configuration_variables.SERVER_NAME):
        print("Invalid name: " + configuration_variables.SERVER_NAME)
        print("Please, do not use spaces or special characters.")
        quit()
示例#10
0
def validate_enable_remote_random():
    configuration_variables.ENABLE_REMOTE_RANDOM = configuration_variables.ENABLE_REMOTE_RANDOM.lower()
    if not functions.matches_regex("^(yes|no)$", configuration_variables.ENABLE_REMOTE_RANDOM):
        print("Invalid 'remote-random' option: " + configuration_variables.ENABLE_REMOTE_RANDOM)
        quit()
示例#11
0
def matches_regex(regex, string):
    return functions.matches_regex(regex, string)
示例#12
0
 def test_matches_regex(self):
     self.assertTrue(functions.matches_regex("^\d$", "5"))
     self.assertFalse(functions.matches_regex("^\d$", "a"))