Exemplo n.º 1
0
    def verifyConfig(self, config):
        if "rate_soft_limit" in config:
            if not isinstance(config["rate_soft_limit"],
                              int) or config["rate_soft_limit"] < 0:
                raise ConfigValidationError("rate_soft_limit",
                                            "invalid number")
            if config["rate_soft_limit"] == 0:
                self.ircd.logConfigValidationWarning(
                    "rate_soft_limit", "a value of 0 will block everything", 1)
                config["rate_soft_limit"] = 1
        else:
            config["rate_soft_limit"] = 60

        if "rate_kill_limit" in config:
            if not isinstance(config["rate_kill_limit"],
                              int) or config["rate_kill_limit"] < 0:
                raise ConfigValidationError("rate_kill_limit",
                                            "invalid number")
            if config["rate_kill_limit"] == 0:
                self.ircd.logConfigValidationWarning(
                    "rate_kill_limit",
                    "a value of 0 will kill everyone; what's the point of having a server?",
                    1)
                config["rate_kill_limit"] = 1
        else:
            config["rate_kill_limit"] = 500

        if "rate_interval" in config:
            if not isinstance(config["rate_interval"],
                              int) or config["rate_interval"] < 0:
                raise ConfigValidationError("rate_interval", "invalid number")
        else:
            config["rate_interval"] = 60
Exemplo n.º 2
0
 def verifyConfig(self, config):
     if "public_info" in config:
         if not isinstance(config["public_info"], list):
             raise ConfigValidationError("public_info",
                                         "value must be a list")
         for info in config["public_info"]:
             if not isinstance(info, basestring):
                 raise ConfigValidationError(
                     "public_info", "every entry must be a string")
Exemplo n.º 3
0
 def verifyConfig(self, config):
     if "channel_minimum_level" in config and not isinstance(
             config["channel_minimum_level"], dict):
         raise ConfigValidationError("channel_minimum_level",
                                     "value must be a dictionary")
     if "channel_exempt_level" in config and not isinstance(
             config["channel_exempt_level"], dict):
         raise ConfigValidationError("channel_exempt_level",
                                     "value must be a dictionary")
Exemplo n.º 4
0
 def verifyConfig(self, config):
     for option in ("deny_channels", "allow_channels"):
         if option in config:
             if not isinstance(config[option], list):
                 raise ConfigValidationError(option, "value must be a list")
             for chanName in config[option]:
                 if not isinstance(chanName, basestring) or not chanName:
                     raise ConfigValidationError(
                         option, "\"{}\" is an invalid channel name".format(
                             chanName))
Exemplo n.º 5
0
 def verifyConfig(self, config):
     if "shun_commands" in config:
         if not isinstance(config["shun_commands"], list):
             raise ConfigValidationError("shun_commands",
                                         "value must be a list")
         for command in config["shun_commands"]:
             if not isinstance(command, basestring):
                 raise ConfigValidationError(
                     "shun_commands",
                     "\"{}\" is not a valid command".format(command))
Exemplo n.º 6
0
 def verifyConfig(self, config):
     if "whowas_duration" in config and not isinstance(
             config["whowas_duration"], basestring) and not isinstance(
                 config["whowas_duration"], int):
         raise ConfigValidationError(
             "whowas_duration",
             "value must be an integer or a duration string")
     if "whowas_max_entries" in config and (
             not isinstance(config["whowas_max_entries"], int)
             or config["whowas_max_entries"] < 0):
         raise ConfigValidationError("whowas_max_entries", "invalid number")
Exemplo n.º 7
0
 def verifyConfig(self, config):
     if "client_join_on_connect" in config:
         if not isinstance(config["client_join_on_connect"], list):
             raise ConfigValidationError("client_join_on_connect",
                                         "value must be a list")
         for chanName in config["client_join_on_connect"]:
             if chanName[0] != "#":
                 chanName = "#{}".format(chanName)
             if not isValidChannelName(chanName):
                 raise ConfigValidationError(
                     "client_join_on_connect",
                     "\"{}\" is an invalid channel name".format(chanName))
Exemplo n.º 8
0
 def verifyConfig(self, config):
     if "admin_line_1" in config and not isinstance("admin_server",
                                                    basestring):
         raise ConfigValidationError("admin_server",
                                     "value must be a string")
     if "admin_line_2" in config and not isinstance("admin_admin",
                                                    basestring):
         raise ConfigValidationError("admin_admin",
                                     "value must be a string")
     if "admin_contact" in config and not isinstance(
             "admin_email", basestring):
         raise ConfigValidationError("admin_email",
                                     "value must be a string")
Exemplo n.º 9
0
 def verifyConfig(self, config):
     if "autoconnect_period" in config and (
             not isinstance(config["autoconnect_period"], int)
             or config["autoconnect_period"] < 0):
         raise ConfigValidationError("autoconnect_period", "invalid number")
     if "autoconnect" in config:
         if not isinstance(config["autoconnect"], list):
             raise ConfigValidationError("autoconnect",
                                         "value must be a list")
         for server in config["autoconnect"]:
             if not isinstance(server, basestring):
                 raise ConfigValidationError(
                     "autoconnect", "every entry must be a string")
Exemplo n.º 10
0
 def verifyConfig(self, config):
     if "starttls_key" in config:
         if not isinstance(config["starttls_key"], basestring):
             raise ConfigValidationError("starttls_key",
                                         "value must be a file name")
     else:
         config[
             "starttls_key"] = "server.pem"  # We'll use the Twisted default for endpoints here
     if "starttls_cert" in config:
         if not isinstance(config["starttls_cert"], basestring):
             raise ConfigValidationError("starttls_cert",
                                         "value must be a file name")
     else:
         config["starttls_cert"] = config["starttls_key"]
Exemplo n.º 11
0
 def verifyConfig(self, config):
     if "connlimit_globmax" in config and (
             not isinstance(config["connlimit_globmax"], int)
             or config["connlimit_globmax"] < 0):
         raise ConfigValidationError("connlimit_globmax", "invalid number")
     if "connlimit_whitelist" in config:
         if not isinstance(config["connlimit_whitelist"], list):
             raise ConfigValidationError("connlimit_whitelist",
                                         "value must be a list")
         for ip in config["connlimit_whitelist"]:
             if not isinstance(ip, basestring):
                 raise ConfigValidationError(
                     "connlimit_whitelist",
                     "every entry must be a valid ip")
Exemplo n.º 12
0
	def verifyConfig(self, config):
		if "topic_length" in config:
			if not isinstance(config["topic_length"], int) or config["topic_length"] < 0:
				raise ConfigValidationError("topic_length", "invalid number")
			elif config["topic_length"] > 326:
				config["topic_length"] = 326
				self.ircd.logConfigValidationWarning("topic_length", "value is too large", 326)
Exemplo n.º 13
0
 def verifyConfig(self, config):
     if "monitor_limit" not in config:
         config["monitor_limit"] = None
         return
     if not isinstance(config["monitor_limit"],
                       int) or config["monitor_limit"] < 0:
         raise ConfigValidationError("monitor_limit", "invalid number")
Exemplo n.º 14
0
 def verifyConfig(self, config):
     if "metadata_limit" in config:
         if config["metadata_limit"] is not None and (
                 not isinstance(config["metadata_limit"], int)
                 or config["metadata_limit"] < 0):
             raise ConfigValidationError(
                 "metadata_limit", "invalid number and not null value")
     else:
         config["metadata_limit"] = None
Exemplo n.º 15
0
 def verifyConfig(self, config):
     if "away_length" in config:
         if not isinstance(config["away_length"],
                           int) or config["away_length"] < 0:
             raise ConfigValidationError("away_length", "invalid number")
         elif config["away_length"] > 200:
             config["away_length"] = 200
             self.ircd.logConfigValidationWarning("away_length",
                                                  "value is too large", 200)
Exemplo n.º 16
0
 def verifyConfig(self, config):
     if "quit_message_length" in config:
         if not isinstance(config["quit_message_length"],
                           int) or config["quit_message_length"] < 0:
             raise ConfigValidationError("quit_message_length",
                                         "invalid number")
         elif config["quit_message_length"] > 370:
             config["quit_message_length"] = 370
             self.ircd.logConfigValidationWarning("quit_message_length",
                                                  "value is too large", 370)
Exemplo n.º 17
0
 def verifyConfig(self, config):
     if "cloaking_salt" in config:
         if not isinstance(config["cloaking_salt"], basestring):
             raise ConfigValidationError("cloaking_salt",
                                         "value must be a string")
         if not config["cloaking_salt"]:
             self.ircd.log.warn(
                 "No cloaking salt was found in the config. Host cloaks will be insecure!"
             )
     else:
         self.ircd.log.warn(
             "No cloaking salt was found in the config. Host cloaks will be insecure!"
         )
     if "cloaking_prefix" in config and not isValidHost(
             config["cloaking_prefix"]
     ):  # Make sure the prefix will not make the cloak an invalid hostname
         raise ConfigValidationError(
             "cloaking_prefix",
             "value must be a string and must not contain any invalid hostname characters"
         )
Exemplo n.º 18
0
	def verifyConfig(self, config):
		if "message_length" in config:
			if not isinstance(config["message_length"], int) or config["message_length"] < 0:
				raise ConfigValidationError("message_length", "invalid number")
			elif config["message_length"] > 324:
				config["message_length"] = 324
				self.ircd.logConfigValidationWarning("message_length", "value is too large", 324)
			elif config["message_length"] < 100:
				config["message_length"] = 100
				self.ircd.logConfigValidationWarning("message_length", "value is too small to be useful", 100)
		else:
			config["message_length"] = 324
Exemplo n.º 19
0
 def verifyConfig(self, config):
     if "custom_prefixes" in config:
         if not isinstance(config["custom_prefixes"], dict):
             raise ConfigValidationError("custom_prefixes",
                                         "value must be a dictionary")
         for prefix, prefixValue in config["custom_prefixes"].iteritems():
             if len(prefix) != 1:
                 raise ConfigValidationError(
                     "custom_prefixes",
                     "prefix value \"{}\" should be a mode character")
             if "level" not in prefixValue:
                 raise ConfigValidationError(
                     "custom_prefixes",
                     "value \"level\" for prefix \"{}\" is missing".format(
                         prefix))
             if "char" not in prefixValue:
                 raise ConfigValidationError(
                     "custom_prefixes",
                     "value \"char\" for prefix \"{}\" is missing".format(
                         prefix))
             if not isinstance(prefixValue["level"], int):
                 raise ConfigValidationError(
                     "custom_prefixes",
                     "prefix \"{}\" does not specify a valid level")
             if not isinstance(prefixValue["char"],
                               basestring) or len(prefixValue["char"]) != 1:
                 raise ConfigValidationError(
                     "custom_prefixes",
                     "prefix \"{}\" does not specify a valid prefix character"
                 )
Exemplo n.º 20
0
	def verifyConfig(self, config):
		if "server_password" in config and not isinstance(config["server_password"], basestring):
			raise ConfigValidationError("server_password", "value must be a string")
Exemplo n.º 21
0
    def verifyConfig(self, config):
        if "oper_types" in config:
            if not isinstance(config["oper_types"], dict):
                raise ConfigValidationError("oper_types",
                                            "value must be a dictionary")
            for operType, permissions in config["oper_types"].iteritems():
                if not isinstance(operType, basestring):
                    raise ConfigValidationError(
                        "oper_types", "every oper type must be a string")
                if not isinstance(permissions, list):
                    raise ConfigValidationError(
                        "oper_types",
                        "permissions for oper type \"{}\" must be a list".
                        format(operType))
                for permission in permissions:
                    if not isinstance(permission, basestring):
                        raise ConfigValidationError(
                            "oper_types",
                            "every permission for oper type \"{}\" must be a string"
                            .format(operType))
        else:
            config["oper_types"] = {}

        if "oper_groups" in config:
            if not isinstance(config["oper_groups"], dict):
                raise ConfigValidationError("oper_groups",
                                            "value must be a dictionary")
            for groupName, values in config["oper_groups"].iteritems():
                if not isinstance(groupName, basestring):
                    raise ConfigValidationError(
                        "oper_groups", "all group names must be strings")
                if not isinstance(values, dict):
                    raise ConfigValidationError("oper_groups",
                                                "group data must be a dict")
                for groupDataKey, groupDataValue in values.iteritems():
                    if not isinstance(groupDataKey, basestring):
                        raise ConfigValidationError(
                            "oper_groups",
                            "group data identifiers for oper group \"{}\" must all be strings"
                            .format(groupName))
                    if groupDataKey == "vhost" and (
                            not isinstance(groupDataValue, basestring)
                            or not isValidHost(groupDataValue)):
                        raise ConfigValidationError(
                            "oper_groups",
                            "vhosts for oper group \"{}\" must all be valid hostnames"
                            .format(groupName))
                    if groupDataKey == "types":
                        if not isinstance(groupDataValue, list):
                            raise ConfigValidationError(
                                "oper_groups",
                                "oper type lists for oper group \"{}\" must all be lists"
                                .format(groupName))
                        for operType in groupDataValue:
                            if not isinstance(operType, basestring):
                                raise ConfigValidationError(
                                    "oper_groups",
                                    "all oper type names for oper group \"{}\" must be strings"
                                    .format(groupName))
                            if operType not in config["oper_types"]:
                                raise ConfigValidationError(
                                    "oper_groups",
                                    "the type \"{}\" for oper group \"{}\" does not exist as an oper type"
                                    .format(operType, groupName))
        else:
            config["oper_groups"] = {}

        if "opers" in config:
            if not isinstance(config["opers"], dict):
                raise ConfigValidationError("opers",
                                            "value must be a dictionary")
            for operName, values in config["opers"].iteritems():
                if not isinstance(values, dict):
                    raise ConfigValidationError("opers",
                                                "oper data must be a dict")
                hasPassword = False
                for operDataKey, operDataValue in values.iteritems():
                    if not isinstance(operDataKey, basestring):
                        raise ConfigValidationError(
                            "opers",
                            "oper data identifiers must all be strings")
                    if operDataKey == "password":
                        if not isinstance(operDataValue, basestring):
                            raise ConfigValidationError(
                                "opers",
                                "no password defined for oper \"{}\"".format(
                                    operName))
                        hasPassword = True
                    if operDataKey == "hash" and not isinstance(
                            operDataValue, basestring):
                        raise ConfigValidationError(
                            "opers",
                            "hash type for oper \"{}\" must be a string name".
                            format(operName))
                    if operDataKey == "host" and not isinstance(
                            operDataValue, basestring):
                        raise ConfigValidationError(
                            "opers",
                            "hosts for oper \"{}\" must be a string".format(
                                operName))
                    if operDataKey == "vhost" and (
                            not isinstance(operDataValue, basestring)
                            or not isValidHost(operDataValue)):
                        raise ConfigValidationError(
                            "opers",
                            "vhost for oper \"{}\" must be a valid hostname".
                            format(operName))
                    if operDataKey == "types":
                        if not isinstance(operDataValue, list):
                            raise ConfigValidationError(
                                "opers",
                                "type list for oper \"{}\" must be a list".
                                format(operName))
                        for operType in operDataValue:
                            if not isinstance(operType, basestring):
                                raise ConfigValidationError(
                                    "opers",
                                    "every type name for oper \"{}\" must be a string"
                                    .format(operName))
                            if operType not in config["oper_types"]:
                                raise ConfigValidationError(
                                    "opers",
                                    "the type \"{}\" for oper \"{}\" does not exist as an oper type"
                                    .format(operType, operName))
                    if operDataKey == "group":
                        if not isinstance(operDataValue, basestring):
                            raise ConfigValidationError(
                                "opers",
                                "the group name for oper \"{}\" must be a string"
                                .format(operName))
                        if operDataValue not in config["oper_groups"]:
                            raise ConfigValidationError(
                                "opers",
                                "the group \"{}\" for oper \"{}\" does not exist as an oper group"
                                .format(operDataValue, operName))
                if not hasPassword:
                    raise ConfigValidationError(
                        "opers",
                        "oper \"{}\" doesn't have a password specified".format(
                            operName))
Exemplo n.º 22
0
 def verifyConfig(self, config):
     if "knock_delay" in config and (not isinstance(
             config["knock_delay"], int) or config["knock_delay"] < 0):
         raise ConfigValidationError("knock_delay", "invalid number")
Exemplo n.º 23
0
 def verifyConfig(self, config):
     if "client_ban_msg" in config and not isinstance(
             config["client_ban_msg"], basestring):
         raise ConfigValidationError("client_ban_msg",
                                     "value must be a string")
Exemplo n.º 24
0
 def verifyConfig(self, config):
     if "client_umodes_on_connect" in config:
         if not isinstance(config["client_umodes_on_connect"], basestring):
             raise ConfigValidationError(
                 "client_umodes_on_connect",
                 "value must be a valid mode string")
Exemplo n.º 25
0
	def verifyConfig(self, config):
		if "channel_default_modes" in config and not isinstance("channel_default_modes", basestring):
			raise ConfigValidationError("channel_default_modes", "value must be a string of mode letters")