--- /dev/null
+#!/bin/bash
+# /usr/local/sbin/squid-redirector
+# Auteur : Progfou <jean-christophe.andre@auf.org>
+# Licence : Domaine public
+# Création : 2008-01-14
+# Dépendances : libwww-perl (pour la commande HEAD)
+#
+# TODO: À refaire en Perl ou Python, un jour...
+#
+# URL <SP> client_ip "/" fqdn <SP> user <SP> method <SP> urlgroup <NL>
+#
+# ATTENTION : le miroir est incomplet => ne pas tout rediriger bêtement !!
+#
+MIRROR="miroir.ndere.cm.refer.org"
+while read URL CLIENT USER METHOD GROUP
+do
+ [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.ubuntu.com\/ubuntu\//://${MIRROR}/ubuntu/}"
+ [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/*archive.ubuntu.com\/ubuntu\//://${MIRROR}/ubuntu/}"
+ [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.debian.org\//://${MIRROR}/debian-security/}"
+ [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/ftp*.debian.org\/debian\//://${MIRROR}/debian/}"
+ if [ "$URL2" != "$URL" ] && HEAD -t5 "$URL2" > /dev/null
+ then
+ echo "!mirror!$URL2"
+ else
+ echo "$URL"
+ fi
+done
+exit 0
--- /dev/null
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+
+# une petite inspiration de
+# http://gofedora.com/how-to-write-custom-redirector-rewritor-plugin-squid-python/
+
+import sys
+
+def modify_url(line):
+ list = line.split(' ')
+ #first element of the list is the URL
+ old_url = list[0]
+ new_url = '\n'
+ #take the decision and modify the URL if needed
+ #do remember that the new_url should contain a '\n' at the end.
+ if old_url.startswith('http://cm.archive'):
+ new_url = 'http://miroir.ndere.cm.refer.org' + new_url
+
+ return new_url
+
+while True:
+ line = sys.stdin.readline().strip()
+ new_url = modify_url(line)
+ sys.stdout.write(new_url)
+ sys.stdout.flush()
+++ /dev/null
-#!/bin/bash
-# /usr/local/sbin/squid-redirector
-# Auteur : Progfou <jean-christophe.andre@auf.org>
-# Licence : Domaine public
-# Création : 2008-01-14
-# Dépendances : libwww-perl (pour la commande HEAD)
-#
-# TODO: À refaire en Perl ou Python, un jour...
-#
-# URL <SP> client_ip "/" fqdn <SP> user <SP> method <SP> urlgroup <NL>
-#
-# ATTENTION : le miroir est incomplet => ne pas tout rediriger bêtement !!
-#
-MIRROR="miroir.ndere.cm.refer.org"
-while read URL CLIENT USER METHOD GROUP
-do
- [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.ubuntu.com\/ubuntu\//://${MIRROR}/ubuntu/}"
- [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/*archive.ubuntu.com\/ubuntu\//://${MIRROR}/ubuntu/}"
- [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.debian.org\//://${MIRROR}/debian-security/}"
- [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/ftp*.debian.org\/debian\//://${MIRROR}/debian/}"
- if [ "$URL2" != "$URL" ] && HEAD -t5 "$URL2" > /dev/null
- then
- echo "!mirror!$URL2"
- else
- echo "$URL"
- fi
-done
-exit 0