|
|
@@ -33,20 +33,36 @@ import (
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
- useHTTP = os.Getenv("UR_USE_HTTP") != ""
|
|
|
- debug = os.Getenv("UR_DEBUG") != ""
|
|
|
- keyFile = getEnvDefault("UR_KEY_FILE", "key.pem")
|
|
|
- certFile = getEnvDefault("UR_CRT_FILE", "crt.pem")
|
|
|
- dbConn = getEnvDefault("UR_DB_URL", "postgres://user:password@localhost/ur?sslmode=disable")
|
|
|
- listenAddr = getEnvDefault("UR_LISTEN", "0.0.0.0:8443")
|
|
|
- geoIPPath = getEnvDefault("UR_GEOIP", "GeoLite2-City.mmdb")
|
|
|
- tpl *template.Template
|
|
|
- compilerRe = regexp.MustCompile(`\(([A-Za-z0-9()., -]+) \w+-\w+(?:| android| default)\) ([\[email protected]]+)`)
|
|
|
- progressBarClass = []string{"", "progress-bar-success", "progress-bar-info", "progress-bar-warning", "progress-bar-danger"}
|
|
|
- featureOrder = []string{"Various", "Folder", "Device", "Connection", "GUI"}
|
|
|
- knownVersions = []string{"v2", "v3"}
|
|
|
+ useHTTP = os.Getenv("UR_USE_HTTP") != ""
|
|
|
+ debug = os.Getenv("UR_DEBUG") != ""
|
|
|
+ keyFile = getEnvDefault("UR_KEY_FILE", "key.pem")
|
|
|
+ certFile = getEnvDefault("UR_CRT_FILE", "crt.pem")
|
|
|
+ dbConn = getEnvDefault("UR_DB_URL", "postgres://user:password@localhost/ur?sslmode=disable")
|
|
|
+ listenAddr = getEnvDefault("UR_LISTEN", "0.0.0.0:8443")
|
|
|
+ geoIPPath = getEnvDefault("UR_GEOIP", "GeoLite2-City.mmdb")
|
|
|
+ tpl *template.Template
|
|
|
+ compilerRe = regexp.MustCompile(`\(([A-Za-z0-9()., -]+) \w+-\w+(?:| android| default)\) ([\[email protected]]+)`)
|
|
|
+ progressBarClass = []string{"", "progress-bar-success", "progress-bar-info", "progress-bar-warning", "progress-bar-danger"}
|
|
|
+ featureOrder = []string{"Various", "Folder", "Device", "Connection", "GUI"}
|
|
|
+ knownVersions = []string{"v2", "v3"}
|
|
|
+ knownDistributions = []distributionMatch{
|
|
|
+ // Maps well known builders to the official distribution method that
|
|
|
+ // they represent
|
|
|
+ {regexp.MustCompile("android-.*[email protected]"), "Google Play"},
|
|
|
+ {regexp.MustCompile("[email protected]"), "GitHub"},
|
|
|
+ {regexp.MustCompile("[email protected]"), "APT"},
|
|
|
+ {regexp.MustCompile("[email protected]"), "Docker Hub"},
|
|
|
+ {regexp.MustCompile("[email protected]"), "GitHub"},
|
|
|
+ {regexp.MustCompile("[email protected]"), "Snappy"},
|
|
|
+ {regexp.MustCompile("."), "Others"},
|
|
|
+ }
|
|
|
)
|
|
|
|
|
|
+type distributionMatch struct {
|
|
|
+ matcher *regexp.Regexp
|
|
|
+ distribution string
|
|
|
+}
|
|
|
+
|
|
|
var funcs = map[string]interface{}{
|
|
|
"commatize": commatize,
|
|
|
"number": number,
|
|
|
@@ -1001,6 +1017,7 @@ func getReport(db *sql.DB) map[string]interface{} {
|
|
|
var uptime []int
|
|
|
var compilers []string
|
|
|
var builders []string
|
|
|
+ var distributions []string
|
|
|
locations := make(map[location]int)
|
|
|
countries := make(map[string]int)
|
|
|
|
|
|
@@ -1070,10 +1087,19 @@ func getReport(db *sql.DB) map[string]interface{} {
|
|
|
nodes++
|
|
|
versions = append(versions, transformVersion(rep.Version))
|
|
|
platforms = append(platforms, rep.Platform)
|
|
|
+
|
|
|
if m := compilerRe.FindStringSubmatch(rep.LongVersion); len(m) == 3 {
|
|
|
compilers = append(compilers, m[1])
|
|
|
builders = append(builders, m[2])
|
|
|
+ loop:
|
|
|
+ for _, d := range knownDistributions {
|
|
|
+ if d.matcher.MatchString(rep.LongVersion) {
|
|
|
+ distributions = append(distributions, d.distribution)
|
|
|
+ break loop
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if rep.NumFolders > 0 {
|
|
|
numFolders = append(numFolders, rep.NumFolders)
|
|
|
}
|
|
|
@@ -1366,6 +1392,7 @@ func getReport(db *sql.DB) map[string]interface{} {
|
|
|
r["platforms"] = group(byPlatform, analyticsFor(platforms, 2000), 5)
|
|
|
r["compilers"] = group(byCompiler, analyticsFor(compilers, 2000), 5)
|
|
|
r["builders"] = analyticsFor(builders, 12)
|
|
|
+ r["distributions"] = analyticsFor(distributions, 10)
|
|
|
r["featureOrder"] = featureOrder
|
|
|
r["locations"] = locations
|
|
|
r["contries"] = countryList
|