httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Farber <alexander.far...@gmail.com>
Subject Re: How to access client socket from a protocol handler
Date Sun, 24 Oct 2010 09:09:19 GMT
On Sun, Oct 24, 2010 at 12:08 AM, Ben Noordhuis <info@bnoordhuis.nl> wrote:
> On Sun, Oct 24, 2010 at 00:00, Alexander Farber
> <alexander.farber@gmail.com> wrote:
>> I've created a module using bb (the source code at the bottom)
>> and it suffers from the same problem (hijacks the port 80 too).
>> Could it be that "SetHandler" is a wrong directive for protocol handler?
>
> The wrong directive, yes. SetHandler handlers work at the request
> level, protocol handlers at the connection level.
>
>> Also, I do not know, how to check that the
>> "handler is enabled for the current vhost".
>
> From mod_echo.c:
>
>  static int process_echo_connection(conn_rec *c)
>  {
>      EchoConfig *pConfig =
> ap_get_module_config(c->base_server->module_config, &echo_module);
>      if (!pConfig->bEnabled) {
>          return DECLINED;
>      }

So for content handlers the convention is
to use "SetHandler XXX" in httpd.conf and
then at the runtime they check for that string with

if (!r->handler || (strcmp(r->handler, "XXX") != 0)) {
    return DECLINED;
}

But for protocol handlers there is no such convention.
You have to introduce some keyword for httpd.conf
and check for it. Or in my case you could just:

        if (conn->base_server->port != 843)
                return DECLINED;

at the beginning? (seems to work)

Regards
Alex

Mime
View raw message