| 1 |
{{define "title"}}Mirrorlist {{.FileInfo.Path}}{{end}} |
| 2 |
{{define "headline"}}{{.FileInfo.Path}}{{end}} |
| 3 |
|
| 4 |
{{define "head"}} |
| 5 |
{{if not .LocalJSPath}} |
| 6 |
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/excanvas.min.js"></script><![endif]--> |
| 7 |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
| 8 |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.min.js"></script> |
| 9 |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.pie.min.js"></script> |
| 10 |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flot.tooltip/0.9.0/jquery.flot.tooltip.min.js"></script> |
| 11 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.css" /> |
| 12 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.js"></script> |
| 13 |
{{else}} |
| 14 |
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="{{.LocalJSPath}}/flot/0.8.3/excanvas.min.js"></script><![endif]--> |
| 15 |
<script type="text/javascript" src="{{.LocalJSPath}}/jquery/3.3.1/jquery.min.js"></script> |
| 16 |
<script type="text/javascript" src="{{.LocalJSPath}}/flot/0.8.3/jquery.flot.min.js"></script> |
| 17 |
<script type="text/javascript" src="{{.LocalJSPath}}/flot/0.8.3/jquery.flot.pie.min.js"></script> |
| 18 |
<script type="text/javascript" src="{{.LocalJSPath}}/flot.tooltip/0.9.0/jquery.flot.tooltip.min.js"></script> |
| 19 |
<link rel="stylesheet" href="{{.LocalJSPath}}/leaflet/1.3.4/leaflet.css" /> |
| 20 |
<script src="{{.LocalJSPath}}/leaflet/1.3.4/leaflet.js"></script> |
| 21 |
{{end}} |
| 22 |
<script type="text/javascript"> |
| 23 |
$(function() { |
| 24 |
{{$filledchart := false}} |
| 25 |
var mirrordistchartdata = [ |
| 26 |
{{range $i, $v := .MirrorList -}} |
| 27 |
{{if $v.Weight}}{{$filledchart = "yes"}}{ label: '{{$v.Name}}', data: {{$v.Weight}}},{{end}} |
| 28 |
{{- end -}} |
| 29 |
{{if not $filledchart}}{ label: 'Random', data: 100 },{{end}} |
| 30 |
]; |
| 31 |
$.plot('#chart_div', mirrordistchartdata, { |
| 32 |
series: { |
| 33 |
pie: { |
| 34 |
show: true, |
| 35 |
radius: 1, |
| 36 |
label: { |
| 37 |
show: true, |
| 38 |
radius: 0.75, |
| 39 |
formatter: labelFormatter, |
| 40 |
threshold: 0.02 |
| 41 |
}, |
| 42 |
combine: { |
| 43 |
threshold: 0.02 // 0.02 == 2% |
| 44 |
}, |
| 45 |
} |
| 46 |
}, |
| 47 |
legend: { |
| 48 |
show: true |
| 49 |
}, |
| 50 |
grid: { |
| 51 |
hoverable: true |
| 52 |
}, |
| 53 |
tooltip: { |
| 54 |
show: true, |
| 55 |
content: "%s: %p.2%", |
| 56 |
shifts: { |
| 57 |
x: 10, y: 0 |
| 58 |
}, |
| 59 |
defaultTheme: true |
| 60 |
} |
| 61 |
}); |
| 62 |
}); |
| 63 |
function labelFormatter(label, series) { |
| 64 |
return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>" + series.percent.toFixed(1) + "%</div>"; |
| 65 |
} |
| 66 |
</script> |
| 67 |
<style> |
| 68 |
.numberboxinmapblue { |
| 69 |
background:blue; color:white; border:none; |
| 70 |
text-align:center; |
| 71 |
font-size: 11px; |
| 72 |
min-height: 16px; min-width: 16px; |
| 73 |
} |
| 74 |
.numberboxinmapblue:after { |
| 75 |
content: ''; |
| 76 |
position: absolute; |
| 77 |
bottom: 0; |
| 78 |
left: 50%; |
| 79 |
width: 0; height: 0; |
| 80 |
border: 4px solid transparent; |
| 81 |
border-top-color: blue; |
| 82 |
border-bottom: 0; |
| 83 |
margin-left: -4px; margin-bottom: -4px; |
| 84 |
} |
| 85 |
.numberboxinmapgreen { |
| 86 |
background:green; color:white; border:none; |
| 87 |
text-align:center; |
| 88 |
font-size: 11px; |
| 89 |
min-height: 16px; min-width: 16px; |
| 90 |
} |
| 91 |
.numberboxinmapgreen:after { |
| 92 |
content: ''; |
| 93 |
position: absolute; |
| 94 |
bottom: 0; |
| 95 |
left: 50%; |
| 96 |
width: 0; height: 0; |
| 97 |
border: 4px solid transparent; |
| 98 |
border-top-color: green; |
| 99 |
border-bottom: 0; |
| 100 |
margin-left: -4px; margin-bottom: -4px; |
| 101 |
} |
| 102 |
</style> |
| 103 |
{{end}} |
| 104 |
|
| 105 |
{{define "body"}} |
| 106 |
<div style="display: flex; flex-wrap: wrap;"> |
| 107 |
<div style="flex-basis: 250px; flex-grow: 1; margin: 8px;"> |
| 108 |
<h3>Client</h3> |
| 109 |
<div>You are connecting with IP address <i>{{.IP}}</i>, which belongs to autonomous system <i>{{.ClientInfo.ASName}} (ASN{{.ClientInfo.ASNum}})</i>.<br /> |
| 110 |
{{if .ClientInfo.IsValid}}We believe you are {{if .ClientInfo.City}}near <i>{{.ClientInfo.City}}</i> in {{else}}somewhere in {{end}}<i>{{.ClientInfo.Country}}</i> and have selected mirrors based on this.{{else}}We were not able to use your IP to approximate your location, so have chosen the mirrors at random.{{end}}</div> |
| 111 |
</div> |
| 112 |
|
| 113 |
<div style="flex-basis: 325px; flex-grow: 1; margin: 8px;"> |
| 114 |
<h3>File</h3> |
| 115 |
<div> |
| 116 |
{{if not (iszero .FileInfo.ModTime)}} |
| 117 |
The file <b>{{.FileInfo.Path}}</b> has a size of {{sizeof .FileInfo.Size}} ({{.FileInfo.Size}} bytes) and was last modified on {{dateutc .FileInfo.ModTime}}. |
| 118 |
{{else}} |
| 119 |
The file <b>{{.FileInfo.Path}}</b> has not been scanned yet, size and modification time are unknown. |
| 120 |
{{end}} |
| 121 |
</div> |
| 122 |
<div> |
| 123 |
<br/>Known hashes: |
| 124 |
<table class="alt"> |
| 125 |
<tr><td>MD5</td><td style="font-family: monospace; word-break: break-all;">{{if .FileInfo.Md5}}{{.FileInfo.Md5}}{{else}}N/A{{end}}</td></tr> |
| 126 |
<tr><td>SHA1</td><td style="font-family: monospace; word-break: break-all;">{{if .FileInfo.Sha1}}{{.FileInfo.Sha1}}{{else}}N/A{{end}}</td></tr> |
| 127 |
<tr><td>SHA256</td><td style="font-family: monospace; word-break: break-all;">{{if .FileInfo.Sha256}}{{.FileInfo.Sha256}}{{else}}N/A{{end}}</td></tr> |
| 128 |
</table> |
| 129 |
</div> |
| 130 |
<br/> |
| 131 |
</div> |
| 132 |
</div> |
| 133 |
|
| 134 |
<div style="display: flex; flex-wrap: wrap; justify-content: space-around;"> |
| 135 |
<div id="map" style="width:600; height:320;"></div> |
| 136 |
<div id="chart_div" style="width:600; height:320;"></div> |
| 137 |
</div> |
| 138 |
|
| 139 |
<script> |
| 140 |
var map = L.map('map').setView([20,37], 2); |
| 141 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 142 |
attribution: 'Data © <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>, map rendering <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>' |
| 143 |
}).addTo(map); |
| 144 |
|
| 145 |
var mapdata = { |
| 146 |
"mirrors" : [ |
| 147 |
{{range $i, $v := .MirrorList}}{{if lt $i 19 }} |
| 148 |
{ |
| 149 |
"lat" : {{$v.Latitude}}, |
| 150 |
"lon" : {{$v.Longitude}}, |
| 151 |
"nr" : {{add $i 1}}, |
| 152 |
"color" : {{if $v.Weight}}"green"{{else}}"blue"{{end}} |
| 153 |
}, |
| 154 |
{{end}}{{end}} |
| 155 |
], |
| 156 |
"clientpos" : { |
| 157 |
{{if .ClientInfo.IsValid }} |
| 158 |
"lat" : {{.ClientInfo.Latitude}}, |
| 159 |
"lon" : {{.ClientInfo.Longitude}} |
| 160 |
{{else}} |
| 161 |
"lat" : 0.0, |
| 162 |
"lon" : 0.0 |
| 163 |
{{end}} |
| 164 |
} |
| 165 |
}; |
| 166 |
var latlngbounds = new L.latLngBounds(); // For calculating the boundaries we zoom to on map load |
| 167 |
if ((mapdata.clientpos.lat != 0.0) || (mapdata.clientpos.lon != 0.0)) { |
| 168 |
var nxtmarker = new L.marker([mapdata.clientpos.lat, mapdata.clientpos.lon]); |
| 169 |
nxtmarker.addTo(map); |
| 170 |
latlngbounds.extend([mapdata.clientpos.lat, mapdata.clientpos.lon]); |
| 171 |
if (mapdata.mirrors.length > 0) { |
| 172 |
var polyline = L.polyline( [ |
| 173 |
[ mapdata.clientpos.lat, mapdata.clientpos.lon ], |
| 174 |
[ mapdata.mirrors[0].lat, mapdata.mirrors[0].lon ] |
| 175 |
], |
| 176 |
{color: 'blue', opacity: 0.6}); |
| 177 |
polyline.addTo(map); |
| 178 |
// No need to update the bounds - that happens when the mirrors dot is added below. |
| 179 |
} |
| 180 |
} |
| 181 |
var showaftercutoff = 3; // How many mirrors without weight to use for calculating bounds |
| 182 |
for (i in mapdata.mirrors) { |
| 183 |
var myIcon = L.divIcon({ |
| 184 |
className: 'numberboxinmap' + mapdata.mirrors[i].color, |
| 185 |
html: "" + mapdata.mirrors[i].nr, |
| 186 |
iconSize: null, |
| 187 |
iconAnchor: [8, 20] |
| 188 |
}); |
| 189 |
var nxtmarker = new L.marker([mapdata.mirrors[i].lat, mapdata.mirrors[i].lon], {icon: myIcon}); |
| 190 |
nxtmarker.addTo(map); |
| 191 |
if (mapdata.mirrors[i].color != "green") { |
| 192 |
showaftercutoff--; |
| 193 |
} |
| 194 |
if (showaftercutoff > 0) { |
| 195 |
latlngbounds.extend([mapdata.mirrors[i].lat, mapdata.mirrors[i].lon]); |
| 196 |
} |
| 197 |
} |
| 198 |
latlngbounds.pad(1); |
| 199 |
map.fitBounds(latlngbounds); |
| 200 |
</script> |
| 201 |
|
| 202 |
<div> |
| 203 |
<br/> |
| 204 |
<h3>Mirrors</h3> |
| 205 |
|
| 206 |
{{if .Fallback}}<p style="color:red">Warning: file not served by any mirror, fallbacks to the rescue.</p>{{end}} |
| 207 |
|
| 208 |
{{if .MirrorList}} |
| 209 |
<table border="0" cellpadding="2" class="alt" style="width: 95%; text-align:left;"> |
| 210 |
<thead><tr> |
| 211 |
<th style="width: 3%;">Rank</th><th style="width: 20%;">Mirror Name</th><th style="text-align: right;">URL</th><th style="text-align: center; width: 10%;">Country</th><th style="text-align: center;">Continent</th><th style="text-align: right;">Distance</th><th style="text-align: center;">Selection</th> |
| 212 |
</tr></thead> |
| 213 |
<tbody> |
| 214 |
{{range $i, $v := .MirrorList}} |
| 215 |
<tr{{if not $v.Weight}} style="color: grey;"{{end}}> |
| 216 |
<td style="text-align: right;">{{add $i 1}}.</td><td>{{if $v.SponsorName}}{{$v.SponsorName}}{{else}}{{$v.Name}}{{end}}</td><td style="text-align: right;"><a href="{{concaturl $v.AbsoluteURL $.FileInfo.Path}}">{{$v.AbsoluteURL}}</a></td><td style="text-align: center;">{{$v.CountryCodes}}</td><td style="text-align: center;">{{$v.ContinentCode}}</td><td style="text-align: right;">{{printf "%.0f" $v.Distance}} Km</td><td style="text-align: center;">{{if $v.Weight}}{{if ge $v.Weight 1.0}}{{printf "%.0f" $v.Weight}}{{else}}<1{{end}}%{{else}}n/a{{end}}</td> |
| 217 |
</tr> |
| 218 |
{{end}} |
| 219 |
</tbody> |
| 220 |
</table> |
| 221 |
{{else}} |
| 222 |
<i>No mirrors for this file</i> |
| 223 |
{{end}} |
| 224 |
|
| 225 |
{{if .ExcludedList}} |
| 226 |
<h3>Excluded Mirrors</h3> |
| 227 |
<table border="0" cellpadding="2" class="alt" style="width: 95%; text-align:left;"> |
| 228 |
<thead><tr> |
| 229 |
<th style="width: 23%;">Mirror Name</th><th style="text-align: right;">URL</th><th style="text-align: center; width: 10%;">Country</th><th style="text-align: center;">Continent</th><th style="text-align: right;">Distance</th><th style="text-align: center; width: 20%;">Exclude Reason</th></tr></thead> |
| 230 |
<tbody> |
| 231 |
{{range $i, $v := .ExcludedList}} |
| 232 |
<tr> |
| 233 |
<td>{{if $v.SponsorName}}{{$v.SponsorName}}{{else}}{{$v.Name}}{{end}}<td style="text-align: right;"><a href="{{$v.AbsoluteURL}}">{{$v.AbsoluteURL}}</a></td><td style="text-align: center;">{{$v.CountryCodes}}</td><td style="text-align: center;">{{$v.ContinentCode}}</td><td style="text-align:right;">{{printf "%.0f" $v.Distance}} Km</td><td style="text-align: center;">{{$v.ExcludeReason}}</td> |
| 234 |
</tr> |
| 235 |
{{end}} |
| 236 |
</tbody> |
| 237 |
</table> |
| 238 |
{{end}} |
| 239 |
</div> |
| 240 |
{{end}} |