OSDN Git Service

* Fixed Bug.
authorAtsushi Konno <konn@users.sourceforge.jp>
Thu, 3 Mar 2011 16:56:58 +0000 (01:56 +0900)
committerAtsushi Konno <konn@users.sourceforge.jp>
Thu, 3 Mar 2011 16:56:58 +0000 (01:56 +0900)
    - overwrite X-Client-Type (with mod_cidr_lookup)

include/mod_chxj.h
src/mod_chxj.c

index f9af7da..feaa46a 100755 (executable)
@@ -404,6 +404,7 @@ struct mod_chxj_config {
 #define CONVRULE_EMOJI_ONLY_BIT       (0x00001000)
 #define CONVRULE_ENVINFO_ONLY_BIT     (0x00002000)
 #define CONVRULE_COOKIE_ONLY_BIT      (0x00004000)
+#define CONVRULE_OVERWRITE_X_CLIENT_TYPE_BIT (0x00008000)
 
 #define CONVRULE_ENGINE_ON_CMD        "EngineOn"
 #define CONVRULE_ENGINE_OFF_CMD       "EngineOff"
@@ -425,6 +426,7 @@ struct mod_chxj_config {
 #define CONVRULE_EMOJI_ONLY_CMD       "EmojiOnly"
 #define CONVRULE_ENVINFO_ONLY_CMD     "EnvInfoOnly"
 #define CONVRULE_COOKIE_ONLY_CMD      "CookieOnly"
+#define CONVRULE_OVERWRITE_X_CLIENT_TYPE_CMD "OverwriteXClientType"
 
 
 #define CONVRULE_FLAG_NOTMATCH        (0x00000001)
@@ -460,6 +462,7 @@ typedef struct {
 #define HTTP_HOST             "Host"
 #define CHXJ_HTTP_USER_AGENT  "CHXJ_HTTP_USER_AGENT"
 #define CHXJ_HEADER_ORIG_CLIENT_IP "X-Chxj-Orig-Client-Ip"
+#define CHXJ_HEADER_ORIG_CLIENT_TYPE "X-Chxj-Orig-Client-Type"
 
 module AP_MODULE_DECLARE_DATA chxj_module;
 
index e3a13eb..b1094e3 100755 (executable)
@@ -294,6 +294,13 @@ chxj_headers_fixup(request_rec *r)
         DBG(r, "REQ[%X] Client IP:[%s] vs Orig Client IP:[%s] vs Server IP:[%s]", (unsigned int)(apr_size_t)r, r->connection->remote_ip, client_ip, addr);
         if (strcmp(addr, r->connection->remote_ip) == 0) {
           r->connection->remote_ip = apr_pstrdup(r->connection->pool, client_ip);
+          /* For mod_cidr_lookup */
+          if (entryp->action & CONVRULE_OVERWRITE_X_CLIENT_TYPE_BIT) {
+            char *client_type = (char *)apr_table_get(r->headers_in, CHXJ_HEADER_ORIG_CLIENT_TYPE);
+            DBG(r, "REQ[%X] Overwrite X-Client-Type to [%s]", (unsigned int)(apr_size_t)r, client_type);
+            apr_table_setn(r->subprocess_env, "X_CLIENT_TYPE", client_type);
+            apr_table_setn(r->headers_in, "X-Client-Type", client_type);
+          }
         }
         if (! apr_table_get(r->headers_in, "Content-Length")) {
           contentLength = (char *)apr_table_get(r->headers_in, "X-Chxj-Content-Length");
@@ -1515,6 +1522,7 @@ chxj_input_handler(request_rec *r)
 
   apr_size_t res_len;
   apr_table_setn(r->headers_in, CHXJ_HEADER_ORIG_CLIENT_IP, r->connection->remote_ip);
+  apr_table_setn(r->headers_in, CHXJ_HEADER_ORIG_CLIENT_TYPE, apr_table_get(r->headers_in, "X-Client-Type")); /* for mod_cidr_lookup */
   apr_table_unset(r->headers_in, "Content-Length");
   apr_table_setn(r->headers_in, "Content-Length", apr_psprintf(pool, "%" APR_SIZE_T_FMT, post_data_len));
   response = chxj_serf_post(r, pool, url_path, post_data, post_data_len, 1, &res_len, &response_code);
@@ -2577,6 +2585,13 @@ cmd_convert_rule(cmd_parms *cmd, void *mconfig, const char *arg)
       }
       break;
 
+    case 'O':
+    case 'o':
+      if (strcasecmp(CONVRULE_OVERWRITE_X_CLIENT_TYPE_CMD, action) == 0) {
+        newrule->action |= CONVRULE_OVERWRITE_X_CLIENT_TYPE_BIT;
+      }
+      break;
+
     case 'C':
     case 'c':
       if (strcasecmp(CONVRULE_COOKIE_ON_CMD, action) == 0) {