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 Fri, 22 Oct 2010 22:15:58 GMT
Hi Ben,

On Fri, Oct 22, 2010 at 11:54 PM, Ben Noordhuis <info@bnoordhuis.nl> wrote:
> On Fri, Oct 22, 2010 at 23:08, Alexander Farber
> <alexander.farber@gmail.com> wrote:
>> but don't know how to get the client socket via conn_rec?
>
> apr_socket_t *client  = ap_get_module_config(conn->conn_config, &core_module);
>
> But note that in most cases direct socket I/O is a bad idea.
>

are you sure that this is a correct command?
(I'm not experienced with Apache2)

And what do you mean by &core_module
in my case (source code below)?

Should I maybe try
apr_socket_t *socket = conn->cs->desc->s
or something similar instead?

And why is direct socket I/O bad idea,
isn't this how protocol handling modules (like mod_ftp, mod_smtp)
are supposed to work?

Greetings from Germany
Alex


#include <httpd.h>
#include <http_protocol.h>
#include <http_connection.h>
#include <http_config.h>
#include <http_log.h>

#define POLICY "<?xml version=\"1.0\"?>\n" \
              "<!DOCTYPE cross-domain-policy SYSTEM\n" \
              "\"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">\n" \
              "<cross-domain-policy>\n" \
              "<allow-access-from domain=\"*\" to-ports=\"8080\"/>\n" \
              "</cross-domain-policy>\0"

static int socket_policy_handler(conn_rec *conn) {

      /* XXX how access socket here? XXX */

       ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, conn->base_server,
               "served socket policy to %s", conn->remote_ip);

       return OK;
}

static void register_hooks(apr_pool_t *pool) {
       ap_hook_process_connection(socket_policy_handler, NULL, NULL,
APR_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA socket_policy_module = {
       STANDARD20_MODULE_STUFF,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       register_hooks
};

Mime
View raw message