poeml / mirrorbrain

MirrorBrain
http://mirrorbrain.org/
Other
75 stars 44 forks source link

Get mirrorlist for a given IP #163

Open rhertzog opened 7 years ago

rhertzog commented 7 years ago

I use the .mirrorlist URL a lot in Kali but I also often need to know what mirrors are considered for a given IP.

Right now the only way to approximate this is to add a "?country=XX" query parameter but this obviously does not allow to take into account the AS realm and has the drawback described in #80 too.

So please allow usage of ".mirrorlist?ip=X.X.X.X" (or same with IPv6 too) to retrieve the exact mirror list that a given IP would get.

Thank you!

poeml commented 7 years ago

Too bad, I was about to start hacking and implement this, because it seems to straightforward. However, it's not possible, because mod_mirrorbrain runs after mod_geoip/mod_geoip2/mod_maxminddb, which it relies upon. In other words, at the time mod_mirrorbrain runs it can read the ?ip= parameter from the URL, but it's too late to look up the GeoIP country and stuff. Thus, it can't be implemented or at least I don't see how.

Under certain circumstances you can still achieve what you asked for. Mod_geoip can respect HTTP headers and read the client up from there (such as is required in a configuration where Apache runs behind a proxy). mod_mirrorbrain looks only at environment variable GEOIP_ADDR, so by that it will also respect the headers that GeoIP read. (With the successor module mod_maxminddb, GEOIP_ADDR is renamed to MMDB_ADDR, which mod_mirrorbrain doesn't know yet.)

Look for 'Proxy-Related Directives' on http://dev.maxmind.com/geoip/legacy/mod_geoip2/ . Something like curl -s -H 'X-Forwarded-For: ...' http://... Should then do the job.