kiwiirc / kiwibnc

Apache License 2.0
44 stars 14 forks source link

Add hooks to disallow networks #24

Closed DanielOaks closed 5 years ago

DanielOaks commented 5 years ago

Extensions and kiwibnc admins may wish to do this in future, this lets extensions do so.

prawnsalad commented 5 years ago

I can't see how the state.disallowed is being used anywhere? clientcontrol.js and clientcommands.js both check it before it would be set by an extension, so they could both be removed from there?

And then in connectionoutgoing.js, if hook.prevent then it can simply return without doing anything. It's down to the extension to send any warnings/errors/notices down to the client as the reason and actions are entirely down to the extension and unknown by the core bnc.

DanielOaks commented 5 years ago

state.disallowed is used to send the correct messages to clients (e.g. KiwiIRC) that try to manually connect networks, or that e.g. have already added a network and it's being disallowed after the fact on a new reboot/rehash of the bouncer. If it's not used there, KiwiIRC does not correctly display the 'This network is disallowed' message to end users and instead shows 'Connecting to network' with no follow-up or anything. This is where it could be better integrated with the BOUNCER subsystem down the line, but for now having those explicitly-sent messages does help users work out what's going on.

Ah, that's interesting. I can change it over to remove the explicit action there in that case, though the two calls in clientcontrol.js and clientcommands.js will also need to be taken over by the extension in that case... This is gonna take a bit of thinking I reckon.

DanielOaks commented 5 years ago

Alright, yeah letting the extension handle it all works fine after refreshing the bouncer. My guess is that there was some strange left-over data that was messing with it and making it not act as expected. In the meantime I'll see whether we can hack together something to make KiwiIRC show it as no longer connecting when it gets that notice from the bouncer.

prawnsalad commented 5 years ago

Nice, this looks much cleaner now