def banish(self): if not self.exists: return make_request(TORRC_PREFIX + self.user, "delete") ports = [] block = get_block({"user": self.user}) ports.append((block["bind_address"], block["bind_port"])) config.get(None, "listen").remove(block) block = get_block({"user": self.user, "ssl": 1}) ports.append((block["bind_address"], block["bind_port"])) config.get(None, "listen").remove(block) config.write_config() return ports
def manage_chan(self, user, line, deny=True): if not config.get(user, 'oper') or utilities.validate(line, 2): return allow_chans = Set([]) deny_chans = Set([]) blocks = [] for listen in config.get(None, 'listen'): if 'user' in listen and listen['user'] == line[1]: blocks.append(listen) if not blocks: user.srv_notice('%s: [!] User not found: %s' % (user.info['nick'], line[1])) return action = 'Allow' if deny: action = 'Deny' user.srv_notice('%s : [*] %sing channel: %s' % (user.info['nick'], action, line[2])) for block in blocks: def merge(elem, chans): if elem not in block: return chans.update(block[elem]) merge('chan_allow', allow_chans) merge('chan_deny', deny_chans) if deny: allow_chans.discard(line[2]) deny_chans.add(line[2]) else: allow_chans.add(line[2]) deny_chans.discard(line[2]) for block in blocks: block['chan_allow'] = list(allow_chans) block['chan_deny'] = list(deny_chans) config.write_config()
def load_config(): try: return Configuration("config.toml") except FileNotFoundError: from lib.config import generate_config, write_config generated = generate_config() towrite = write_config(generated, "config.toml") if towrite: return Configuration("config.toml") else: sys.exit("Couldn't load the configuration")
def create(self): if self.exists: return standard_port = find_sock() ssl_port = find_sock([standard_port]) make_request(TORRC_PREFIX + self.user, "create") make_request(TORRC_PREFIX + self.user, "map", 6667, config.get(None, "default_address"), standard_port) make_request(TORRC_PREFIX + self.user, "map", 6697, config.get(None, "default_address"), ssl_port) config.get(None, "listen").append( {"bind_address": config.get(None, "default_address"), "bind_port": standard_port, "user": self.user} ) config.get(None, "listen").append( {"bind_address": config.get(None, "default_address"), "bind_port": ssl_port, "user": self.user, "ssl": 1} ) config.write_config() return [ (config.get(None, "default_address"), standard_port, 0), (config.get(None, "default_address"), ssl_port, 1), ]
def step_configure_dnf(context): """ Merges the new configuration values with what is stored in DNFContext and writes the config file at <installroot>/etc/dnf/dnf.conf. [main] is the default section, you can add more sections like so: Given I configure dnf with | key | value | | best | False | | [my_section] | | | foo | bar | """ check_context_table(context, ["key", "value"]) section = "[main]" context.dnf.config.setdefault(section, {}) for k, v in context.table: if k.startswith("[") and v == "": section = k context.dnf.config.setdefault(section, {}) context.dnf.config[section][k] = v write_config(context)