provisionircd / ProvisionIRCd

A modern IRCd written in Python 3.10
GNU General Public License v3.0
23 stars 3 forks source link

"Q" TKL / Q:Lines are never enforced #16

Closed strlcat closed 3 days ago

strlcat commented 2 months ago

There is probably a logic bug where Q:Lines are never enforced:

Such TKLs never work

Y4kuzi commented 2 months ago

The Tkl.mask is a property of the Tkl object, which returns the following:

@property
    def mask(self):
        return Tkl.get_mask(self.type, self.ident, self.host)

The mask is not always the same as a host. Q:lines are a perfect example of this. For example, Q:lines do not require an ident to work since they are based on nicknames. This is the reason that Q:lines have '*' as ident because it has no value in this context. The mask simply is in format of ident@host.

Before a Q:line gets checked, the nickname will be in the place of the host value. This is why in m_tkl() the 'newnick' gets passed as 'host' argument in sqline_check_pre_nick(). The ident value gets ignored because it's not relevant in this context.

So basically, when this happens:

    @staticmethod
    def find_tkl_by_mask(tkltype, mask):
        for tkl in [tkl for tkl in Tkl.table if tkl.type == tkltype]:
            if is_match(tkl.mask.lower(), mask.lower()):
                return tkl

the Tkl object 'property' gets called, which in turn will call Tkl.get_mask():

    @staticmethod
    def get_mask(tkltype, ident, host):
        if ident in Tkl.ext_names:
            return f"{Tkl.ext_names[ident]}{host}"
        elif tkltype in Tkl.get_flags_host_format():
            return f"{ident}@{host}"
        else:
            return host

It will check to see if the 'tkltype' (in this case 'Q') has the attribute Tkl.host_format (Q:lines do not have this attribute), so it will only return the host portion.

It's actually checking if "newnick" matches "newnick" which will always be true. I choose this so that is it easily compatible with other host-based bans and exceptions.

Check out #15 and let me know if it works now :)

strlcat commented 2 months ago

Ok sure, and it seems that we have already quite divergent versions running. I will test yours once I will be home today. Thank you

4 сентября 2024 г. 21:38:40 UTC, Y4kuzi @.***> пишет:

The Tkl.mask is a property of the Tkl object, which returns the following:

@property
   def mask(self):
       return Tkl.get_mask(self.type, self.ident, self.host)

The mask is not always the same as a host. Q:lines are a perfect example of this. For example, Q:lines do not require an ident to work since they are based on nicknames. This is the reason that Q:lines have '*' as ident because it has no value in this context. The mask simply is in format of @.***

Before a Q:line gets checked, the nickname will be in the place of the host value. This is why in m_tkl() the 'newnick' gets passed as 'host' argument in sqline_check_pre_nick(). The ident value gets ignored because it's not relevant in this context.

So basically, when this happens:

   @staticmethod
   def find_tkl_by_mask(tkltype, mask):
       for tkl in [tkl for tkl in Tkl.table if tkl.type == tkltype]:
           if is_match(tkl.mask.lower(), mask.lower()):
               return tkl

the Tkl object 'property' gets called, which in turn will call Tkl.get_mask():

   @staticmethod
   def get_mask(tkltype, ident, host):
       if ident in Tkl.ext_names:
           return f"{Tkl.ext_names[ident]}{host}"
       elif tkltype in Tkl.get_flags_host_format():
           return f"{ident}@{host}"
       else:
           return host

It will check to see if the 'tkltype' (in this case 'Q') has the attribute Tkl.host_format (Q:lines do not have this attribute), so it will only return the host portion.

It's actually checking if "newnick" matches "newnick" which will always be true. I choose this so that is it easily compatible with other host-based bans and exceptions.

Check out #15 and let me know if it works now :)

-- Reply to this email directly or view it on GitHub: https://github.com/provisionircd/ProvisionIRCd/issues/16#issuecomment-2330190839 You are receiving this because you authored the thread.

Message ID: @.***>