Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package MirrorCache for openSUSE:Factory checked in at 2023-08-10 15:34:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/MirrorCache (Old) and /work/SRC/openSUSE:Factory/.MirrorCache.new.11712 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "MirrorCache" Thu Aug 10 15:34:47 2023 rev:30 rq:1103287 version:1.062 Changes: -------- --- /work/SRC/openSUSE:Factory/MirrorCache/MirrorCache.changes 2023-07-27 16:53:19.942669868 +0200 +++ /work/SRC/openSUSE:Factory/.MirrorCache.new.11712/MirrorCache.changes 2023-08-10 15:35:00.488578270 +0200 @@ -1,0 +2,8 @@ +Thu Aug 03 08:42:06 UTC 2023 - Andrii Nikitin <andrii.niki...@suse.com> + +- Update to version 1.062: + * Add GEOIP config (#399) + * Add url parameter LIMIT fir number of mirrors in metalink (#399) + * Improve download report for multigroups (#398) + +------------------------------------------------------------------- Old: ---- MirrorCache-1.061.obscpio New: ---- MirrorCache-1.062.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ MirrorCache.spec ++++++ --- /var/tmp/diff_new_pack.gpFtVc/_old 2023-08-10 15:35:01.320583459 +0200 +++ /var/tmp/diff_new_pack.gpFtVc/_new 2023-08-10 15:35:01.324583483 +0200 @@ -22,7 +22,7 @@ %define main_requires %{assetpack_requires} perl(Carp) perl(DBD::Pg) >= 3.7.4 perl(DBI) >= 1.632 perl(DBIx::Class) >= 0.082801 perl(DBIx::Class::DynamicDefault) perl(DateTime) perl(Encode) perl(Time::Piece) perl(Time::Seconds) perl(Time::ParseDate) perl(DateTime::Format::Pg) perl(Exporter) perl(File::Basename) perl(LWP::UserAgent) perl(Mojo::Base) perl(Mojo::ByteStream) perl(Mojo::IOLoop) perl(Mojo::JSON) perl(Mojo::Pg) perl(Mojo::URL) perl(Mojo::Util) perl(Mojolicious::Commands) perl(Mojolicious::Plugin) perl(Mojolicious::Plugin::RenderFile) perl(Mojolicious::Static) perl(Net::OpenID::Consumer) perl(POSIX) perl(Sort::Versions) perl(URI::Escape) perl(XML::Writer) perl(base) perl(constant) perl(diagnostics) perl(strict) perl(warnings) shadow rubygem(sass) perl(Net::DNS) perl(LWP::Protocol::https) perl(Digest::SHA) perl(Config::IniFiles) %define build_requires %{assetpack_requires} rubygem(sass) tidy sysuser-shadow sysuser-tools Name: MirrorCache -Version: 1.061 +Version: 1.062 Release: 0 Summary: WebApp to redirect and manage mirrors License: GPL-2.0-or-later ++++++ MirrorCache-1.061.obscpio -> MirrorCache-1.062.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/assets/javascripts/reportdownloadtable.js new/MirrorCache-1.062/assets/javascripts/reportdownloadtable.js --- old/MirrorCache-1.061/assets/javascripts/reportdownloadtable.js 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/assets/javascripts/reportdownloadtable.js 2023-08-03 10:35:43.000000000 +0200 @@ -1,6 +1,7 @@ function setupReportDownloadTable(column) { // read columns from empty HTML table rendered by the server var columns = []; + var keys = column.split(','); columns.push({ data: 'dt', defaultContent: "", @@ -9,7 +10,20 @@ return date.toLocaleDateString(); } }); - columns.push({ data: column, defaultContent: "" }); + columns.push({ + data: column, + defaultContent: "", + render: function (data, type, row, meta) { + data = ""; + for (let i = 0; i < keys.length; i++) { + if (data != "") { + data = data + ','; + } + data = data + row[keys[i]]; + } + return data; + } + }); columns.push({ data: 'total_requests', defaultContent: "" }); columns.push({ data: 'known_files_requested', defaultContent: "" }); columns.push({ data: 'known_files_redirected', defaultContent: "" }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/lib/MirrorCache/Config.pm new/MirrorCache-1.062/lib/MirrorCache/Config.pm --- old/MirrorCache-1.061/lib/MirrorCache/Config.pm 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/lib/MirrorCache/Config.pm 2023-08-03 10:35:43.000000000 +0200 @@ -1,4 +1,4 @@ -# Copyright (C) 2022 SUSE LLC +# Copyright (C) 2022,2023 SUSE LLC # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,6 +55,8 @@ has browser_agent_mask => $ENV{MIRRORCACHE_BROWSER_AGENT_MASK} // '(?i)(firefox|msie|chrom|safari|seamonkey|opera|opr|trident).*'; +has geoip => undef; + sub init($self, $cfgfile) { my $db_provider = $ENV{MIRRORCACHE_DB_PROVIDER}; @@ -132,6 +134,22 @@ $self->offline_redirect_https(\@offline_redirect_https); } + my %geoip; + foreach (sort keys %ENV) { + my (undef, $reg) = split /MIRRORCACHE_GEOIP_(.*)/, $_; + next unless $reg; + $geoip{lc($reg)} = $ENV{$_}; + } + if ($cfg) { + my @param = $cfg->Parameters('default'); + for my $k (@param) { + my (undef, $reg) = split /geoip_(.*)/, $k; + next unless $reg; + $geoip{lc($reg)} = $cfg->val('default', $k); + } + } + + $self->geoip(\%geoip); return 1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/lib/MirrorCache/Datamodule.pm new/MirrorCache-1.062/lib/MirrorCache/Datamodule.pm --- old/MirrorCache-1.061/lib/MirrorCache/Datamodule.pm 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/lib/MirrorCache/Datamodule.pm 2023-08-03 10:35:43.000000000 +0200 @@ -29,6 +29,7 @@ has [ '_route', '_route_len' ]; # this is '/download' or '/browse' has [ 'route', 'route_len' ]; # this may be '/download' or '/browse' or empty if one of TOP_FOLDERS present has [ 'metalink', 'meta4', 'zsync', 'accept_all', 'accept_metalink', 'accept_meta4', 'accept_zsync' ]; +has [ 'metalink_limit' ]; # maximum mirrors to search for metalink has [ '_ip', '_country', '_region', '_lat', '_lng', '_vpn' ]; has [ '_avoid_countries' ]; has [ '_pedantic' ]; @@ -436,6 +437,12 @@ $self->_country($country); $self->_region($region // ''); + if (my $p = $query->param('LIMIT')) { + # check numeric value + if (int($p) > 0) { + $self->metalink_limit($p); + } + } } sub _glob2re { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/lib/MirrorCache/WebAPI/Controller/Rest/ReportDownload.pm new/MirrorCache-1.062/lib/MirrorCache/WebAPI/Controller/Rest/ReportDownload.pm --- old/MirrorCache-1.061/lib/MirrorCache/WebAPI/Controller/Rest/ReportDownload.pm 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/lib/MirrorCache/WebAPI/Controller/Rest/ReportDownload.pm 2023-08-03 10:35:43.000000000 +0200 @@ -50,8 +50,8 @@ next; } if ($p eq 'country') { - $tmp = $tmp . ', country'; - $key = $key . ", country"; + $tmp = $tmp . ', agg_download.country'; + $key = $key . ", agg_download.country"; next; } if ($p eq 'os') { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm new/MirrorCache-1.062/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm --- old/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/lib/MirrorCache/WebAPI/Plugin/RenderFileFromMirror.pm 2023-08-03 10:35:43.000000000 +0200 @@ -748,7 +748,9 @@ my $mirrorlist = $dm->mirrorlist; my $ipvstrict = $dm->ipvstrict; my $metalink = $dm->metalink || $dm->meta4 || $dm->zsync; - my $limit = $mirrorlist ? 100 : (( $metalink || $dm->pedantic )? 10 : 1); + my $limit = $mirrorlist ? 200 : (( $metalink || $dm->pedantic )? 10 : 1); + my $hard_limit = $dm->metalink_limit; + $limit = $hard_limit if $hard_limit; my $rs = $dm->c->schemaR->resultset('Server'); my $m; @@ -758,10 +760,13 @@ !$mirrorlist, $ipvstrict, $vpn ) if $country; - push @$mirrors_country, @$m if $m && scalar(@$m); + if ($m && scalar(@$m)) { + splice(@$m, $hard_limit) if $hard_limit && $hard_limit > scalar(@$m); + push @$mirrors_country, @$m; + } my $found_count = scalar(@$mirrors_country) + scalar(@$mirrors_region) + scalar(@$mirrors_rest); - if ($region && (($found_count < $limit))) { + if ($region && ($found_count < $limit) && (!$hard_limit || $found_count < $hard_limit)) { my @avoid_countries; push @avoid_countries, @$avoid_countries if $avoid_countries && scalar(@$avoid_countries); push @avoid_countries, $country if ($country and !(grep { $country eq $_ } @avoid_countries)); @@ -771,15 +776,20 @@ !$mirrorlist, $ipvstrict, $vpn ); my $found_more; + $found_more = scalar(@$m) if $m; if ($found_more) { + if ($hard_limit && $found_count + $found_more > $hard_limit) { + $found_more = $hard_limit - $found_count; + splice @$m, $found_more; + } $found_count += $found_more; push @$mirrors_region, @$m; } } if ( - ($found_count < $limit && !$dm->root_country) || + ($found_count < $limit && !$dm->root_country && (!$hard_limit || $hard_limit > $found_count)) || ($metalink && $found_count < 3) || $mirrorlist ) { @@ -791,6 +801,10 @@ my $found_more; $found_more = scalar(@$m) if $m; if ($found_more) { + if ($hard_limit && $found_count + $found_more > $hard_limit) { + $found_more = $hard_limit - $found_count; + splice @$m, $found_more; + } $found_count += $found_more; push @$mirrors_rest, @$m; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm new/MirrorCache-1.062/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm --- old/MirrorCache-1.061/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/lib/MirrorCache/WebAPI/Plugin/Subsidiary.pm 2023-08-03 10:35:43.000000000 +0200 @@ -94,9 +94,12 @@ my $country = $dm->country; my $region = $dm->region; - my $url = _has_subsidiary($c, $dm); + my $url = $c->mcconfig->geoip->{$region} if $region; + unless ($url) { + $url = _has_subsidiary($c, $dm); + $url = $url->to_abs if $url; + } return $c->render(status => 204, text => '') unless $url; - $url = $url->to_abs; $url =~ s/http(s)?:\/\///; $c->res->headers->content_disposition("attachment; filename=\"$basename\""); $c->render(data => "<geoip><region>$region</region><country>$country</country><host>$url</host></geoip>", format => 'xml'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/t/environ/01-smoke-mirror-hasall.sh new/MirrorCache-1.062/t/environ/01-smoke-mirror-hasall.sh --- old/MirrorCache-1.061/t/environ/01-smoke-mirror-hasall.sh 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/t/environ/01-smoke-mirror-hasall.sh 2023-08-03 10:35:43.000000000 +0200 @@ -44,4 +44,16 @@ rc=0 $mc/curl -I /download/folder1/file1.1.dat?"COUNTRY=it&PEDANTIC=1" | grep "${FAKEURL}" || rc=$? test $rc -gt 0 + +echo test LIMIT with meta4 +test 3 == $($mc/curl /download/folder1/file1.1.dat.meta4 | grep location | wc -l) +test 2 == $($mc/curl /download/folder1/file1.1.dat.meta4?LIMIT=2 | grep location | wc -l) +test 1 == $($mc/curl /download/folder1/file1.1.dat.meta4?LIMIT=1 | grep location | wc -l) + + +echo test LIMIT with metalink +test 3 == $($mc/curl /download/folder1/file1.1.dat.metalink | grep location | wc -l) +test 2 == $($mc/curl /download/folder1/file1.1.dat.metalink?LIMIT=2 | grep location | wc -l) +test 1 == $($mc/curl /download/folder1/file1.1.dat.metalink?LIMIT=1 | grep location | wc -l) + echo success diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/t/environ/03-headquarter-subsidiaries-country.sh new/MirrorCache-1.062/t/environ/03-headquarter-subsidiaries-country.sh --- old/MirrorCache-1.061/t/environ/03-headquarter-subsidiaries-country.sh 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/t/environ/03-headquarter-subsidiaries-country.sh 2023-08-03 10:35:43.000000000 +0200 @@ -67,3 +67,14 @@ curl --interface $cn_interface -Is http://$cn_address/rest/server | grep '200 OK' curl --interface $na_interface -Is http://$na_address/rest/server | grep '200 OK' curl --interface $eu_interface -Is http://$eu_address/rest/server | grep '200 OK' + +$mc9/stop +echo "export MIRRORCACHE_INI=$mc9/conf.ini" >> $mc9/conf.env +echo "export MIRRORCACHE_GEOIP_EU=test1.com" >> $mc9/conf.env +echo "geoip_as=test2.com" >> $mc9/conf.ini +$mc9/start + +curl -si --interface $eu_interface http://$hq_address/geoip | grep -A 50 '200 OK' | grep "<host>test1.com</host>" +curl -si --interface $cn_interface http://$hq_address/geoip | grep -A 50 '200 OK' | grep "<host>test2.com</host>" + +echo success diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/t/environ/20-report-download.sh new/MirrorCache-1.062/t/environ/20-report-download.sh --- old/MirrorCache-1.061/t/environ/20-report-download.sh 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/t/environ/20-report-download.sh 2023-08-03 10:35:43.000000000 +0200 @@ -96,4 +96,6 @@ $mc/backstage/job -e report -a '["once"]' $mc/backstage/shoot +$mc/curl /rest/repdownload?group=mirror,country | grep '{"bytes_redirected":"396","bytes_served":"0","bytes_total":"396","country":"de",' | grep -o '"known_files_no_mirrors":"0","known_files_redirected":"36","known_files_requested":"36","mirror":"127.0.0.1:1314","total_requests":"36"}' + echo success diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MirrorCache-1.061/templates/branding/openSUSE/footer.html.ep new/MirrorCache-1.062/templates/branding/openSUSE/footer.html.ep --- old/MirrorCache-1.061/templates/branding/openSUSE/footer.html.ep 2023-07-20 08:47:03.000000000 +0200 +++ new/MirrorCache-1.062/templates/branding/openSUSE/footer.html.ep 2023-08-03 10:35:43.000000000 +0200 @@ -2,7 +2,7 @@ <div class="container"> <div class="d-flex justify-content-between"> <div class="footer-copyright"> - © 2021,2022 SUSE LLC., openSUSE contributors + © 2021-2023 SUSE LLC., openSUSE contributors </div> <div class="list-inline"> <a class="list-inline-item" href="https://en.opensuse.org/Imprint">Legal notice</a> ++++++ MirrorCache.obsinfo ++++++ --- /var/tmp/diff_new_pack.gpFtVc/_old 2023-08-10 15:35:01.700585828 +0200 +++ /var/tmp/diff_new_pack.gpFtVc/_new 2023-08-10 15:35:01.704585854 +0200 @@ -1,5 +1,5 @@ name: MirrorCache -version: 1.061 -mtime: 1689835623 -commit: ccac89f907703f26b57e8f2d2068d94cf4e41601 +version: 1.062 +mtime: 1691051743 +commit: 4f34752b944d19295a710909c801dbcbbb2f818f