Page 1 of 1

How to block a client in custom module?

Posted: Sat Oct 09, 2010 11:04 am
by RDXdev
Hi,

In my module in some cases I have to block connected clients.
How could I do it with "kline"-command?
Is it possible to send this command with

Code: Select all

sendto_one(sptr, ":noticebot kline +user@host <time in sec> <message>");
where aClient *sptr?

Or should I do it in other way.

How to get user@host information from aClient *sptr structure?

Thank you for help!

Re: How to block a client in custom module?

Posted: Sat Oct 09, 2010 1:19 pm
by katsklaw
What is the point is having an ircd module that has server access use/create a bot to perform client level commands?

Re: How to block a client in custom module?

Posted: Mon Oct 11, 2010 9:59 am
by RDXdev
There is an extended definition of flooding which can't be checked with usual UnrealIRCd filters.
My module do this extended flood checks. When the flood detected I would like to block the clients which are flooding.
How could I do it?
My idea was to use "kline".

Re: How to block a client in custom module?

Posted: Thu Oct 14, 2010 3:09 pm
by RDXdev
Nobody knows?

Re: How to block a client in custom module?

Posted: Thu Oct 14, 2010 5:27 pm
by Syzop
Since the modules API is indeed highly underdocumented, you are best off with checking existing modules, how they do it.
Like, have a look at my nopost module, or AntiMoon, or AntiRandom, etc...

Re: How to block a client in custom module?

Posted: Mon Nov 01, 2010 5:13 pm
by RDXdev
Syzop wrote:Since the modules API is indeed highly underdocumented, you are best off with checking existing modules, how they do it.
Like, have a look at my nopost module, or AntiMoon, or AntiRandom, etc...
Thank you, it was helpful.
By now I have another problem. I'm using the function place_host_ban() in function banflood_filter_msg() called in HOOKTYPE_USERMSG and HOOKTYPE_CHANMSG. And after the function banflood_filter_msg() returns the ircd-server crashes. Without place_host_ban() it works fine but didn't do what it expected to do :(.

In comment to place_host_ban() is written: "(you should NOT read from 'sptr' after you got FLUSH_BUFFER!!!)". In my case there is other module(s) which use HOOKTYPE_USERMSG and HOOKTYPE_CHANMSG and I can't prevent them from reading from 'sptr' (at least I don't know how to do it).

What am I doing wrong?
Is there another solution how to ban a user in this case?

Thank you for answers!

Re: How to block a client in custom module?

Posted: Sun Nov 14, 2010 5:51 pm
by Syzop
You're right, the current hook API does not allow you to do this. It does not allow you to signal the fact that you've killed the client.

Perhaps you could use: dead_link(sptr, "reason here")

That would kill the client. It would not add a *LINE. Though, you can do that yourself if you duck into place_host_ban() routine and copy relevant parts.. like all up to and including calling the m_tkl() layer, but leaving out the find_tkline_match() stuff.

Good luck.