[mirrorbrain-commits] [opensuse-svn] r6556 - trunk/tools/download-redirector-v2/mod_mirrorbrain

From: Novell Forge SVN <noreply_at_novell.com>
Date: Tue, 24 Feb 2009 09:25:42 -0700 (MST)
Author: poeml
Date: 2009-02-24 09:25:39 -0700 (Tue, 24 Feb 2009)
New Revision: 6556

Modified:
   trunk/tools/download-redirector-v2/mod_mirrorbrain/mod_mirrorbrain.c
Log:
mod_mirrorbrain:
- allow to override the client IP's autonomous system by query parameter
  (?as=[0-9]*)


Modified: trunk/tools/download-redirector-v2/mod_mirrorbrain/mod_mirrorbrain.c
===================================================================
--- trunk/tools/download-redirector-v2/mod_mirrorbrain/mod_mirrorbrain.c	2009-02-24 16:20:49 UTC (rev 6555)
+++ trunk/tools/download-redirector-v2/mod_mirrorbrain/mod_mirrorbrain.c	2009-02-24 16:25:39 UTC (rev 6556)
@@ -590,6 +590,7 @@
     const char *user_agent = NULL;
     const char *clientip = NULL;
     const char *query_country = NULL;
+    char *query_asn = NULL;
     char fakefile = 0, newmirror = 0;
     char mirrorlist = 0, mirrorlist_txt = 0;
     char metalink_forced = 0;                   /* metalink was explicitely requested */
@@ -688,6 +689,7 @@
         if (form_lookup(r, "fakefile")) fakefile = 1;
         clientip = form_lookup(r, "clientip");
         query_country = form_lookup(r, "country");
+        query_asn = (char *) form_lookup(r, "as");
         if (form_lookup(r, "newmirror")) newmirror = 1;
         if (form_lookup(r, "mirrorlist")) mirrorlist =1;
         if (form_lookup(r, "metalink")) metalink_forced = 1;
@@ -700,6 +702,12 @@
         query_country = NULL;
     }
 
+    if (query_asn) {
+        for (i = 0; apr_isdigit(query_asn[i]); i++)
+            ;
+        query_asn[i] = '\0';
+    }
+
     if (!mirrorlist_txt && !metalink_forced && !mirrorlist) {
         const char *accepts;
         accepts = apr_table_get(r->headers_in, "Accept");
@@ -949,9 +957,13 @@
 
     /* see if we find info about autonomous system and network prefix
      * in the subprocess environment - set for us by mod_asn */
-    as = apr_table_get(r->subprocess_env, "ASN");
-    if (!as) {
-        as = "--";
+    if (query_asn && (query_asn[0] != '\0')) {
+        as = query_asn;
+    } else {
+        as = apr_table_get(r->subprocess_env, "ASN");
+        if (!as) {
+            as = "--";
+        }
     }
     prefix = apr_table_get(r->subprocess_env, "PFX");
     if (!prefix) {

_______________________________________________
Opensuse-svn mailing list
Opensuse-svn_at_forge.novell.com
http://forge.novell.com/mailman/listinfo/opensuse-svn


_______________________________________________
mirrorbrain-commits mailing list

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on 2009-02-24Z16:26:03

This archive was generated by hypermail 2.2.0 : 2009-07-10Z19:18:11 GMT