2020-05-04 12:17:14 -07:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
2020-05-13 19:23:53 -07:00
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
2020-05-04 12:17:14 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handle http(s) downloads for zcash params
|
2021-04-21 10:40:39 -07:00
|
|
|
func ParamsHandler(w http.ResponseWriter, req *http.Request) {
|
2020-05-04 12:17:14 -07:00
|
|
|
if strings.HasSuffix(req.URL.Path, "sapling-output.params") {
|
2021-04-21 10:40:39 -07:00
|
|
|
Metrics.TotalSaplingParamsCounter.Inc()
|
|
|
|
Log.WithFields(logrus.Fields{
|
2020-05-13 19:23:53 -07:00
|
|
|
"method": "params",
|
|
|
|
"param": "sapling-output",
|
|
|
|
}).Info("ParamsHandler")
|
|
|
|
|
2020-05-04 12:17:14 -07:00
|
|
|
http.Redirect(w, req, "https://z.cash/downloads/sapling-output.params", 301)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasSuffix(req.URL.Path, "sapling-spend.params") {
|
2021-04-21 10:40:39 -07:00
|
|
|
Log.WithFields(logrus.Fields{
|
2020-05-13 19:23:53 -07:00
|
|
|
"method": "params",
|
|
|
|
"param": "sapling-spend",
|
|
|
|
}).Info("ParamsHandler")
|
|
|
|
|
2020-05-04 12:17:14 -07:00
|
|
|
http.Redirect(w, req, "https://z.cash/downloads/sapling-spend.params", 301)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasSuffix(req.URL.Path, "sprout-groth16.params") {
|
2021-04-21 10:40:39 -07:00
|
|
|
Log.WithFields(logrus.Fields{
|
2020-05-13 19:23:53 -07:00
|
|
|
"method": "params",
|
|
|
|
"param": "sprout",
|
|
|
|
}).Info("ParamsHandler")
|
2021-04-21 10:40:39 -07:00
|
|
|
Metrics.TotalSproutParamsCounter.Inc()
|
2020-05-13 19:23:53 -07:00
|
|
|
|
2020-05-04 12:17:14 -07:00
|
|
|
http.Redirect(w, req, "https://z.cash/downloads/sprout-groth16.params", 301)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
http.Error(w, "Not Found", 404)
|
|
|
|
}
|